Jump to content

[Solved] Undo function in GUIOnEventMode?

Recommended Posts


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 by qwert

Share this post

Link to post
Share on other sites



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.


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

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:


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

While 1

Func Undo()
        MsgBox($MB_SYSTEMMODAL, "You selected", "Undo")

And, yes, both GUICtrlSetOnEvent and GUISetAccelerators are required for this to work in OnEventMode.

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now