Christopher Blue Posted December 30, 2004 Share Posted December 30, 2004 (edited) I am looking to start a script, have to throw up a MsgBox that says it's working, and have the script work until the user clicks the "OK" button on the MsgBox. What is the best way to do this? MsgBox doesn't return until the box is gone so I am not sure how to do that. Edited December 30, 2004 by Christopher Blue Link to comment Share on other sites More sharing options...
ezzetabi Posted December 30, 2004 Share Posted December 30, 2004 (edited) I am afraid you have to use 2 scripts. E.g. Script 1 FileWrite(@tempdir & '\going.tmp','') $sCmd = 'script2.au3' $sFolder = 'c:\folder of script 2\' DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", 'Open', _ "string", $sCmd, "string", '', "string", $sFolder, "long", @SW_SHOWNORMAL) MsgBox(0,'Going...','Script 2 is working. Click OK to stop.') FileDelete(@tempdir & '\going.tmp') Script 2 While FileExists(@tempdir & '\going.tmp') ;What you need here. WEnd Edit: Small fix. I forgot the 'line' argument in FileWrite. Edited December 30, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
Christopher Blue Posted December 30, 2004 Author Share Posted December 30, 2004 Thanks ezzetabi, I will look into implementing your solution. Link to comment Share on other sites More sharing options...
trids Posted December 30, 2004 Share Posted December 30, 2004 Ezzetabi is correct .. if you specifically want the trigger to be the clicking of a button on a MsgBox.However .. If you simply want to terminate a script by clicking something when you're ready .. then that facility is already a default feature of AutoIt: simply rightclick the icon in the system tray, and select "exit" from the menu. Note that a rightclick like this also pauses the script, which is why there is another entry on it for you to un-pause it if you decide to let it continue. Hope this helps Link to comment Share on other sites More sharing options...
ezzetabi Posted December 30, 2004 Share Posted December 30, 2004 (edited) Only a point is unclear to me. Do you need to ISTANT STOP when the user click OK or just stop when the while loop ends?In my implementation the 'Script 2' will stop only when the loop finish.If you need a instant stop you have to use something like:Script 2AdlibEnable('_ShouldIContinue') Do ;What you need here. Until 0 Exit Func _ShouldIContinue() If Not FileExists(@tempdir & '\going.tmp') Then Exit;Of couse you may need OnAutoItExit func for 'just-before-leave things...' EndIf EndFuncEdit: Trids is smarter than me we know. His solution is obiously better as instant stop... Edited December 30, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
Christopher Blue Posted December 30, 2004 Author Share Posted December 30, 2004 (edited) Actually, I am going to take this opportunity to learn more about the GUI methods. I just made a rudimentary window with some text that is checked each work loop to see if it was sent a close message. Edited December 30, 2004 by Christopher Blue Link to comment Share on other sites More sharing options...
Christopher Blue Posted December 30, 2004 Author Share Posted December 30, 2004 Ezzetabi is correct .. if you specifically want the trigger to be the clicking of a button on a MsgBox.However .. If you simply want to terminate a script by clicking something when you're ready .. then that facility is already a default feature of AutoIt: simply rightclick the icon in the system tray, and select "exit" from the menu. Note that a rightclick like this also pauses the script, which is why there is another entry on it for you to un-pause it if you decide to let it continue. Hope this helps<{POST_SNAPBACK}>Aye, my first implementation had the script use a MsgBox which the user would "OK" when they wanted the script to start running. They would then stop the script using the method you describe at which point the script would call OnAutoItExit() and in that function I would take care of any other work before exiting. Link to comment Share on other sites More sharing options...
trids Posted December 30, 2004 Share Posted December 30, 2004 [..]Edit: Trids is smarter than me we know. His solution is obiously better as instant stop... <{POST_SNAPBACK}>Not smarter .. I just believe in "less is more". Your watchdog script is very clever, and comes in handy for all sorts of applications 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