don't blink
don't blink

Reputation: 101

AHK How to make one SetTimer launch other, and than reversal

Goal of a code:

Timer CheckStart iterrates every 3 seconds until it find a choosen color.

If it finds pixel - it stops itself and start CheckStop timer, to look for another pixel every 3 seconds.

Rince and repeat

Also there is a keybind to check which timer was launched last.

#NoEnv
SendMode Input

checkstate = 0 ;just for checking state
SetTimer, CheckStart, 3000
Return

CheckStart:
    PixelSearch, xx, zz, 710, 460, 730, 480, 0x385982, 0, Alt RGB
    if !ErrorLevel {
        checkstate = 1
        SetTimer, CheckStart, Off
        SetTimer, CheckEnd, 3000
        Gosub, CheckEnd
    }
Return

CheckEnd:
    PixelSearch, xx, zz, 670, 160, 725, 200, 0xE60014, 0, Alt RGB
    if !ErrorLevel {
        checkstate = 0
        SetTimer, CheckEnd, Off
        SetTimer, CheckStart, 3000
        Gosub, CheckStart
    }
Return

^!z:: ; Control+Alt+Z 
    MouseGetPos, MouseX, MouseY
    PixelGetColor, color, %MouseX%, %MouseY%, Alt RGB
    MsgBox (checkstate%) colour: %color%. 
return

What I'm getting:

  1. Before i feed needed color to 1st timer, keybind works delayed, shows state only between iterrations. Can i make it async?
  2. After i feed needed color to 1st timer, checker became "1", but CheckEnd timer not starting. (and so keybind start to work immediately)

What i'm doing wrong? or its just prohibited to launch timer by timer?

Upvotes: 0

Views: 215

Answers (1)

0x464e
0x464e

Reputation: 6489

There is no such pixel search mode as Alt, that's only for PixelGetColor.
I'm going to assume the problem here is just the pixel search taking forever.
Add in the Fast mode.
So instead of Alt RGB try Fast RGB.

Upvotes: 1

Related Questions