Interrupted by questions about image search, please help me

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
autu
Posts: 17
Joined: 04 Apr 2015, 11:09

Interrupted by questions about image search, please help me

09 Apr 2015, 09:20

Interrupted by questions about image search, please help me see the code, thanks
My script is two cycles, if the first picture can not find the words, I can use the left mouse button to suspend the same token, the second picture can not find it, use the left mouse button can also be suspended.
My problem :when the script is runing, if two picture in the folder can not be found in webbrowers, then use the left mouse button to interrupt, then press and hold the left mouse button one time to be effective, if there is only a picture in the folder or not, then just click the left mouse button , I do not know what causes this condition (mouse serious delay)? How to solve
Script attached below:

F1::
loop
{
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\wang\Desktop\itt\1.bmp
If ErrorLevel = 0
MouseClick, left, 150, 235
break
}
if getkeystate("Lbutton",p)
break
}
loop
{
ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\wang\Desktop\itt\2.bmp
If ErrorLevel = 0
{
x :=FoundX
y :=FoundY
xm :=x+125
ym :=y+30
MouseClick, left, 180, 520
Send 12345
break
}
if getkeystate("Lbutton",p)
break
}
return
autu
Posts: 17
Joined: 04 Apr 2015, 11:09

Re: Interrupted by questions about image search, please help

09 Apr 2015, 10:53

Cause: Search 1.bmp takes 1.5 seconds
What is the solution?
User avatar
boiler
Posts: 16915
Joined: 21 Dec 2014, 02:44

Re: Interrupted by questions about image search, please help

09 Apr 2015, 17:21

Your first loop will never actually loop. It will always break on the first pass through. Whether or not the MouseClick is executed, the break is always executed. You probably meant to include the break with the MouseClick, left, 150, 235 in a block of code. Put { } around those two statements if that's what you meant.

You also have an unmatched brace.

I find it a lot easier to follow the logic and to check for matching braces by indenting my code like this:

Code: Select all

F1::
	loop
	{
		ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\wang\Desktop\itt\1.bmp 
		If ErrorLevel = 0 
			MouseClick, left, 150, 235 ; <<< This will only get executed if ErrorLevel = 0
		break ; <<< This will always be executed, causing the loop to only be executed once
	}
	if getkeystate("Lbutton",p)
		break
	} ; <<<<< THIS IS AN UNMATCHED BRACE
	loop
	{
		ImageSearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\wang\Desktop\itt\2.bmp 
		If ErrorLevel = 0 
		{ 
			x :=FoundX
			y :=FoundY 
			xm :=x+125
			ym :=y+30
			MouseClick, left, 180, 520 
			Send 12345 
			break 
		}
		if getkeystate("Lbutton",p) 
			break
	}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, CrowexBR, Google [Bot], Holarctic, montie, Rohwedder and 207 guests