Search image for 10 seconds

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
inthesky2
Posts: 35
Joined: 15 Jan 2016, 03:09

Search image for 10 seconds

04 Apr 2016, 00:45

Searching for a couple of images that must be done in the right order but because the images are part of gifs it sometimes misses the frame and skips an image instead of finding them in order. I need to search each image for 10 seconds before continuing to the next (duration of the gif)
Last edited by inthesky2 on 05 Apr 2016, 02:18, edited 1 time in total.
ahcahc
Posts: 110
Joined: 25 Jul 2014, 23:55

Re: Search image for 10 seconds

04 Apr 2016, 08:48

taken from one of my scripts.

Code: Select all

res :=  imgSearch(oX, oY, 0, 0, A_ScreenWidth, A_ScreenHeight, "test.png", 10) ;imagesearch test.png until it is found for 10
if res = 0
    MsgBox found
ExitApp


imgSearch(ByRef oX, ByRef oY, x1, y1, x2, y2, img, t)
{
	st := A_TickCount
	again_:
	ImageSearch, oX, oY, x1, y1, x2, y2, %img%
	if errorlevel = 0
		return 0
    else if errorlevel = 2
        return 2
	else
	{
		Sleep, 100
		if ((A_TickCount -st)/1000 > t)
			return errorlevel
		else
			goto again_
	}
}
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Search image for 10 seconds

04 Apr 2016, 09:01

Maybe a loop,10 together with sleep 10000 ?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: downstairs, filipemb, Google [Bot], OrangeCat and 164 guests