Pixelsearch loop with break if timelimit reached

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bobelyk
Posts: 64
Joined: 26 Jun 2021, 16:55

Pixelsearch loop with break if timelimit reached

Post by bobelyk » 23 Oct 2021, 01:39

So i have this infinite loop:

Code: Select all

Sub1:
CoordMode, Pixel, Client
Pixelsearch, Px, Py, 1019, 759, 1019, 759, 0x010101, 1, fast
if (ErrorLevel = 0) {
    
}
Else {

Goto sub1
}

I want to know how to break it on these 2 scenarios:
-30 seconds have transcurred
- 6 loops have ocurred
Rohwedder
Posts: 7610
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Pixelsearch loop with break if timelimit reached

Post by Rohwedder » 23 Oct 2021, 07:01

Hallo,
try:

Code: Select all

Sub1:
CoordMode, Pixel, Client
Time := A_TickCount + 30000
Loop, 6
{
	Pixelsearch, Px, Py, 1019, 759, 1019, 759, 0x010101, 1, fast
}
Until, !ErrorLevel Or (A_TickCount >= Time)
Post Reply

Return to “Ask for Help (v1)”