searchimage with errolevel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Lukk54
Posts: 9
Joined: 06 Mar 2021, 04:09

searchimage with errolevel

20 Apr 2021, 04:08

I have problem with error msgbox, which show on despite, that the image was found. Like image was found and it click on it but then msgbox with error shows too.
Thanks for help.


Code: Select all

Send j
j::
Sleep 500
ImageSearch,ix,iy,0,0,1920,1080, jauzfaktnevim.png
if !ErrorLevel 
{
    Mousemove, ix, iy
    Sleep 10
    Click
}
else if (ErrorLevel = 1)
{
Msgbox, obrázek nebyl nalezen
ButtonOK:
ExitApp
}
return
[Mod edit: [code][/code] tags added.]
User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: searchimage with errolevel

20 Apr 2021, 06:28

Exit all other scripts.
Save your script file, with no other code except what is shown in your post.
Reload.
User avatar
Chunjee
Posts: 1422
Joined: 18 Apr 2014, 19:05
Contact:

Re: searchimage with errolevel

20 Apr 2021, 08:05

Since many different commands have the ability to change ErrorLevel; I prefer to write if (ix) { which I think is more readable and requires less 'the error will be 0 on success' mental note.
malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: searchimage with errolevel

20 Apr 2021, 09:16

Chunjee, You are not right.
1)
Each thread retains its own value of ErrorLevel, meaning that if the current thread is interrupted by another, when the original thread is resumed it will still have its original value of ErrorLevel, not the ErrorLevel that may have been set by the interrupting thread.
https://www.autohotkey.com/docs/misc/ErrorLevel.htm
2)

Code: Select all

ix := 0   ; found
if (ix)
   msgbox found
else
   msgbox not found

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen and 370 guests