Jump to content

Recommended Posts

Posted (edited)

Hey all.  So I have a question.  I am trying to use "winmenuselectitem" to select a menu item, but I am running into some difficulty actually matching the text of the menu item.  As you all are already abundantly aware, the autoit help file indicates that an underlined character in the text of a menu item should be preceded by a "&."  I don't know if this is a configuration that one can enable somewhere, but I am not seeing any underlined characters in the text of any of the menu list items.  And I know that there have to be some there, as, when I open notepad to run the example provided in the autoit help file, the example would indicate that the "F" in File and "u" in Setup are both underlined, but, as you can see below, these characters are not underlined. 

m1fLSPj.png

Furthermore, as one would expect, running the help file example does perform the intended action.  So, I need one of two things: 1) if someone could inform me as to how I enable whatever view lets me see the underlined characters, or 2) inform me as to how I can go about determining the correct characters that make up the strings of the menu items.  I would greatly appreciate it.

Edited by MattHiggs
Posted
1 minute ago, JLogan3o13 said:

Usually on the top level menu, if you hold the ALT key down, it will display the trigger keys:

image.png.41ed3d10a79a2e3c99b461a5bdf0536e.png

image.png.b7e5637f1bb1df884342a0ff68363ff1.png

 

 

 

Interesting, @JLogan3o13.  Did not know that.  But only the top level menu item?  How do you determine if any non-top level menu item has underlined characters?

Posted (edited)

Example of looping a menu, and looping through a child menu, to get what you need:

#include <GuiMenu.au3>

$hwnd = WinGetHandle("[CLASS:Notepad]")
WinActivate($hwnd)
$hMenu = _GUICtrlMenu_GetMenu($hwnd)
$iFile = _GUICtrlMenu_FindItem($hMenu, "File")
$hFileMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $iFile)
For $i = 0 To _GUICtrlMenu_GetItemCount($hMenu) - 1
    ConsoleWrite(_GUICtrlMenu_GetItemText($hMenu,$i) & " " & @error & @CRLF)
Next

ConsoleWrite($hFileMenu & @CRLF)
For $i = 0 To _GUICtrlMenu_GetItemCount($hFileMenu) - 1
    ConsoleWrite("text=[" & _GUICtrlMenu_GetItemText($hFileMenu,$i, True) & "] " & @error & @CRLF)
Next

&File 0
&Edit 0
F&ormat 0
&View 0
&Help 0
0x000E0869
text=[&New    Ctrl+N] 0
text=[&Open...    Ctrl+O] 0
text=[&Save    Ctrl+S] 0
text=[Save &As...] 0
text=[] 0
text=[Page Set&up...] 0
text=[&Print...    Ctrl+P] 0
text=[] 0

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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
  • Recently Browsing   0 members

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