Sign in to follow this  
Followers 0
Anandyatree

Identify elements in Menu strip (toolbar)

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Your suggestion is helpful, I appreciate !!

But I don't know whats the issue.

$hWin gives me value that does not match with the one given by Window info tool

$hMenu gives me value 0x00000000, that means the menu is not recognizable

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

There you are ! ;)

You have pointed it right. This might be the issue.

Any alternative you may think of?

Any ways, I am very thankful to you. Impressed by the way you are tracking the issue and providing the inputs :)

Share this post


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
Sign in to follow this  
Followers 0