Jump to content

Creating Infinite Loop - Possible to end it by specific key press (Such as control+s)


 Share

Recommended Posts

Hello,

I have got my script to do just about everything I want it too except one (or maybe more if its coded wrong) thing.

Here is my script:

While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    
    Select
    ;;;;;;;;;;;;;;;;;;;;;;;
    ;;                ;;
    ;;     LinkY's    ;;
    ;;                ;;
    ;;;;;;;;;;;;;;;;;;;;;;;
        
    ;case for "AutoCM"
        
        Case $msg = $Click_For_Auto_CM
        Send("{LWIN}{UP 22}{ENTER}")
        Sleep(500)
        Send("{TAB 17}{DOWN 8}")
        
    EndSelect
WEnd

Here is what I want it to do:

While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
    
    Select
    ;;;;;;;;;;;;;;;;;;;;;;;
    ;;                ;;
    ;;     LinkY's    ;;
    ;;                ;;
    ;;;;;;;;;;;;;;;;;;;;;;;
        
    ;case for "AutoCM"
        
        Case $msg = $Click_For_Auto_CM
        Send("{LWIN}{UP 22}{ENTER}")
        Sleep(500)
        Send("{TAB 17}{DOWN 8}")
             StatusbarGetText ( "Outlook Express - My Emails" [, 1] )
                ;Start Loop HERE
                  If Status Bar Text 1 is 0 messages(s), 0 unread
                  Then Sleep (300000) Check Status Bar Text again.
                  Else Send({TAB}{ENTER}{TAB}{ENTER})
                  Sleep(1500000)
                ;End Loop
    EndSelect
WEnd
Link to comment
Share on other sites

Not exactly sure what you're doing, but I can answer the question in the title of the thread. What I would do is make a Hotkey, and inside that function set a variable to 1 that tells the loop to exitloop. Example:

HotKeySet ("^s", "NoMoreLooping")
Global $StopLoop = 0

While 1
   ; this is your loop
    Sleep (100)
    If $StopLoop = 1 Then
        $StopLoop = 0
        ExitLoop
    EndIf
WEnd

Func NoMoreLooping()
    $StopLoop = 1
EndFunc
Link to comment
Share on other sites

Not exactly sure what you're doing, but I can answer the question in the title of the thread. What I would do is make a Hotkey, and inside that function set a variable to 1 that tells the loop to exitloop. Example:

HotKeySet ("^s", "NoMoreLooping")
Global $StopLoop = 0

While 1
  ; this is your loop
    Sleep (100)
    If $StopLoop = 1 Then
        $StopLoop = 0
        ExitLoop
    EndIf
WEnd

Func NoMoreLooping()
    $StopLoop = 1
EndFunc
So sayeth the Lord. Yep you are right muh friend. You hit the nail on the head when it comes to the topic! I award you 10 Experts Exchange Points!

[quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()

Link to comment
Share on other sites

  • 2 weeks later...

OK, sorry I am not quite sure how to integrate the looping into my script.

Here is the basics of my script:

While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

    Select
    ;;;;;;;;;;;;;;;;;;;;;;;
    ;;                ;;
    ;;     LinkY's    ;;
    ;;                ;;
    ;;;;;;;;;;;;;;;;;;;;;;;

    ;case for "AutoCM"

        Case $msg = $Click_For_Auto_CM
        Send("{LWIN}{UP 22}{ENTER}")
        Sleep(500)
        Send("{TAB 17}{DOWN 8}")
        Sleep(1000)
        $x = StatusbarGetText("Classical-Mail - Outlook Express")
        MsgBox(0, "Classical-Mail status bar says:", $x)

Basically I want it to check what the box says (example, 2 message(s), 2 unread) and if it says anything other then 0 message(s), 0 unread then it will continue looping the script until I press Control+S (which, as greenmachine pointed out, is done with a HotKeySet Function).

Thank you for any help you can provide :o

Link to comment
Share on other sites

  • Moderators

If $Var <> 0 Then ContinueLoop? (this restarts the loop from the beginning)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...