Jump to content

Loop in a while, and perform action every 4 loops


 Share

Recommended Posts

I have a small easy script I threw together in about a half hour and I have a main start button that I performs a list of actions in 11 seconds, I want this lottle list of actions to loop forever until I stop, but after about 3-4 loops I want it to do a special action, than repeat. So here is an example of waht I am looking for:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
Case $Button6
            WinActivate('[TITLE:Untitled - Notepad]')
            WinWaitActive('[TITLE:Untitled - Notepad]')
            Sleep(500)
            Send("{F1}")
            Sleep(2000)
            Send("{F2}")
            Sleep(2000)
            Send("{F3}")
            Sleep(2000)
            Send("{F4}")
            Sleep(2000)
            Send("{F5}")
            Sleep(2000)
    EndSwitch
WEnd

Now I want that script to loop forever until I clsoe program or hit "stop" AND I after it loops 3 times I want it to "Send("{F6}") and than go back to actions until another 3 loops. possible? Hope so!

Link to comment
Share on other sites

$count = 0
While 1
    If $count == 3 Then
        ;action
    Else
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button6
                WinActivate('[TITLE:Untitled - Notepad]')
                WinWaitActive('[TITLE:Untitled - Notepad]')
                Sleep(500)
                Send("{F1}")
                Sleep(2000)
                Send("{F2}")
                Sleep(2000)
                Send("{F3}")
                    Sleep(2000)
                Send("{F4}")
                Sleep(2000)
                Send("{F5}")
                Sleep(2000)
        EndSwitch
    EndIf
    $count = Mod($count + 1, 4)
WEnd

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...