Forum Discussion
Hi Nimith -
I haven't seen menus come up in Object Spy as individual items. The index I explained above is the way we get to the individual items. In your case, index = 0 would give text = CREATE and index = 1 would give text = MOVE.
You can use the full object name (all the way down to text or another property) to select or click or whatever action you need.
It looks like the menu is drawn separately from the menu control.
In which case something like: Sys.Process("XYZ").WinFormsObject("frmMainMDI").WinFormsObject("MdiClient", "").WinFormsObject ("frmDisplay").MainMenu.Click("MenuName|ANNOTATIONS|CREATE");
would not work.
One method to work around this might be to click the menu item first, then use text recognition or coordinates to click the text on the popup dialogue/menu. (Text Recognition)
//JScript , example only, untested
Sys.Process("XYZ").WinFormsObject("frmMainMDI").WinFormsObject("MdiClient", "").WinFormsObject("frmDisplay").MainMenu.Click("YourmenuItemhere");
Sys.Process("XYZ").Window("#32768", "", 2).Click(5,50); //clicks first item in list
Sys.Process("XYZ").Window("#32768", "", 1).Click(5,50); //clicks first item in list
- Ryan_Moran11 years agoValued Contributor
Also keep in mind that the index of the #32768 Window may change during run time as the windows are created when they fly out. The index given in the example may or may not work during run time. If not try reversing like so:
//JScript , example only, untested Sys.Process("XYZ").WinFormsObject("frmMainMDI").WinFormsObject("MdiClient", "").WinFormsObject("frmDisplay").MainMenu.Click("YourmenuItemhere"); Sys.Process("XYZ").Window("#32768", "", 1).Click(5,50); //first menu Sys.Process("XYZ").Window("#32768", "", 2).Click(5,50); //second menu- Nimith11 years agoContributor
Hi Marsha, Ryan,
The only properties which I get when I spy that object is as seen below.
I am not able to use any of them in order to select any option. Any suggestions?
- HKosova11 years ago
Alumni
To improve the menu object identification, try this:
- Go to Tools > Current Project Properties > Object Mapping.
- Expand the Microsoft Controls > WinForms > Menu category.
- Select the Derived Classes check box next to these items:
StripMenuContext > System.Windows.Forms.ContextMenuStrip
StripMenuPanel > System.Windows.Forms.MenuStrip
- Save the project.
Then record the menu selection - it is recorded using item names or coordinates?
- Go to Tools > Current Project Properties > Object Mapping.