computergroove Posted March 12, 2015 Share Posted March 12, 2015 I want to start my script paused and when I click the pause button I want it to unpause the script. I would also like the pause button to say unpaused when the script is not paused. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Paused $Paused = $Paused #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 377, 280, 192, 114) $Input1 = GUICtrlCreateInput("10", 24, 40, 49, 21) $Input2 = GUICtrlCreateInput("", 24, 72, 49, 21) $Input3 = GUICtrlCreateInput("", 24, 104, 49, 21) $Input4 = GUICtrlCreateInput("", 24, 136, 49, 21) $Input5 = GUICtrlCreateInput("23", 24, 168, 49, 21) $Input6 = GUICtrlCreateInput("", 240, 40, 49, 21) $Input7 = GUICtrlCreateInput("", 240, 72, 49, 21) $Input8 = GUICtrlCreateInput("", 240, 104, 49, 21) $Input9 = GUICtrlCreateInput("", 240, 136, 49, 21) $Input10 = GUICtrlCreateInput("", 240, 168, 49, 21) $Pause = GUICtrlCreateButton("Pause", 24, 216, 97, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### TogglePause() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Pause TogglePause() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func TogglePause() ;<==========================Here $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Paused', 0, 0) WEnd ToolTip("") EndFunc Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
JohnOne Posted March 12, 2015 Share Posted March 12, 2015 Just call the _Pause() function after create gui AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted March 12, 2015 Share Posted March 12, 2015 expandcollapse popupHotKeySet("{Esc}", "_Exit") $hGui = GUICreate("Gui Pause Button Example", 300, 80) $hPause = GUICtrlCreateButton("Pause", 120, 24, 60) GUISetState() Global $Counter = 0 ; Not needed, just for demonstration purpose. _Pause() While 3 ;Your code starts in this main loop ; Note that the below is just to show script is running, and might look odd due to nature of msg loop. $Counter += 1 If $Counter >= 300 Then ConsoleWrite("Running" & @LF) $Counter = 0 EndIf Switch GUIGetMsg() Case -3 ; $GUI_EVENT_CLOSE Exit Case $hPause ; Pause button ConsoleWrite("!Pause" & @LF) _Pause() EndSwitch WEnd Func _Pause() GUICtrlSetData($hPause, "Resume") While 3 Switch GUIGetMsg() Case -3 ; $GUI_EVENT_CLOSE need to be able to exit while paused. Exit Case $hPause ; Pause button ExitLoop EndSwitch WEnd GUICtrlSetData($hPause, "Pause") ConsoleWrite("+Resume" & @LF) EndFunc ;==>_Pause Func _Exit() Exit EndFunc ;==>_Exit AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
computergroove Posted March 12, 2015 Author Share Posted March 12, 2015 Take a look at the script. I did that. My pause button wont unpause the script. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
computergroove Posted March 12, 2015 Author Share Posted March 12, 2015 expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> HotKeySet("{PAUSE}","TogglePause") Global $Paused $Paused = $Paused #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 377, 280, 192, 114) $Input1 = GUICtrlCreateInput("10", 24, 40, 49, 21) $Input2 = GUICtrlCreateInput("", 24, 72, 49, 21) $Input3 = GUICtrlCreateInput("", 24, 104, 49, 21) $Input4 = GUICtrlCreateInput("", 24, 136, 49, 21) $Input5 = GUICtrlCreateInput("23", 24, 168, 49, 21) $Input6 = GUICtrlCreateInput("", 240, 40, 49, 21) $Input7 = GUICtrlCreateInput("", 240, 72, 49, 21) $Input8 = GUICtrlCreateInput("", 240, 104, 49, 21) $Input9 = GUICtrlCreateInput("", 240, 136, 49, 21) $Input10 = GUICtrlCreateInput("", 240, 168, 49, 21) $Pause = GUICtrlCreateButton("Pause", 24, 216, 97, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Send("{PAUSE}") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Pause Send("{PAUSE}") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Paused', 0, 0) WEnd ToolTip("") EndFunc This worked but I feel like its a shoehorn fit. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 12, 2015 Moderators Share Posted March 12, 2015 computergroove,Try something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> Global $Paused $Paused = $Paused $Form1 = GUICreate("Form1", 377, 280, 192, 114) $Pause = GUICtrlCreateButton("Pause", 24, 216, 97, 25) $cTest = GUICtrlCreateButton("Test", 24, 116, 97, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() ; Run these all the time Switch $nMsg Case $Pause ; Toggle pause $Paused = Not $Paused If $Paused Then ToolTip('Paused', 0, 0) GUICtrlSetData($Pause, "Unpause") Else ToolTip("") GUICtrlSetData($Pause, "Pause") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch ; Only run these if not paused If Not $Paused Then Switch $nMsg Case $cTest MsgBox($MB_SYSTEMMODAL, "Hi", "Running") EndSwitch EndIf WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted March 12, 2015 Share Posted March 12, 2015 Take a look at the script. I did that. My pause button wont unpause the script. No you never. I looked at you script, you never looked at mine. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
computergroove Posted March 12, 2015 Author Share Posted March 12, 2015 computergroove, Try something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> Global $Paused $Paused = $Paused $Form1 = GUICreate("Form1", 377, 280, 192, 114) $Pause = GUICtrlCreateButton("Pause", 24, 216, 97, 25) $cTest = GUICtrlCreateButton("Test", 24, 116, 97, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() ; Run these all the time Switch $nMsg Case $Pause ; Toggle pause $Paused = Not $Paused If $Paused Then ToolTip('Paused', 0, 0) GUICtrlSetData($Pause, "Unpause") Else ToolTip("") GUICtrlSetData($Pause, "Pause") EndIf Case $GUI_EVENT_CLOSE Exit EndSwitch ; Only run these if not paused If Not $Paused Then Switch $nMsg Case $cTest MsgBox($MB_SYSTEMMODAL, "Hi", "Running") EndSwitch EndIf WEnd M23 I tried this but I dont see where the script sleeps when paused. Did I miss something? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2015 Moderators Share Posted March 13, 2015 computergroove,If you want the script itself to sleep, how do you intend the GUI button to reawaken it given that the entire script is inactive? I have offered you a way to keep the button active while nothing else can operate - if that is not what you want them just ignore my suggestion. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now