Gui Posted May 22, 2010 Share Posted May 22, 2010 Well, I've always known that with AutoIt, in order to close your .exe while running it, it must not be in a loop. Is it possible to have it completely terminate even while in a loop by pressing the X on the top right of the program? Thanks. Link to comment Share on other sites More sharing options...
JohnOne Posted May 22, 2010 Share Posted May 22, 2010 I believe so, if you are using onevent mode. Not 100% on that though. 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...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 (edited) I've always done this : - Made a global Var = 0 ; ( $running = 0 ) - Used : GUIRegisterMsg($WM_COMMAND,'command') - In the Command Function done something like : Func command($hwnd,$msg,$wparam,$lparam) $nNotifyCode = BitShift($wparam, 16) $nID = BitAND($wparam, 0x0000FFFF) If $nID = $start Then If GUICtrlRead($start, 'Start') Then $running = 1 EndIf EndIf If $nID = $stop Then If GUICtrlRead($stop, 'Stop') Then $running = 0 EndIf EndIf EndFunc Edited May 22, 2010 by Gui Link to comment Share on other sites More sharing options...
JohnOne Posted May 22, 2010 Share Posted May 22, 2010 whatever works for you. 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 May 22, 2010 Moderators Share Posted May 22, 2010 Gui, Well, I've always known that with AutoIt, in order to close your .exe while running it, it must not be in a loopThen you obviously do not know AutoIt very well - the only way AutoIt scripts (compiled or not) keep running on your machine is because they ARE in a loop! Two examples to close the script via the [X]: - OnEvent mode: #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() ; Enter an infinite loop While 1 Sleep(10) WEnd Func CLOSEClicked() Exit EndFunc -MessageLoop mode: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUISetState() ; Enter an infinite loop While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd If you remove the loops, the script exits immediately - you need the loops to keep the scripts active. All clear? 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...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 Yeah, I know it quite well. Those methods I know of as well, it's different when you have a loop that's 1000 lines of code and more! Lol, so how do you explain closing while in that eh? You'd have to post If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit every 5 lines? Lol. Link to comment Share on other sites More sharing options...
Kip Posted May 22, 2010 Share Posted May 22, 2010 (edited) Yeah, I know it quite well. Those methods I know of as well, it's different when you have a loop that's 1000 lines of code and more! Lol, so how do you explain closing while in that eh? You'd have to post If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit every 5 lines? Lol. Or everytime you enter a loop that might take a while to complete. Btw: Yeah, I know it quite well.Based on your suggestion, you don't. Or better: you don't seem to understand any basic programming techniques. Edited May 22, 2010 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
JohnOne Posted May 22, 2010 Share Posted May 22, 2010 As far as I recall, onevent mode polls the gui every so many milliseconds no matter what its doing. 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...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 I already use Register Message. OnEvent mode can't work with buttons & $GUI_EVENT_CLOSE, it's odd. I don't like the way it works. I like GUIGetMsg() much better. Link to comment Share on other sites More sharing options...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 Or everytime you enter a loop that might take a while to complete.Btw:Based on your suggestion, you don't. Or better: you don't seem to understand any basic programming techniques.Perhaps I know these techniques, I'm trying to find more efficient ones. Try not to assume. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 22, 2010 Moderators Share Posted May 22, 2010 Gui Those methods I know of as well, it's different when you have a loop that's 1000 lines of code and more!That is "in a function" (or should be!), not "in a loop". Lol, so how do you explain closing while in that eh?Not quite the tone I would adopt if I wanted an answer , but................ If you use OnEvent mode, you can break into the running function: #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() _Long_Function() ; Enter an infinite loop While 1 Sleep(10) WEnd Func _Long_Function() $iBegin = TimerInit() While TimerDiff($iBegin) < 10000 ConsoleWrite(@SEC & @CRLF) Sleep(1000) WEnd EndFunc Func CLOSEClicked() Exit EndFunc If you use MessageLoop mode, you have a big problem. AutoIt will NOT interrupt a running function unless you use a HotKey. So if you have long function without a periodic check of some kind, you cannot break out. The best you can do is run a HotKey and set a flag which you check now and again. M23 P.S. I agree with Kip - and I am not assuming, you are telling us. 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...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 Thanks Melba. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 22, 2010 Moderators Share Posted May 22, 2010 Gui, My pleasure. 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...
Kip Posted May 22, 2010 Share Posted May 22, 2010 Perhaps I know these techniques, I'm trying to find more efficient ones. Try not to assume.If you already know those techniques, then why in gods name are you providing us such a "dumb" example?And why do you literally ask:it's different when you have a loop that's 1000 lines of code and more! Lol, so how do you explain closing while in that eh?if you already know the answer? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 Thanks KIP for all your help. Link to comment Share on other sites More sharing options...
Kip Posted May 22, 2010 Share Posted May 22, 2010 Thanks KIP for all your help. You're welcome. If that was supposed to be sarcastic you probably just blocked out the first part of my first post in this thread. It's "Kip", not "KIP". MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 No, I saw it. I just don't feel like arguing. It's hard to understand what I mean through the internet. Simple, I mean it thanks for all your help. You wasted your time over my thread, so 'Thanks'. Also, sorry. -Kip. -Gui. Link to comment Share on other sites More sharing options...
Kip Posted May 22, 2010 Share Posted May 22, 2010 (edited) Simple, I mean it thanks for all your help. You wasted your time over my thread, so 'Thanks'.Also, sorry. -Kip. -Gui.No hard feelings, I've had a wonderful time Edited May 22, 2010 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Gui Posted May 22, 2010 Author Share Posted May 22, 2010 Lol, this is why I like not arguing. (; Hah, likewise! 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