Rhona Guerrero
Rhona Guerrero

Reputation: 63

How to prioritize the sending of a key in timer without interfering other?

I want to send the key to my browser refresh button (F5), every 3 minutes, but I don't want that the script will be interfered. Something like a timer. Click refresh (F5) every 3 minutes without interfering with the original script in the loop?

HotKeySet("{HOME}", "Start")
AdlibRegister("refresh", 180000)

While 1
    Sleep(200)
WEnd

Func refresh()
    Send("{F5}")
EndFunc

Func Start()
    While 1
        Call "refresh"

        $pink = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x8a0859)        
        If IsArray($pink) then
            MouseMove($pink[0], $pink[1], 0)
            Sleep(100)
            MouseClick("Left")
        Else
            $pink2 = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x8c085a)
            If IsArray($pink2) then
                MouseMove($pink2[0], $pink2[1], 0)
                Sleep(100)
                MouseClick("Left")
            Else
                $pink3 = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, 0x880852)
                If IsArray($pink3) then
                    MouseMove($pink3[0], $pink3[1], 0)
                    Sleep(100)
                    MouseClick("Left")
                EndIf
            EndIf
        EndIf
    WEnd
EndFunc

Upvotes: 0

Views: 126

Answers (2)

Stephan
Stephan

Reputation: 56180

AdlibRegister has a strange habit: if you unregister and register again (with the same time), the counter does not reset. That's annoying/unexpected most of the time, but exactly, what you need here:

Func Start()
    AdlibUnRegister("refresh")
    ; your original code here
    AdlibRegister("refresh", 180000)
EndFunc

Upvotes: 1

SachaDee
SachaDee

Reputation: 9545

take a look at : AdlibRegister

AdlibRegister("refresh", 180000) ; for 3 minutes

Upvotes: 1

Related Questions