Jump to content

How to pause script inside a func


Recommended Posts

right now i have this, what i want to do is when i call for the pause func to pause the script, but because its in a loop it dont think its working, is there anyway to achieve this?

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $start
            Start()
        Case $msg = $stop
            Pause()
        Case $msg = $exit
            Exit
    EndSelect
WEnd

Exit

Func Pause()
    If $Pause = 1 Then
        $Pause = 0
    Elseif $Pause = 0
        $Pause = 1
    EndIf
EndFunc

Func Start()
    While $a < 1
        If $Pause = 1 Then
            Panel()
            BG()
        ;Join()
            Sleep(10000)
        Elseif $Pause = 0 Then
            $a = 2
        EndIf
    WEnd
EndFunc
Link to comment
Share on other sites

  • Moderators

I see you have two other functions as well as what you posted. You'll need to make conditions for the Global $Pause variable in all your functions, checking it periodically to see if it is paused and take an appropriate action then.

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

Hi, first sorry about my poor english.

If you don't want to check if the program is paused in every loop or function, maybe you can use HotKeySet(), when you want to pause your script use Send() with the key that activate the HotKeySet(), like the HotKeySet is global and works in all script you don't have to worry about where is the script for paused it.

I hope it will help you, any doubt you have I'll try to help.

Link to comment
Share on other sites

how would i check for something when its running in a loop? i can't even exit with the exit button when its stuck in the loop. And i want it in a loop to do keep on going until i pause or exit the program.

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