Dephy Posted February 20, 2010 Posted February 20, 2010 (edited) I'm having a bit of trouble with a script I'm working on, I'm using a function to create a GUI and for some reason it won't close (by the X on title bar, by Alt+F4, by the task bar, or by right-clicking on the window). The only way I can get the GUI to close is by closing the script. I want to know if there is something I can do to fix this. Func _AGUI() GuiCreate("TITLE", 273, 475) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) GuiCtrlCreatePic("pic.jpg",0,0, 273,475) GuiSetState() EndFunc Edited February 20, 2010 by Dephy
Fire Posted February 20, 2010 Posted February 20, 2010 DephyIs it your complete script or this is a only snippet from it?I need for complete script for understand what`s going on your script. [size="5"] [/size]
Newbi3 Posted February 20, 2010 Posted February 20, 2010 Just like Sh3llC043r said, we need to know if this is complete. I think you need this piece, right before the EndFunc command <code> $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect </code> I'm not sure this will completly fix it though
Dephy Posted February 21, 2010 Author Posted February 21, 2010 (edited) The original code what only a bit of the original, but that is the entire code that has to do with the GUI. The GUI is part of a function which is called by a hot key.Just like Sh3llC043r said, we need to know if this is complete. I think you need this piece, right before the EndFunc command<code>$msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect</code>I'm not sure this will completly fix it though I just tried the code, it doesn't work, as I'm not using a loop. The GUI is part of a function and doesn't have a loop. I tried removing the "ExitLoop" and it still won't close. I tried making a loop and it just continually opens the window Edited February 21, 2010 by Dephy
Dephy Posted February 21, 2010 Author Posted February 21, 2010 (edited) Here's most of the code, I can't show it all though. I still can't close the window with this code either. #include <GuiConstantsEx.au3> #include "GUIConstants.au3" While 1 HotKeySet("+a", "_AGUI") WEnd Func _AGUI() GuiCreate("TITLE", 100, 400) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) GuiCtrlCreatePic("pic.jpg",0,0, 100,400) GuiSetState() While 3 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc Edited February 21, 2010 by Dephy
kaotkbliss Posted February 21, 2010 Posted February 21, 2010 (edited) you don't want just exitloop you want either guidelete or guisetstate(@SW_HIDE) then your exitloop 1 more edit. since you guicreate is in the function called with the hotkey, use guidelete("title") @SW_HIDE only hides the gui so you would be creating a new one every time the func is called and never deleting any. Edited February 21, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
jchd Posted February 21, 2010 Posted February 21, 2010 Why did you place the hot key registration _inside_ the main loop? How did you intend to terminate your program? Use Tabs to indent. Try this: #include <GuiConstantsEx.au3> #include "GUIConstants.au3" ; needs only invoked once! HotKeySet("+a", "_AGUI") ; you need to provide a clean way to exit your program (the loop below) ; use Escape to exit HotKeySet("{ESC}", "ExitPgm") While 1 Sleep(100) WEnd Func _AGUI() GuiCreate("TITLE", 400, 100) ; this way is much better (or was it a haïku?) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ;~ GuiCtrlCreatePic("pic.jpg",0,0, 100,400) ; or is it 400x100 ? GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc Func ExitPgm() Exit EndFunc This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Dephy Posted February 21, 2010 Author Posted February 21, 2010 Why did you place the hot key registration _inside_ the main loop? How did you intend to terminate your program? Use Tabs to indent. Try this: #include <GuiConstantsEx.au3> #include "GUIConstants.au3" ; needs only invoked once! HotKeySet("+a", "_AGUI") ; you need to provide a clean way to exit your program (the loop below) ; use Escape to exit HotKeySet("{ESC}", "ExitPgm") While 1 Sleep(100) WEnd Func _AGUI() GuiCreate("TITLE", 400, 100) ; this way is much better (or was it a haïku?) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ;~ GuiCtrlCreatePic("pic.jpg",0,0, 100,400) ; or is it 400x100 ? GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc Func ExitPgm() Exit EndFunc Awesome! It worked, thanks.
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