How to access the menu from within notepad?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
enzio901

How to access the menu from within notepad?

24 Jun 2016, 08:24

I starting using AHT recently so apologies if this is a too simple question.

I wan't to access the menu of a notepad document. Normally when you press Alt you can access this.

What I did was

Code: Select all

#IfWinActive  Notepad$ ; ------ only in windows with title ending with "Notepad" This is for tag editing doc

^!q::
{
Send, !
Send, {Enter}


}

#IfWinActive ; ------ end of section restricted to specific windows
When this runs, the cursor jumps to the next line (enter key pressed) but Alt key is not pressed.

What am I doing wrong here? Is there an easy method to access the menu?
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: How to access the menu from within notepad?

24 Jun 2016, 11:56

Try this.

Code: Select all

^q::Send, {Ctrl up}{LAlt}{Enter}

^a::WinMenuSelectItem, A, , File, Save As
Please excuse my spelling I am dyslexic.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: How to access the menu from within notepad?

24 Jun 2016, 12:23

Use keyboard shortcuts when you can.

Code: Select all

SetTitleMatchMode, 2

#IfWinActive  Notepad ; ------ only in windows with title ending with "Notepad" This is for tag editing doc
 
^!q::Send, ^s    ; save using keyboard shortcut.

#IfWinActive ; ------ end of section restricted to specific windows

/*
For menu items without keyboard shortcuts:

PostMessage, 0x111, 4, 0,, Notepad     ; Save As
PostMessage, 0x111, 5, 0,, Notepad     ; Page Setup
PostMessage, 0x111, 7, 0,, Notepad     ; Exit

PostMessage, 0x111, 32, 0,, Notepad    ; Word Wrap
PostMessage, 0x111, 33, 0,, Notepad    ; Font

PostMessage, 0x111, 64, 0,, Notepad    ; View Help
PostMessage, 0x111, 65, 0,, Notepad    ; About Notepad
*/
hunter99
Posts: 129
Joined: 20 Jan 2014, 17:57

Re: How to access the menu from within notepad?

24 Jun 2016, 12:23

enzio901:
The ! shows you the underlined letters used by some menus and these may then show additional items,
may be added to the string, as shown below. You don't need the Enter, but should end with a return.

Code: Select all

^e::
send !e		;the ! shows underlined letters and the e is the one to show the Edit menu.
return

^d::
send !ed		;same as above but added the letter d which will print the date /time.
return

^s::
send !fa		;shows the SaveAs dialog.
return
good luck, hunter99
Edit: Yes as above, use shortcuts when possible. faster and cleaner.
Also, Capn Odin showed in his 2nd example the WinMenuSelectItem command, which is great because many
forget its there. Its very useful in that some times nothing else is available, other then many right arrows,
down arrows, or tabs, etc.
Guest

Re: How to access the menu from within notepad?

24 Jun 2016, 12:44

Capn Odin wrote:Try this.

Code: Select all

^q::Send, {Ctrl up}{LAlt}{Enter}

^a::WinMenuSelectItem, A, , File, Save As

Thanks a lot for this. I used WinMenuSelectItem and it worked perfectly. Can you please tell me what 'A' represents here?

^a::WinMenuSelectItem, A, , File, Save As
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: How to access the menu from within notepad?

24 Jun 2016, 12:54

Guest wrote:
Capn Odin wrote:Try this.

Code: Select all

^q::Send, {Ctrl up}{LAlt}{Enter}

^a::WinMenuSelectItem, A, , File, Save As

Thanks a lot for this. I used WinMenuSelectItem and it worked perfectly. Can you please tell me what 'A' represents here?

^a::WinMenuSelectItem, A, , File, Save As
It means the active window. See WinTitle for details.
Please excuse my spelling I am dyslexic.
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: How to access the menu from within notepad?

24 Jun 2016, 13:03

Capn Odin wrote:
Guest wrote:Can you please tell me what 'A' represents here?
It means the active window.
Which can he found in the docs here:
WinTitle
A window title or other criteria identifying the target window. See WinTitle.
- WinMenuSelectItem
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: How to access the menu from within notepad?

24 Jun 2016, 19:56

enzio901 wrote:Send, !
Since it seems no one else has pointed it out: ! is only meaningful as a modifier. As the docs say, "the following characters are treated as modifiers (these modifiers affect only the very next key)". If there's no "very next key", they affect nothing.

To send the modifier key on its own, you need to use its name (as Capn Odin demonstrated). This is true for all of the modifier keys. It also applies to hotkeys, so !a:: is Alt+A while !:: is the symbol ! (Shift+1 on the US layout).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 282 guests