Jump to content

In-GUI shortcuts


protoid
 Share

Recommended Posts

Easiest/fastest way to explain:

press file or alt+f

see the shortcuts justified right on the menu items? there should be things like "New Tab_______Ctrl+T"

Can you assign non-global hotkeys to functions or menu items like that natively in autoit?

I searched a bit on the forums and was not able to find much on the topic...

Link to comment
Share on other sites

accelarators!!

; A simple dialog showing accelerators in menus

#include <GUIConstantsEx.au3>

GUICreate("Accelerators", 210, 80)

$hRoot = GUICtrlCreateMenu ("&menu", -1)
   $hMenuItem1 = GUICtrlCreateMenuItem ("&New Tab" & @TAB & "Ctrl+T", $hRoot)
   $hMenuItem2 = GUICtrlCreateMEnuItem ("&Close Tab" & @TAB & "Ctrl+Y", $hRoot)
   $hMenuItem3 = GUICtrlCreateMenuItem ("&Exit" & @TAB & "Alt+F4", $hRoot)

; Set accelerators for Ctrl+t and Ctrl+y
Dim $AccelKeys[2][2]=[["^t", $hMenuItem1], ["^y", $hMenuItem2]]
GUISetAccelerators($AccelKeys)

GUISetState()  ; display the GUI

Do
    $msg = GUIGetMsg()
    Switch $msg
        Case $hMenuItem1
            MsgBox(0, "You clicked on", "Menu Item 1")
        Case $hMenuItem2
            MsgBox(0, "You clicked on", "Menu Item 2")
    EndSwitch
Until $msg = $GUI_EVENT_CLOSE Or $msg = $hMenuItem3

Mat

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...