Jump to content

Selecting from sub menu when it contains two similar items

Recommended Posts


I need to select an item from sub menu, but it contains more than one that match.

E.g. supposed my menu is like


Open New File


I need to call "File->Open", so I'm using the command:

WinMenuSelectItem(MyMainWindow, "", "File", "Open")

but it seems that the system is searching the first match for File->Open.* so the first one is File->Open New File

is there a way to force AutoIt to select the exact sub memu I need?

many thanks,


Link to post
Share on other sites

Does the menu command have any of the characters underlined when you open the menu with the ALT key? Because "&Open" is different than "Open &New File" where the "&" is what letter that is underlined when you do this.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to post
Share on other sites

thanks for the reply, but No.

I'm aware of the use of &, and above is just an example:

Main menu is File

Sub menu 1 is Open New File

Sub menu 2 is Open

the question is how to execute File->Open?

I have noticed that there is an option of calling menu command by its location, but it does not work for me.




Link to post
Share on other sites

tomers you should try sending wm_command message with sendmessage() because this is the message you send to the app when you click on those menu items. And everytime you do this you send different message depending what you click.


Or you could try something like controlcommand() and use "SendCommandID", Command ID

Simulates the WM_COMMAND message. Usually used for ToolbarWindow32 controls - use the ToolBar tab of Au3Info to get the Command ID.

You could also use a tool like spy++ to inspect wm_command message for the desired app, then only filter this message, manually click some menu items to see sendmessage params, test, experiment

I didnt use this approach but i would go this route myself

edit: Here is what i get when i click an item and spy for this with spy++ it gives me command id

Posted Image

After you get this id you could try

ControlCommand($appofyours, "", "putcontrolofmenuhere", "SendCommandID", "putcommandidhere eg 35005")

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

    No registered users viewing this page.

  • Create New...