ImageSearch Persistent ErrorCode=2 Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
SB1992
Posts: 5
Joined: 19 Sep 2019, 21:03

ImageSearch Persistent ErrorCode=2

19 Sep 2019, 21:46

Hello everyone!

New to AutoHotkey and I cannot figure out what I am doing wrong here. From the ToolTip it is clear that I have 4 numbers that should work for Image Search, but the ErrorLevel is always 2.

Code: Select all

MouseX:=non
MouseY:=non
TopLeftX:=non
TopLeftY:=non
BottomRightX:=non
BottomRightY:=non

#Persistent
SetTimer, WatchCursor, 100
return

WatchCursor:
MouseGetPos, MouseX, MouseY
TopLeftX := MouseX-100
TopLeftY := MouseY+200
BottomRightX := MouseX+100
BottomRightY := MouseY
ImageSearch, OPX, OPY, %TopLeftX%, %TopLeftY%, %BottomRightX%, %BottomRightY%, Image.JPG
test=%ErrorLevel%
ToolTip,  %TopLeftX%  %TopLeftY%  %BottomRightX% %BottomRightX% %ErrorLevel%
The image file is in the same directory as the script. If anyone has a suggestion to fix this code (or even to clean it up) that would be fantastic!

Cheers!

-S
User avatar
Xtra
Posts: 1446
Joined: 02 Oct 2015, 12:15

Re: ImageSearch Persistent ErrorCode=2  Topic is solved

19 Sep 2019, 23:54

TopLeftX := MouseX-100
TopLeftY := MouseY+200
BottomRightX := MouseX+100
BottomRightY := MouseY

Your top left Y pos is lower than your bottom right Y pos. This cause your search area to not be a rectangle.

The next problem you will most likely have is using a .jpg image try using a lossless format such as .png or .bmp

HTH
SB1992
Posts: 5
Joined: 19 Sep 2019, 21:03

Re: ImageSearch Persistent ErrorCode=2

21 Sep 2019, 19:06

Thank you for making clear this issue! As Height (the max pixel) is at the bottom of my screen I need to subtract from Height to look higher.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Bort P, Google [Bot], Marcosa1020, SOTE and 194 guests