ImageSearch returning ErrorLevel 2 Topic is solved

Ask gaming related questions (AHK v1.1 and older)
FluffyMrKitty
Posts: 14
Joined: 24 May 2018, 19:43

ImageSearch returning ErrorLevel 2

31 May 2018, 01:27

First things first, here's the script:

Code: Select all

CoordMode, Pixel, Screen
#SingleInstance force
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , H
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input

~*XButton1::
psUel:=1

Loop
{
;=====================================
	ImageSearch, psUX, psUY, 3359, 449, 3360, 367, *Trans0xff1d00 *120 red.png
	if (ErrorLevel=0)
	{
		psUel=0
	}
	if (ErrorLevel=1)
	{
		psUel=1
	}
	if (ErrorLevel=2)
	{
		MsgBox, error
		return
	}
;=====================================
	if (GetKeyState("XButton1", "P")=0)
	{
		psUel:=1
	}
	if (psUel=0)
	{
		DllCall("Sleep",UInt,100.1)
		Click
	}
}
return

*F10::ExitApp
Now the issue is that ImageSearch is constantly returning an ErrorLevel value of 2. I've tried changing the directory of the image and removing the additional arguments (*Trans and *120) to no avail.
Any thoughts? Did I do something silly?
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: ImageSearch returning ErrorLevel 2

31 May 2018, 02:09

red.png will need to be in the same folder as the script you are running.

ImageSearch
SetWorkingDir
A_WorkingDir
ImageFile
The file name of an image, which is assumed to be in %A_WorkingDir% if an absolute path isn't specified.

A_WorkingDir
The script's current working directory, which is where files will be accessed by default.
HTH
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: ImageSearch returning ErrorLevel 2

31 May 2018, 03:22

try \red.png
workingdir wrote: The final backslash is not included unless it is the root directory.
FluffyMrKitty
Posts: 14
Joined: 24 May 2018, 19:43

Re: ImageSearch returning ErrorLevel 2

31 May 2018, 03:38

Still throws errorlevel 2 when using \red.png
FluffyMrKitty
Posts: 14
Joined: 24 May 2018, 19:43

Re: ImageSearch returning ErrorLevel 2  Topic is solved

31 May 2018, 04:03

Found my solution here: https://autohotkey.com/board/topic/1143 ... orlevel-2/
Apparently Y2 needs to be greater than Y1. Sorry for wasting anybody's time! Should've done my research.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 167 guests