image search problem

Ask gaming related questions (AHK v1.1 and older)
floqqi
Posts: 1
Joined: 05 Mar 2018, 10:39

image search problem

05 Mar 2018, 12:43

i need to find imgae and click it by condition
sorry for my bad english
it mean search for img1 - if find click img1
if not find - find img2 and click img2
i have did this code but it only work for few loob and then dont work
i dont know why :crazy: :crazy:

Code: Select all

`::
loop{
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, C:\Users\Floq\Desktop\4.png
If(ErrorLevel == 0){
Click, %foundX%, %foundY%
Sleep, 150
Send, q
}else{
ImageSearch, aX, aY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, C:\Users\Floq\Desktop\5.png
If(ErrorLevel == 0){
Click, %aX%, %aY%
Sleep, 150
Send, Tab key
}else{
Send, q
}
}
}
return
alt::pause
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: image search problem

05 Mar 2018, 22:20

Hi,
based on your script, try

Code: Select all

`::
loop
{
	ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, C:\Users\Floq\Desktop\4.png
	If ErrorLevel = 0
	{
		ToolTip, Image 1 Found, 10, 10, 2
		Click, %foundX%, %foundY%
		Sleep, 150
		Send, q
	}
	if ErrorLevel
	{
		ImageSearch, aX, aY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, C:\Users\Floq\Desktop\5.png
		If ErrorLevel = 0
		{
			ToolTip, Image 2 Found, 10, 10, 2
			Click, %aX%, %aY%
			Sleep, 150
			Send, Tab key
		}
		If ErrorLevel
		{
			ToolTip, image not found, 10, 10, 2
			Send, q
		}
	}
}
return
alt::pause

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 75 guests