| View previous topic :: View next topic |
| Author |
Message |
tsmith
Joined: 11 Jul 2007 Posts: 1
|
Posted: Wed Jul 11, 2007 11:31 pm Post subject: Activate menu item without sendkey or mouse movement |
|
.Net 2005, C#, v1.2
I am trying to get a handle on a menu item element I want, and then tell it to DoDefaultAction()
By doing ...Element.GetChild(2).GetChild(1).DoDefaultAction I can open the menu -- this works fine.
Before I open the menu, I can find the subitem I want to select by doing ...Element.GetChild(2).GetChild(1).GetChild(0).GetChild(12) -- but I cannot DoDefaultAction (I assume because menu is not open, this element's state is Unavailable)
After the menu is open, though, the last child element has only one child, not the 19 that it should! If I look inside that child, it has no children at all... where did my menu items go?
If I'm going about this entirely the wrong way, let me know... I need it to be without sendkeys or mouse movement, but activate the menu item.
Thanks! |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Thu Jul 12, 2007 9:37 pm Post subject: |
|
| Quote: |
| I need it to be without sendkeys or mouse movement, but activate the menu item. |
Please try the following:
(This code works with the VS2005Application sample)
Code: click into code to enlarge
Control menuStrip = form.FindControlName("menuStrip1");
Element menuItem = menuStrip.Element.FindChild(Role.MenuItem, "Submenu2");
if (menuItem == null)
return 1;
menuItem.DoDefaultAction();
Application.Sleep(500);
menuItem = menuItem.FindChild(Role.MenuItem, "Submenu2Item3");
if (menuItem == null)
return 1;
menuItem.DoDefaultAction();
Application.Sleep(500);
menuItem = menuItem.FindChild(Role.MenuItem, "Subitem13");
if (menuItem == null)
return 1;
menuItem.DoDefaultAction();
Application.Sleep(500);
menuItem = menuItem.FindChild(Role.MenuItem, "Subitem31");
if (menuItem == null)
return 1;
menuItem.DoDefaultAction();
Jenö
Ranorex Team |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|