February 10, 2020

AutoHotkey: Undocumented Hotkeys for Gui Menus

This is a feature a bit hidden/undocumented in AutoHotkey I have learned from Jack's blog post here:
https://jacksautohotkeyblog.wordpress.com/2019/12/30/use-autohotkey-gui-menu-bar-for-instant-hotkeys/

When appended to the end of a MenuItemName, the tab character (`t) followed by one or more standard Hotkey modifiers (CtrlAlt, or Shift) plus another key “indicates a keyboard shortcut that the user may press instead of selecting the menu item. If the shortcut uses only the standard modifier key names CtrlAlt and Shift, it is automatically registered as a keyboard accelerator for the GUI.”
I use this for example in a simple ListView Gui with checkboxes to be able to select all with Ctrl+A.

Menu, ItemsMenu, Add, Check All`tCtrl+A, SelectAll
Menu, ItemsMenu, Add, Uncheck all`tCtrl+Shift+A, UncheckAll

SelectAll:
LV_Modify(0, "Check")  ; Uncheck all the checkboxes.
return
UncheckAll:
LV_Modify(0, "-Check")  ; Uncheck all the checkboxes.
return

This saves a lot of work-arounding with dynamic hotkeys.

(Thanks to Jack for sharing it)

No comments:

Post a Comment