ImageSearch returning wrong coords?

Ask gaming related questions
Posts: 1
Joined: 10 Dec 2017, 19:42

ImageSearch returning wrong coords?

10 Dec 2017, 20:40


I am having some issues returning the correct coords when using ImageSearch in a game.
The game is running in Window mode, and I have reduced down the resolution from my native resolution (i.e. My desktop is running at 3840x2160, and the game is running in window mode at 1920x1080).
(I have tried running the game in full screen window mode also without success).

ImageSearch is finding the image, but when I use the returned coords with MouseMove, its moves to the wrong location.
I assumed it was due to the CoordMode, but having tried various combinations I have ran out of ideas.

Any ideas would be greatly appreciated, Thanks

Code: Select all

SetWorkingDir, %A_ScriptDir%

CoordMode, Mouse, Relative
CoordMode, Pixel, Relative
CoordMode, Tooltip, Relative

; Vars

; Debug
Gui, add, picture, x10 y10, %img%
Gui, show, x100 y10 h70 w250, Hit F2 to Find


WinActivate %win%
WinWaitActive, %win%
Sleep, 200

ImageSearch, X, Y, 0, 0, %a_screenwidth%, %a_screenheight%, *50 %img%
if errorlevel=1
else if errorlevel=2
	MsgBox, Not Found

MouseMove, X, Y
ToolTip, Found: %X% %Y%
Sleep, 4000
Kim Latrashgian

Re: ImageSearch returning wrong coords?

10 Dec 2017, 20:56

is it always off by the same amount? if it is you can just adjust the X Y
User avatar
Posts: 5154
Joined: 19 Dec 2016, 01:58
Location: UK

Re: ImageSearch returning wrong coords?

11 Dec 2017, 00:47

- Try MouseGetPos, and then MouseMove to the same coordinates, and see if there is a discrepancy, and what the pattern is.
- Based on the resolutions you state, maybe you need to double or halve the X/Y values.
- I usually prefer to use Screen coordinates rather than Window coordinates, it's possible that this would make things simpler.
- Sometimes, to be on the safe side, I use CoordMode at the start of a hotkey subroutine, just underneath the hotkey label. Also, you can retrieve the value of the A_CoordModeXXX variables to see if they are what you expected.

Return to “Gaming”

Who is online

Users browsing this forum: Evil-e and 9 guests