Question

I'm having troubles using WinMenuSelectItem to select a menu option when I have to go through more than two levels of a menu.

The menu item I'm currently working with has this set up:

  • Menu Level 1
  • (click on item on Menu Level 1 to access) Menu Level 2
  • (hover over item on Menu Level 2 to access) Menu Level 3

I am able to use WinMenuSelectItem to do this operation just fine:

  • Menu Level 1
  • (click on item on Menu Level 1 to access) Menu Level 2
  • select item on Menu Level 2

I am unable to use WinMenuSelectItem to perform the following operation:

  • Menu Level 1
  • (click on item on Menu Level 1 to access) Menu Level 2
  • (hover over item on Menu Level 2 to access) Menu Level 3
  • select item on Menu Level 3

EDIT:

I've found the solution. The problem was that the text of the menu I was trying to use in WinMenuSelectItem was not correct. When you look at what the menu says in the program (eg. "Open File"), that's not necessarily the text of the menu item. In my case, the text was something like "Open&&File".

In order to figure out what the text of the menu item is, you can do two things:

a) use AutoitMacroGenerator (not AU3Recorder) to record the actions you want to replicate, and investigate the code. Particularly, see what it uses for WinMenuSelectItem.

b) muck around with the GUICtrlMenu suite of functions (go into AutoIT's help -> Index, type in "GUICtrlMenu" to see the corresponding suite of functions) to navigate through the menus and find their text.

Was it helpful?

Solution

In my case, the text was something like "Open&&File".

It was actually "Open &File". The reason for this is that the menus are supposed to be easily accessible by a keyboard. You can press alt (to open the menu) and then the 'f' key, and it will act as if you had pressed 'Open File'.

The ampersand before the character here indicates the preferred shortcut. This is because it's possible to have multiple menus starting with the same characters. Example:

Open file
Open directory
Exit

In this case, the first two menu items are both given the shortcut 'o' for 'Open'. This is inconvenient for people who use your application a lot and wish to have simple shortcuts to do common operations. To give the menu items different shortcuts, you write them down like this:

Open &file
Open &directory
E&xit

It works the same for every menu item. Even for the top level menus.

Try it on notepad! Alt + F (&File) + x (E&xit).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top