Queener Posted April 19, 2013 Posted April 19, 2013 (edited) I see there's a request of help for closing the program because clicking X doesn't take effects. Thread seems old so I didn't want to bump it. Instead I post what might help them here. I've been playing around and it's not easy, but with an Exit button; it worked. Hopefully this will help most users: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> $TESTExit = GUICreate("EXITTest",275,250,-1,-1,-1,-1) $Button = GUICtrlCreateButton("Exit",150,20,100,24,-1,-1) GUISetState(@SW_SHOW,$TESTEXIT) Func TestExit() Exit EndFunc While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Case $Button TestExit() EndSwitch WEnd I know an exit button is not a good practice, but hopefully someone will find it useful. In addition, professional can help out on how to make the X effective. Edited April 19, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Moderators Melba23 Posted April 19, 2013 Moderators Posted April 19, 2013 asianqueen, I see there's a request of help for closing the program because clicking X doesn't take effectsAnd you think that script is going to help? Your script as posted does not close on [X] because you do not tell it to do anything on receipt of the $GUI_EVENT_CLOSE event. If you do tell it what to do then both the [X] and the button work just fine: #include <GUIConstantsEx.au3> $TESTExit = GUICreate("EXITTest", 275, 250) $Button = GUICtrlCreateButton("Exit", 150, 20, 100, 24) GUISetState(@SW_SHOW, $TESTExit) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button Exit EndSwitch WEnd And you can see that there is a lot less of the script as most of the original was completely unnecessary. I do not want to put you off from tryin gto help, but please try to post things which have some value rather then suggesting that the only way to exit a GUI is to use a button rather then the [X]. M23 P.S. If you want to link to the thread in question we can perhaps discuss why the [X] did not work in that case either. 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
Queener Posted April 19, 2013 Author Posted April 19, 2013 (edited) very funny, I tried that earlier and it didn't want to work on me. Copying paste your code works... if you don't mind; I can help link the old thread to this post, but as I say; the thread seems old and do not want to bump. I see my own problem... I placed my Exit after Case $Button to do something else rather than after Event close. Edited April 19, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")
Moderators Melba23 Posted April 19, 2013 Moderators Posted April 19, 2013 asianqueen, I placed my Exit after Case $Button to do something else rather than after Event closeCorrect. You could also do this: While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ContinueCase Case $Button Exit EndSwitch WEnd I quite agree that you should not bump the old thread, but if you copy/paste the URL we can easily take a look and see what the problem was in that case. 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
JohnOne Posted April 19, 2013 Posted April 19, 2013 Or While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button Exit EndSwitch WEnd AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
TheSaint Posted April 26, 2013 Posted April 26, 2013 Each to their own I guess, but I much prefer an EXIT button .... providing it's well placed and large enough. Of course, I also provide the usual 'X' too .... sometimes differentiating what each method does ... on top of exiting - save settings or cleaning up or run something on exit, etc. Generally, I heartily dislike programs that don't provide a decent EXIT button. Aiming for little things all the time has a way of annoying me. You are also unlikely to click the wrong 'X' ... like happens when several windows get overlayed and you are in a hurry. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
Werty Posted April 27, 2013 Posted April 27, 2013 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $TESTExit = GUICreate("EXITTest", 275, 250, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) $AltF4 = GUICtrlCreateLabel("Press ALT+F4 to exit", 10, 210) $ContextMenu = GUICtrlCreateContextMenu() $ContextMenuExit = GUICtrlCreateMenuItem("Exit", $ContextMenu) $FileMenu = GUICtrlCreateMenu("&File") $FileExit = GUICtrlCreateMenuItem("Exit", $FileMenu) $Button = GUICtrlCreateButton("Exit", 150, 20, 100, 24) GUISetState(@SW_SHOW, $TESTExit) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button, $FileExit, $ContextMenuExit Exit EndSwitch WEnd That's 6 ways to exit Some guy's script + some other guy's script = my script!
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