Jump to content

What is wrong with my "pause" script?


huldu
 Share

Recommended Posts

I cant get this pause script to work, i got no idea what is wrong to be honest. The pause/break key works fine. The problem is the pause button in the program, it starts the "pause" but it never stops it, doesnt matter how many times you click on the button. This pause thing works great outside the GUI, but inside... the pause button just refuse to stop the pause.

#include <GUIConstants.au3>

Dim $Paused, $Clicked, $Executed, $NotPaused

Global $Paused

Opt("GUIOnEventMode",1)

HotKeySet("{PAUSE}", "PauseButton")

$Form1 = GUICreate("Paused", 121, 40, 462, 300)

GUISetOnEvent($GUI_EVENT_CLOSE, "ExitProgram")

$Button1 = GUICtrlCreateButton("Pause", 24, 8, 75, 25)

GUICtrlSetOnEvent(-1, "PauseButton")

GUISetState(@SW_SHOW)

While 1

$NotPaused = $NotPaused +1

ToolTip("" & "Not Paused: " & $NotPaused,0,0)

Sleep(100)

WEnd

Exit

Func PauseButton()

$Clicked = $Clicked + 1

$Paused = NOT $Paused

While $Paused

$Executed = $Executed + 1

ToolTip("" & "The script is paused: " & $Clicked & " Ran: " & $Executed,0,0)

Sleep(100)

WEnd

ToolTip("",0,0)

EndFunc

Func ExitProgram()

Select

Case @GUI_CTRLID = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc

"I'm paper, rock is fine, nerf scissors!!!"

Link to comment
Share on other sites

  • Developers

I cant get this pause script to work, i got no idea what is wrong to be honest. The pause/break key works fine. The problem is the pause button in the program, it starts the "pause" but it never stops it, doesnt matter how many times you click on the button. This pause thing works great outside the GUI, but inside... the pause button just refuse to stop the pause.

The HotKey Pause works fine, but your Pause button doesn't work because after pressing the button the Event is started and never end. so the next click on the button doesn't function.

Here is a version that works:

#include <GUIConstants.au3>

Dim $Paused, $Clicked, $Executed, $NotPaused

opt("GUIOnEventMode", 1)

HotKeySet("{PAUSE}", "PauseButton")

$Form1 = GUICreate("Paused", 121, 40, 462, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitProgram")
$Button1 = GUICtrlCreateButton("Pause", 24, 8, 75, 25)
GUICtrlSetOnEvent(-1, "PauseButton")
GUISetState(@SW_SHOW)
AdlibEnable("adRoutine")
While 1
    $NotPaused = $NotPaused + 1
    ToolTip("" & "Not Paused: " & $NotPaused, 0, 0)
    Sleep(100)
WEnd
Exit

Func PauseButton()
    $Clicked = $Clicked + 1
    $Paused = Not $Paused
EndFunc  ;==>PauseButton

Func ExitProgram()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            Exit
    EndSelect
EndFunc  ;==>ExitProgram

Func adRoutine()
     While $Paused
        $Executed = $Executed + 1
        ToolTip("" & "The script is paused: " & $Clicked & " Ran: " & $Executed, 0, 0)
        Sleep(100)
    WEnd
    ToolTip("", 0, 0)
EndFunc  ;==>PauseButton

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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