Jump to content
Sign in to follow this  
Pauletp

How to align menu shortcuts on right side of GUI menu entries

Recommended Posts

Pauletp

Align shortcuts on the right side of menu entries:

I would like to find a way to automatically align shortcuts on the right side of the menu entry in an Autoit GUI. This is the usual look for many programs. For example, in Firefox if you click on the the File menu you get the following drop down menu (without the broken lines I have put in here just to simulate the format) which has the shortcuts aligned on the right side of the menu entries:

File

New Window-------------Ctrl+N

New Tab-------------------Ctrl+T

Open location------------Ctrl+L

etc

In AutoIt I have a GUI with the lines

$MenuItemSearch = GUICtrlCreateMenu("Search")
$MenuItemSearchTitle = GUICtrlCreateMenuItem("Find title-----------CTRL+F", $MenuItemSearch)
Dim $Form1_1_AccelTable[1][2] = [["^f", $MenuItemSearchTitle]]
GUISetAccelerators($Form1_1_AccelTable)

AutoIt has the information there is a shortcut by the lines

Dim $Form1_1_AccelTable[1][2] = [["^f", $MenuItemSearchTitle]]
GUISetAccelerators($Form1_1_AccelTable)

and you can see that in the line

$MenuItemSearchTitle = GUICtrlCreateMenuItem("Find title-----------CTRL+F", $MenuItemSearch)

I have manually placed the shortcut in the menu with the characters "Find title-----------CTRL+F".

I would like to make some tidy menues. Does anybody have an idea how to automatically align shortcuts on the right side of the menu entries in AutoIt without doing it the manual way?

Many thanks for a tip.

Share this post


Link to post
Share on other sites
ProgAndy

It should work when you use a tab as delimiter

GUICreate("test")

$MenuItemSearch = GUICtrlCreateMenu("Search")
$MenuItemSearchTitle = GUICtrlCreateMenuItem("Find title" & @TAB & "CTRL+F", $MenuItemSearch)
$MenuItemSearchTitle = GUICtrlCreateMenuItem("Find text ...LONG..." & @TAB & "CTRL+G", $MenuItemSearch)
Dim $Form1_1_AccelTable[1][2] = [["^f", $MenuItemSearchTitle]]
GUISetAccelerators($Form1_1_AccelTable)

GUISetState()
While GUIGetMsg()<>-3
WEnd

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
Pauletp

It should work when you use a tab as delimiter

GUICreate("test")

$MenuItemSearch = GUICtrlCreateMenu("Search")
$MenuItemSearchTitle = GUICtrlCreateMenuItem("Find title" & @TAB & "CTRL+F", $MenuItemSearch)
$MenuItemSearchTitle = GUICtrlCreateMenuItem("Find text ...LONG..." & @TAB & "CTRL+G", $MenuItemSearch)
Dim $Form1_1_AccelTable[1][2] = [["^f", $MenuItemSearchTitle]]
GUISetAccelerators($Form1_1_AccelTable)

GUISetState()
While GUIGetMsg()<>-3
WEnd
Well that will certainly do the alignment.

Thanks for the tip.

No one else has reacted so I suppose there is no other obvious way to use the information contained in the accelerator table to automate the shortcut display in the menu.

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.