qwert Posted February 23, 2018 Share Posted February 23, 2018 (edited) I haven't been able to locate any explanation of how to detect and process an Undo request (ctrl+z ... not a GUI button) while a GUI is active in GUIOnEventMode. What is a good method to define a function for that specific keyboard input? (All the buttons and "click on label" elements of my GUI work fine, BTW ... so I'm pleased with OnEventMode.) If I can catch the key input, my GUI can determine what, if anything, to do. IOW, the key input shouldn't be associated with any particular control. Thanks in advance for any help. Edited February 27, 2018 by qwert Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 25, 2018 Moderators Share Posted February 25, 2018 qwert, Quote how to detect and process an Undo request (ctrl+z ... not a GUI button) while a GUI is active That sounds like a definition of an Accelerator key - look at GUISetAccelerators in the Help file. 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...
qwert Posted February 27, 2018 Author Share Posted February 27, 2018 Thank you, Melba23. Indeed, Accelerator keys are the answer. (I've never had an occasion to use them.) I fashioned a short demonstration script for using them in OnEventMode, based on the following provision in the help file: Quote If there is no suitable control available in the GUI then a dummy control can be created using GUICtrlCreateDummy. ; ; Test of accelerator key for Undo in OnEventMode ; #include <MsgBoxConstants.au3> Opt("GUIOnEventMode", 1) GUICreate("Custom MsgBox", 225, 80) GUICtrlCreateLabel("Please select a button.", 10, 10) $idUndo = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, "Undo") Local $aAccelKeys[1][2] = [["^z", $idUndo]] ; can define several in this statement GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 sleep(10) WEnd Func Undo() MsgBox($MB_SYSTEMMODAL, "You selected", "Undo") GUIDelete() Exit EndFunc And, yes, both GUICtrlSetOnEvent and GUISetAccelerators are required for this to work in OnEventMode. 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