Sign in to follow this  
Followers 0
Jiggaboo

Pause help

6 posts in this topic

Hey guys, I was wondering if anyone could help me out here.

Basically, I have a GUI button labeled "Pause" and when its clicked, it runs the TogglePause() function:

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

And, when I click the Pause button, it pauses it just fine, but I cannot get it out of the Paused state.

I get no response from any other events.

ALSO!

I have Pause set as a hotkey (to run the TogglePause function) - Would this have anything to do with it?

(I can Pause/UnPause just fine using the hotkey)

Any help would be greatly appreciated!

-Jiggaboo

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I think that when you click the "pause" key, your script stays in the pause state forever because of the loop you have.

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
        $key = ;set what key to check for
        If _IsPressed($key) Then
            ExitLoop ; Exit out of pause
        Wend
    WEnd
    ToolTip("")
EndFunc
Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Thanks for the reply, but I am still having trouble here ...

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        ;Start
        ;(...)
    Case $msg = $Button_2
        ;Pause
        $Paused = NOT $Paused
        While $Paused
            $msg = GUIGetMsg()
            sleep(100)
            ToolTip('Script is "Paused"',0,0)
        WEnd
        if $msg = $Button_2 then
            ;$Paused = NOT $Paused
            ToolTip("")
        EndIf
    Case $msg = $Button_3
        ;Exit
                ;(...)
        Exit
    Case Else
        ;;;
    EndSelect
WEnd
Exit



;Basic Functions
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
        $key = $Button_2;set what key to check for
        ;If  isIsPressed($key) Then
         ;   ExitLoop ; Exit out of pause
        ;EndIf
    WEnd
    ToolTip("")
EndFunc

Sorry for the obvious questions, dont work with Au3 very much ><

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

By $key I meant the hex for the key.

An easier way in my opinion would be to set a HotKey.

HotKeySet("{F1}", "UnPause");sets F1 key that will unpause if pressed

Func Unpause()
    ;leave blank to just unpause
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Yeah, just using a hotkey to Pause/UnPause would definitely be easier, but I would prefer to just have a button on the GUI, so it kinda feels like the Center of the program. You start/pause/exit/etc. all in the GUI.

I guess I am making this more of a problem than it should be.

What I want, is to have a Pause button, and when you click it - the script pauses. When you click it again, it unpauses.

I guess, I honestly dont know how to do this T_T

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yeah, just using a hotkey to Pause/UnPause would definitely be easier, but I would prefer to just have a button on the GUI, so it kinda feels like the Center of the program. You start/pause/exit/etc. all in the GUI.

I guess I am making this more of a problem than it should be.

What I want, is to have a Pause button, and when you click it - the script pauses. When you click it again, it unpauses.

I guess, I honestly dont know how to do this T_T

Oh in that case, you would do something like this:

$stop = GUICtrlCreateButton("Stop (F4)", 40, 120, 120) ; unpause button
GUICtrlSetOnEvent($stop, "Stop") ; tells to go to function if pressed

Func Stop()
    ;leave blank or tell it to do something else
EndFunc
Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

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