get("#388") -- rect functions get("#428") -- findContents get("#430") -- makeIcon get("#433") -- iconDiff -- fw/fh: 8/17 cursor_unfocused = [[ RRRRRRRRRR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RAAAAAAAAR RRRRRRRRRR]] cursor_focused = "AAAAAAAAAA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.IRRRRRRRRA.ERRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.ARRRRRRRRA.AAAAAAAAAA" cursor_unfocused = cursor_unfocused:gsub("\n", ".") problem = findContents() if problem then return problem end fw, fh = 8, 17 -- font width/height tw = math.floor((contents_x2-contents_x1)/fw+0.5) th = math.floor((contents_y2-contents_y1)/fh+0.5) tolerance = 0.05 for y = 0, th-1 do for x = 0, tw-1 do xx, yy = contents_x1+x*fw, contents_y1+y*fh-1 cropped = {width=fw+2, height=fh+2, getInt = function(x, y) return img.getInt(xx+x, yy+y) end} icon = makeIcon(cropped) diff = iconDiffWithLimit(icon, cursor_unfocused, tolerance, fw+2, fh+2) if diff ~= nil and diff <= tolerance then return "Cursor: "..xx..", "..yy..", ".. xx+cropped.width..", "..yy+cropped.height.. ". Cursor position: "..(x+1).."/"..(y+1).. ". Window not focused." end diff2 = iconDiffWithLimit(icon, cursor_focused, tolerance, fw+2, fh+2) --[[if y == 23 then print(x, y, diff, diff2) if x == 37 or x == 38 then print(icon) end end]] if diff2 ~= nil and diff2 <= tolerance then return "Cursor: "..xx..", "..yy..", "..xx+cropped.width..", "..yy+cropped.height..". Cursor position: "..(x+1).."/"..(y+1)..". Window focused." end end end return "Cursor not found"