Anandyatree Posted September 14, 2010 Posted September 14, 2010 (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: Edited September 14, 2010 by Anandyatree
PsaltyDS Posted September 14, 2010 Posted September 14, 2010 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
Anandyatree Posted September 15, 2010 Author Posted September 15, 2010 (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 September 15, 2010 by Anandyatree
PsaltyDS Posted September 15, 2010 Posted September 15, 2010 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
Anandyatree Posted September 16, 2010 Author Posted September 16, 2010 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
PsaltyDS Posted September 17, 2010 Posted September 17, 2010 From the comments under WinMenuSelectItem() in the help file: Quote 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
Anandyatree Posted September 21, 2010 Author Posted September 21, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now