DelStone Posted February 27, 2012 Share Posted February 27, 2012 Hi I've been racking my brains over this for a number of hours and can't spot anything in the forums to address it - even though it appears to be an obvious point. I'm ok with using esc to close most popup windows in my app, but the main window should close using x or alt-f4 - I've used GUISetOnEvent($GUI_EVENT_CLOSE, "CloseWin") to do this. However pressing esc closes it too - if I disable this (with a simple return in the CloseWin function), then the x and alt-f4 get disabled too. Is there any way of distinguishing which of the three has been pressed/selected in the CloseWin function - so I exit when it is anything other than Esc? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 27, 2012 Moderators Share Posted February 27, 2012 delstone,You can use Opt("GUICloseOnESC", 0) to prevent ESC closing your GUIs, but that is a script-wide block. So you will have to come up with a way to use ESC to close your pop-ups. Fortunately you can use an Accelerator key like this: expandcollapse popup#include <guiconstantsex.au3> #include <windowsconstants.au3> Opt("GUICloseOnESC", 0) $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Press me!", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton _Child() EndSwitch WEnd Func _Child() $hChild_GUI = GUICreate("Child", 300, 300, -1, -1, $WS_POPUP, Default, $hGUI) GUISetBkColor(0xFF0000) $cDummy = GUICtrlCreateDummy() GUISetState() Local $aAccelKeys[1][2] = [["{ESC}", $cDummy]] GUISetAccelerators($aAccelKeys) While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hChild_GUI Switch $aMsg[0] Case $cDummy ExitLoop EndSwitch EndSwitch WEnd GUIDelete($hChild_GUI) EndFuncA suitable solution for you? 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...
wakillon Posted February 27, 2012 Share Posted February 27, 2012 @Melba23 nice example again ! DelStone you can also simply set Hotkeys. expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUICloseOnESC", 0) HotKeySet ( "!{F4}", '_CloseMainWin' ) ; Alt F4 HotKeySet ( "{ESC}", "_CloseChildWin" ) Global $hGUI, $hChild_GUI $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Press me!", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _CloseMainWin ( ) Case $cButton _Child() EndSwitch WEnd Func _Child() $hChild_GUI = GUICreate("Child", 300, 300, -1, -1, -1, Default, $hGUI) GUISetBkColor(0xFF0000) GUISetState() While WinExists ( $hChild_GUI ) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _CloseChildWin ( ) EndFunc Func _CloseMainWin ( ) GUIDelete($hGUI) Exit EndFunc Func _CloseChildWin ( ) If $hChild_GUI Then GUIDelete($hChild_GUI) EndFunc AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 27, 2012 Moderators Share Posted February 27, 2012 wakillon,you can also simply set HotkeysBut remember that HotKeys are set system-wide and so will fire even when those particular GUIs are not active. And they may not be settable at all if another app has already taken those combinations for itself. 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...
wakillon Posted February 27, 2012 Share Posted February 27, 2012 wakillon,But remember that HotKeys are set system-wide and so will fire even when those particular GUIs are not active. And they may not be settable at all if another app has already taken those combinations for itself. M23A WinActive condition can be added but OP didn't precise what he want, and your solution need child gui is active...If you use the same solution for the Main Gui ( Alt+F4) when child Gui is show, you can't close both... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
DelStone Posted February 27, 2012 Author Share Posted February 27, 2012 Melba - excellent solution - simple and straightforward and works a treat! I should have posted this earlier - would have saved a number of hours of headbanging - thank you v much! :-) I had thought about the hotkeys approach Wakillon, but it's a pain to exclude/include all the relevant windows, as I have already had to do it for ctrl-pgup/pgdn for moving through tabs and didn't relish having to use that approach again - Melba's solution is exactly what was needed. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 27, 2012 Moderators Share Posted February 27, 2012 wakillon, If you use the same solution for the Main Gui ( Alt+F4) when child Gui is show, you can't close bothYou can use Alt-F4 to exit the script when the child is active if you add another Accelerator key like this: expandcollapse popup#include <guiconstantsex.au3> #include <windowsconstants.au3> Opt("GUICloseOnESC", 0) $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("Press me!", 10, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton _Child() EndSwitch WEnd Func _Child() $hChild_GUI = GUICreate("Child", 300, 300, -1, -1, $WS_POPUP, Default, $hGUI) GUISetBkColor(0xFF0000) $cDummy_1 = GUICtrlCreateDummy() $cDummy_2 = GUICtrlCreateDummy() GUISetState() Local $aAccelKeys[2][2] = [["{ESC}", $cDummy_1], ["!{F4}", $cDummy_2]] GUISetAccelerators($aAccelKeys) While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hChild_GUI Switch $aMsg[0] Case $cDummy_1 ExitLoop Case $cDummy_2 Exit EndSwitch EndSwitch WEnd GUIDelete($hChild_GUI) EndFunc 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...
DelStone Posted February 27, 2012 Author Share Posted February 27, 2012 However I must say I love your scite hopper program! Having nearly 15000 lines of code, it's an absolute boon to be able to jum directly to the required function - most of which I can't remember the names of any more ! Link to comment Share on other sites More sharing options...
DelStone Posted February 27, 2012 Author Share Posted February 27, 2012 I would only allow alt-f4 exit when all the child windows were closed - and the main app was running. Otherwise, alt-f4 simply closes the child window... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 27, 2012 Moderators Share Posted February 27, 2012 DelStone, In which case you need the first of my scripts in post #2. 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...
DelStone Posted February 27, 2012 Author Share Posted February 27, 2012 Forgot to mention, horizontally and vertically are with 2 l's and not one (as per the spelling in the hopper options) Link to comment Share on other sites More sharing options...
DelStone Posted February 27, 2012 Author Share Posted February 27, 2012 M23 already used it and it works a treat - thank you - really appreciated Link to comment Share on other sites More sharing options...
wakillon Posted February 27, 2012 Share Posted February 27, 2012 wakillon,You can use Alt-F4 to exit the script when the child is active if you add another Accelerator key like this: M23But in this case Alt+F4 doesn't work if there is no child window ! However I must say I love your scite hopper program! Having nearly 15000 lines of code, it's an absolute boon to be able to jum directly to the required function - most of which I can't remember the names of any more !Thanks a lot ! Is it the last version ?Forgot to mention, horizontally and vertically are with 2 l's and not one (as per the spelling in the hopper options)Sorry for that, will be corrected in the next version ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 27, 2012 Moderators Share Posted February 27, 2012 wakillon,But in this case Alt+F4 doesn't work if there is no child window !Have you tried the script? Alt-F4 closes the main GUI just fine for me whether the child is active or not. The Accelerator keys are only set for the last created GUI (unless you use the winhandle parameter) and so are not set when the child is closed - hence Alt-F4 works as normal for the main GUI. 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...
wakillon Posted February 27, 2012 Share Posted February 27, 2012 wakillon,Have you tried the script? Alt-F4 closes the main GUI just fine for me whether the child is active or not. The Accelerator keys are only set for the last created GUI (unless you use the winhandle parameter) and so are not set when the child is closed - hence Alt-F4 works as normal for the main GUI. M23Are you sure ? Try with Alt+F3 AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
DelStone Posted February 27, 2012 Author Share Posted February 27, 2012 Thanks a lot ! Is it the last version ?It's v 1.0.2.1 - looks like the latest versionAside from the minor spelling, there is one minor bug I've noticed - when you run "Includes Helper", it comments out "unused includes" - however I've found that a number of functions and constant in include files I use (my own include files to break the project down a little) are commented out - does your code check any include files that need the standard include files or does it just go by the main program and functions/variables used in that? It would be nice to trim down the includes I've done if possible as I think 30 odd includes may have some that I don't really need... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 27, 2012 Moderators Share Posted February 27, 2012 wakillon,You are correct - you do need the winhandle parameter set. The Help file says "default is the previously used window", not "last created". Sorry. 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...
wakillon Posted February 27, 2012 Share Posted February 27, 2012 It's v 1.0.2.1 - looks like the latest versionAside from the minor spelling, there is one minor bug I've noticed - when you run "Includes Helper", it comments out "unused includes" - however I've found that a number of functions and constant in include files I use (my own include files to break the project down a little) are commented out - does your code check any include files that need the standard include files or does it just go by the main program and functions/variables used in that? It would be nice to trim down the includes I've done if possible as I think 30 odd includes may have some that I don't really need...Well part was created by asdf8 so you should ask on his Topic.I just found handy to associate two usefull utilities in one ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
wakillon Posted February 27, 2012 Share Posted February 27, 2012 wakillon,You are correct - you do need the winhandle parameter set. The Help file says "default is the previously used window", not "last created". Sorry. M23ALT+F4 is a "Windows" Hotkey that's why it worked in your example ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts 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