Need C# Cod to click the Submenu of Window based Application

Class library usage, coding and language questions.
kumarm100
Posts: 7
Joined: Mon Apr 05, 2010 1:04 pm

Need C# Cod to click the Submenu of Window based Application

Post by kumarm100 » Sat Jun 19, 2010 4:04 pm

Hi,
Am trying to automate the Microsoft Dynamics GP 2010. I have a problem in invoking GP, can any one provide me C# code for selecting the submenu of a menubar
Am able to select till "File" Menu item, Ranorex not recognizing the Context Menu object.
Please suggest me how to select the context menu "Open Launch File... Ctrl + o" of "File" Menu Item.
Almost my issue resembles the same as Calculator (Menus -> Menubar -> Menuitems -> ContextMenu)
In My case

"Application" is the Main Menu Bar

/form[@title='Dexterity Runtime']/menubar[@accessiblename='Application']

"File" is the Menuitem of Application

/form[@title='Dexterity Runtime']/menubar[@accessiblename='Application']/menuitem[@accessiblename='File']

"Open Launch File... Ctrl + 0" is the Submenu of File

//contextmenu[@processname='Dynamics']/contextmenu/menuitem[@accessiblename~'^Open\ Launch\ File\.\.\.Ctrl\+']

Please let me know the c# code using (Ranorex) ASAP

Thanks in advance

Kumar

kumarm100
Posts: 7
Joined: Mon Apr 05, 2010 1:04 pm

Re: Need C# Cod to click the Submenu of Window based Application

Post by kumarm100 » Sun Jun 20, 2010 6:31 am

Hi,
My issue almost resemble like Calculator Menu's
Please let me know the code for selecting the context menu.
Regards
Kumar

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Need C# Cod to click the Submenu of Window based Application

Post by Support Team » Mon Jun 21, 2010 10:25 am

Hi,

Here is an example for Windowx XP calculator to select a context menu item.
//Open context menu
Ranorex.MenuItem editMenu = Host.Local.FindSingle("/form[@title='Calculator']/menubar[@accessiblename='Application']/menuitem[@accessiblename='Edit']");                 
editMenu.Click();                                  
//Select your context menu item
Ranorex.MenuItem contextItem = Host.Local.FindSingle("/contextmenu[@processname='calc']/contextmenu/menuitem[@accessiblename='PasteCtrl+V']");                 
contextItem.Select();
You can also use the code generated by the Ranorex Recorder. Just record the actions and let the Recorder generate the code for you, see the corresponding section in the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... rding.html

Regards,
Peter
Ranorex Support Team
.
Image

kumarm100
Posts: 7
Joined: Mon Apr 05, 2010 1:04 pm

Re: Need C# Cod to click the Submenu of Window based Application

Post by kumarm100 » Tue Jun 22, 2010 7:45 am

Hi,

Now am able to get the values of submenus using
Ranorex.Menuitem Filemenu = Host.Local.FindSingle("/form[@title='Dexterity Runtime']/menubar[@accessiblename='Application']/menuitem[@accessiblename='File']");
IList <Ranorex.unknown> uk = Filemenu.Children;

but not able to click the submenu and on execution it clicks the top most browser window.
Any one know how to set focus the submenu and click the respective item.

Thanks in advance

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Need C# Cod to click the Submenu of Window based Application

Post by Support Team » Tue Jun 22, 2010 11:33 am

kumarm100 wrote:but not able to click the submenu and on execution it clicks the top most browser window.
Ranorex can only click on menu items when the menu is open, otherwise it can't calculate the screen location of the menu items. Consequently, you have to click the "File" menu item first to open the menu.
Filemenu.Click();
I suggest you read through the Ranorex Tutorial; it answers most of the questions that new Ranorex users have.

Regards,
Alex
Ranorex Team
.
Image