Jump to content

Identify elements in Menu strip (toolbar)


 Share

Recommended Posts

Hi,

I am automating a window that have a menubar/toolbar.

Though the menubar can be recognized with the help of 'Window info', there is no way I see to recognize elements/menus in that menubar.

Is there any way to list it out and say double click one of the menu to invoke some function?

Menu looks like this:

post-60077-1284465143081_thumb.jpg

Edited by Anandyatree
Link to comment
Share on other sites

Start out with WinMenuSelectItem(). See help file.

If you want to get more advanced with it, see the _GuiCtrlMenu_* UDF functions. Again, see help file.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I tried this function as:

$Success = WinMenuSelectItem ( "Administrator", "", "File")

$iIndex = _GUICtrlMenu_FindItem (0x000111CC, "Help")

For both statements, I am getting back failure value (o and -1). The main window is reognized by the function. But the menu can not be recognized.

Is this issue with AutoIt tool that it can not recognize some of the woindows etc?

Edited by Anandyatree
Link to comment
Share on other sites

You can't enter a literal handle that way. It is technically possible if you used:

$iIndex = _GUICtrlMenu_FindItem (HWnd(0x000111CC), "Help")
But that is never a good idea because handles change each time the object is recreated.

Get the menu handle with _GUICtrlMenu_GetMenu().

So it would be more like this:

#include <GuiMenu.au3>

$hWin = WinGetHandle("Administrator", "")
$hMenu = _GUICtrlMenu_GetMenu($hWin)
$iFile = _GUICtrlMenu_FindItem($hMenu, "Help")

Note the actual text of the help item might be "&Help", indicating ALT-h was the accelerator key for that item.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

From the comments under WinMenuSelectItem() in the help file:

WinMenuSelectItem will only work on standard menus. Unfortunately, many menus in use today are actually custom written or toolbars "pretending" to be menus. This is true for most Microsoft applications.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

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