Ahmed M. Adly
Ahmed M. Adly

Reputation: 50

making a hotkey that does a specific command inside a program (autohotkey)

Can I use AutoHotkey to make a hotkey that does a command specific to a certain program???
for example: opening the font settings in notepad

and if I can then how?
because all I seem to find is running a program or hitting some \keyboard buttons but can I do more?

Upvotes: 0

Views: 110

Answers (1)

Spyre
Spyre

Reputation: 2344

You are likely looking for WinMenuSelectItem

From the docs: Invokes a menu item from the menu bar of the specified window.

WinMenuSelectItem, WinTitle, WinText, Menu , SubMenu1, SubMenu2, SubMenu3, SubMenu4, SubMenu5, SubMenu6, ExcludeTitle, ExcludeText


So for the Notepad font example, the Font setting is located in Format>Font of the Notepad menu. So, you could use something like:

#IfWinActive ahk_class Notepad  ;If Notepad is active
^q::WinMenuSelectItem, A, , Format, Font    ;Open Format>Font of actitve window
#If

to trigger the command on Control+q if notepad is the active window.

Upvotes: 1

Related Questions