ImageSearch not working???

Get help with using AutoHotkey and its commands and hotkeys
PepeLapiu
Posts: 30
Joined: 19 Jun 2020, 14:06

ImageSearch not working???

06 Aug 2020, 23:51

Hey guys. I'm having a real hard time figuring out what's wrong with my image searches.
The following script always turns up no value for x and y, and a ErrorLevel 2 when I maximize and activate Thunderbird:

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
SetTitleMatchMode, 2
WinWaitActive, Thunderbird
WinMaximixe, Thunderbird
ImageSearch, x, y, 500, 700, 1100, 1100,‪‪ C:\Users\pepel\Desktop\Gradual\New_contract_link_old.png
MsgBox, x = %x% `ny = %y% `n%ErrorLevel%
MsgBox always turns up: no value for x and y, and a 2 for ErrorLevel

So I tried the following modified script:

Code: Select all

CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
SetTitleMatchMode, 2
WinWaitActive, Thunderbird
WinMaximize, Thunderbird
While (ErrorLevel=2)
	ImageSearch, x, y, 500, 700, 1100, 1100,‪‪ C:\Users\pepel\Desktop\Gradual\New_contract_link_old.png
MsgBox, x = %x% `ny = %y% `n%ErrorLevel%
An now the MsgBox always comes up with still no value for x and y, but with 0 as ErrorLevel.

So if I get it to repeat itself until it somehow gets itself out of ErrorLevel 2, it now finds the image, but doesn't give a value to x and y?

What am I doing wrong here?
Last edited by PepeLapiu on 07 Aug 2020, 00:14, edited 1 time in total.
User avatar
boiler
Posts: 5919
Joined: 21 Dec 2014, 02:44

Re: ImageSearch not working???

07 Aug 2020, 00:13

ErrorLevel 2 means that there is something wrong with the statement itself, so it never even searches for the image. In the first script, since you didn't try to invoke any options, that must mean that it can't find the file or the image file is bad or something like that.

In the second script, the reason it shows ErrorLevel of 0 but nothing for x and y is that it never executes your ImageSearch command. The value of ErrorLevel is 0 until a command changes it to be something else, and your while statement checks to see if it is 2, which it is not, so it never executes even one iteration of the loop and goes straight to the next line, which is the MsgBox.
PepeLapiu
Posts: 30
Joined: 19 Jun 2020, 14:06

Re: ImageSearch not working???

07 Aug 2020, 21:40

Well, what I found after a lot of trying is that it appears there can't be too many .PNG files in the same folder. For some reason, after a certain amount of .PNG files in a given folder, it stops working. My issue simply got solved by putting some .PNG files in a subfolder.
I don't understand it, but it works!

Return to “Ask For Help”

Who is online

Users browsing this forum: aifritz, Bing [Bot], Bv841455, ddt442, hasantr, hihixd, jadams, mikeyww, pelos, teadrinker, WOlfen and 33 guests