Sign in to follow this  
Followers 0
d0n

How to pause script inside a func

7 posts in this topic

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

Share this post


Link to post
Share on other sites



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.


[center]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.[/center]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

yea i thought about using hotkeys, but i made a tray menu for this script and hope to have a pause button in it.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

ok, but my loop goes every 10 second, how would i make it check for pauses within that 10 second?

Share this post


Link to post
Share on other sites

nevermind i think i got it now, thanks for the help

Share this post


Link to post
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
Sign in to follow this  
Followers 0