Jump to content

Nested While Loops


 Share

Recommended Posts

Ah, this is driving me nuts. Am trying to have three loops. First Loop waits for middle mouse button, when that is pressed action is taken first loop is exited and second loop kicks in. Second loop waits for the Enter key. When that is pressed, action is taken and second loop exits. Then the first loop starts again. This is supposed to continue until the F12 key is pressed. I can get the first and second loop to repeat like I want, but the F12 key will not exit the script. What am I missing? Script is attached.

Link to comment
Share on other sites

#include <Misc.au3>

While 1
    Sleep(10)
    If _IsPressed("7B") = 1 Then ; Continue to loop the scirpt until F12 is pressed to end the script
        MsgBox(0,"test",0)
        Exit
    Else
        ;While 1
            ;Sleep(100)
            If _IsPressed("04") = 1 Then ; If Middle Mouse Button is clicked send down key 250 times and apps key - G
                Send("{Down 250}")
                Sleep(50)
                Send("{APPSKEY}")
                Sleep(50)
                Send("G")
            ;    ExitLoop ; Middle Mouse button was clicked so now this loop exits and goes to the Enter Key Loop
            ;Else
            ;    Sleep(50)
            ;    ContinueLoop
            EndIf
        ;WEnd
        ;While 1
            ;Sleep(100)
            If _IsPressed("0D") = 1 Then ;If Enter Key is pressed send Up arrow, hold shift, up arrow 249 times
                Send("{Up}")
                Send("{SHIFTDOWN}")
                Send("{up 249}")
                Send("{SHIFTUP}")
                Sleep(500)
            ;    ExitLoop
            ;    ExitLoop
            ;Else
            ;    Sleep(50)
            ;    ContinueLoop
            EndIf
        ;WEnd
        ;Sleep(50)
        ;ContinueLoop
    EndIf
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

#include <Misc.au3>

While 1
    Sleep(10)
    If _IsPressed("7B") = 1 Then ; Continue to loop the scirpt until F12 is pressed to end the script
        MsgBox(0,"test",0)
        Exit
    Else
        ;While 1
            ;Sleep(100)
            If _IsPressed("04") = 1 Then ; If Middle Mouse Button is clicked send down key 250 times and apps key - G
                Send("{Down 250}")
                Sleep(50)
                Send("{APPSKEY}")
                Sleep(50)
                Send("G")
            ;    ExitLoop ; Middle Mouse button was clicked so now this loop exits and goes to the Enter Key Loop
            ;Else
            ;    Sleep(50)
            ;    ContinueLoop
            EndIf
        ;WEnd
        ;While 1
            ;Sleep(100)
            If _IsPressed("0D") = 1 Then ;If Enter Key is pressed send Up arrow, hold shift, up arrow 249 times
                Send("{Up}")
                Send("{SHIFTDOWN}")
                Send("{up 249}")
                Send("{SHIFTUP}")
                Sleep(500)
            ;    ExitLoop
            ;    ExitLoop
            ;Else
            ;    Sleep(50)
            ;    ContinueLoop
            EndIf
        ;WEnd
        ;Sleep(50)
        ;ContinueLoop
    EndIf
WEnd

8)

Oh so easy, I was making it harder than it needed to be. Works great. Thanks.
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...