ags911 Posted December 18, 2013 Author Share Posted December 18, 2013 You could change the pause function for something like this. Make sure you have the includes in your script #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Func _Pause() $Form1 = GUICreate("Form1", 179, 42, @DesktopWidth - 182, 3, $WS_POPUP, BitOR($WS_EX_TRANSPARENT, $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST)) $Button1 = GUICtrlCreateButton("Resume", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("Exit", 96, 8, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 Exit Case $Button1 ExitLoop EndSwitch WEnd EndFunc ;==>_Pause Thanks for the reply John, but I have no idea how to put this into my script. It messes with my other while loop and says Line 48 Endfunc then, Error:"Func" statement has no matching "EndFunc". That line is the end of this function: While $UnPaused ; Loop 2 ToolTip("1") MouseClick("Left", @DesktopWidth *0.926, @DesktopHeight *0.962, 1, 10) ToolTip("2") MouseClick("Left", @DesktopWidth *0.0869, @DesktopHeight *0.809, 1, 20) ToolTip("3") MouseClick("Left", @DesktopWidth *0.625, @DesktopHeight *0.522, 2, 20) ToolTip("4") MouseClick("Left", @DesktopWidth *0.463, @DesktopHeight *0.644, 2, 20) ToolTip("5") MouseClick("Left", @DesktopWidth *0.306, @DesktopHeight *0.607, 1, 20) ToolTip("6") MouseClick("Left", @DesktopWidth *0.503, @DesktopHeight *0.644, 1, 20) Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2013 Share Posted December 18, 2013 (edited) All you do is swap your old _Pause() func for the above one. The func is everything between and including. Func _Pause() ;everything EndFunc Edited December 18, 2013 by JohnOne 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...
ags911 Posted December 18, 2013 Author Share Posted December 18, 2013 All you do is swap your old _Pause() func for the above one. The func is everything between and including. Func _Pause() ;everything EndFunc Thanks man, I added this but now it does not pause but I get that GUI on the top right of my screen but I cannot click on it since the mouse is still running the script. Also, my code has a toggle pause function script that might be broken now so I am not sure what to do but here is that bit of script so far. Func _TogglePause() $Form1 = GUICreate("Form1", 179, 42, @DesktopWidth - 182, 3, $WS_POPUP, BitOR($WS_EX_TRANSPARENT, $WS_EX_WINDOWEDGE, $WS_EX_TOPMOST)) $Button1 = GUICtrlCreateButton("Resume", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("Exit", 96, 8, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 Exit Case $Button1 ExitLoop EndSwitch MouseClick("Left", @DesktopWidth *0.93, @DesktopHeight *0.92, 1, 10) MouseClick("Left", @DesktopWidth *0.084, @DesktopHeight *0.785, 1, 20) MouseClick("Left", @DesktopWidth *0.625, @DesktopHeight *0.523, 2, 20) MouseClick("Left", @DesktopWidth *0.462, @DesktopHeight *0.628, 2, 20) MouseClick("Left", @DesktopWidth *0.3, @DesktopHeight *0.606, 1, 20) MouseClick("Left", @DesktopWidth *0.506, @DesktopHeight *0.628, 1, 20) WEnd EndFunc Link to comment Share on other sites More sharing options...
ags911 Posted December 18, 2013 Author Share Posted December 18, 2013 By the way my script uses the toggle pause to remain in a suspended state till a hotkey is pressed so that the user can decide when to start the script. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $sHeight = @DesktopHeight Global $sWidth = @DesktopWidth Global $UnPaused HotKeySet("+1","_TogglePause") ; Press Shift+1 to start script HotKeySet("+2", "_Terminate") ; Press Shift+2 to terminate script I think by removing that Unpaused state and the while function might have broken the pause function, I'm not sure. Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2013 Share Posted December 18, 2013 Well you need to choose just one, either _TogglePause() or _Pause(). Both wont work together. 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...
Prime03 Posted December 18, 2013 Share Posted December 18, 2013 (edited) I'm going to hijack this thread because I have a similar question. I'm a day or two into writing out a quite intricate and multi function script with tons of gui controls stuff for work, I'm familiar with the fundamentals of scripting, but this is my first stab at using Autoit (and it's been pretty exciting opening my mind to all this) The GUI has about 50 options and settings to chose from that you will chose before you run which will dictate what happens along the main path, and eventually I'd like to add completely different paths with there own settings down the road on new GUI tabs. I think I understand the difference between an OnEvent and a GetMsg GUI, and since I haven't had experience with both, I'm sort of just going forward with an OnEvent since it sounds more correct to me. So if I understand this right, using an OnEvent lets me build my GUI, and then dictate functions at the end of my script that will be associated with buttons on my GUI and in those functions (such as the Main path (Run button), pause button, aswell as some functions for making sure clashing settings aren't selected) I will be reading data from GUI controls. So the thing I'm stuck on as far as pausing and resuming my script revolves around my entire main path being a function, and if I were to hit the pause button, which is another function, would hop out of my mainpath function into the pause function, how would I get back to where I was inside my main path function after the run button was hit again? I've tried to give a lot of maybe unnecessary details to give a picture of what I'm doing and hopefully someone can intervene if my logic is critically wrong or I am just at a mental block. Ok so I just had a revelation as I was about to click on the post button. I was thinking about the progress bar and status box I've made that sends ctrl data along the script for visual feedback of what the scripts doing on the GUI. Well, if I add a global variable, something like $location and along my main path at various points (But honestly it would have to be before every action) I updated that, so if the pause function was called and the script exited my mainpath function, I would have a reference point of where it was when it left. As far as reentering that, I cant think of an efficient way. I could have a Select/case argument at the very start of the function that would perform the step the script left on and the remaining code, but that would be TONS of code if I had 75+ actions (The main path will be around 1000 lines by my guess at this point). Ugh I feel so close to the solution (I hope!). Much appreciation for any advice anyone can offer! Edited December 18, 2013 by Prime03 Link to comment Share on other sites More sharing options...
JohnOne Posted December 18, 2013 Share Posted December 18, 2013 When you pause a script with some sort of blocking code via a hotkey, the last native function will end and will return t o it's very next step when you resume. 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...
Prime03 Posted December 19, 2013 Share Posted December 19, 2013 (edited) When you pause a script with some sort of blocking code via a hotkey, the last native function will end and will return t o it's very next step when you resume. All that frustration ... that's what I get for skimming over the function reference! And wow was I way out there with my thinking earlier lol. Edited December 19, 2013 by Prime03 Link to comment Share on other sites More sharing options...
Prime03 Posted December 19, 2013 Share Posted December 19, 2013 (edited) All that frustration ... that's what I get for skimming over the function reference! And wow was I way out there with my thinking earlier lol. I guess the edit button goes away after a certain amount of time on this forum, so excuse the double post. So now that I've gotten a chance to start trying to apply this I'm still hazy implementing this. I'd like to avoid having to use some sort of blocking code like a MsgBox inside the Pause hotkey, I'd like to be able to just hit the hotkey(and/or button on the GUI, which I don't think would do what I want, hotkey is an exception here) and toggle without anything appearing on the screen. All while still falling back into the previous running function at the location it left at. I'm actually having a pretty hard time with this as I sit here flipping through the references. Using a MsgBox does do what I want to have happen as far as handling re-entering the main function where it left off, I'd just prefer it a cleaner way from a users perspective. They're going to be modifying things on screen, so I think it would be instinctive for them to automatically close it out of habit regardless of what the box says, and it would be a pain to have to drag a window around each time you pause. Edited December 19, 2013 by Prime03 Link to comment Share on other sites More sharing options...
JohnOne Posted December 19, 2013 Share Posted December 19, 2013 The help file has a ready made example for that, See HotkeySet example, just remove the tooltip. 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...
Moderators Melba23 Posted December 19, 2013 Moderators Share Posted December 19, 2013 Prime03, I guess the edit button goes away after a certain amount of time on this forum, so excuse the double postOnce you reach a certain number of posts you get a permanent "Edit" button. 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...
Prime03 Posted December 19, 2013 Share Posted December 19, 2013 The help file has a ready made example for that, See HotkeySet example, just remove the tooltip. Ugh, I feel ridiculous! Thank you for pointing that out. How I've even gotten as far as I have with this project is beyond me! I have a problem with not FULLY reading things. Prime03, Once you reach a certain number of posts you get a permanent "Edit" button. M23 LOL, that's going to be handy, I just hope its not after like 100 or something! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 19, 2013 Moderators Share Posted December 19, 2013 Prime03,I think it is 5, but I am not going to delve into the server to check it. 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