Ranorex

Unable to get handler of Context Menu

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
saurabh



Joined: 20 Jul 2007
Posts: 20
Location: India

PostPosted: Fri Aug 03, 2007 9:58 am    Post subject: Unable to get handler of Context Menu
In my application Context Menu is appeared only after right click mouse in current form it’s not the permanent child of current form so I am unable to get the control by FindChild(). I am doing right mouse click by this code. I am working in VS2003 using RanorexNet.dll.

form = Application::FindFormTitle("Alarm manager",Ranorex::SearchMatchMode::MatchExact,true,5000);
Mouse::MoveToControl(form);
Mouse::ButtonDown(MouseButtonType::RightButton);
Mouse::ButtonUp(MouseButtonType::RightButton);

Now my context menu has appeared and there is no control showing by Ranorex Spy. So I can not use FindContolName() as mentioned in VS2005Application. Only Element role and name is there.

To understand my problem better like if you want to automate to get display property window of your desktop through Ranorex then you have to do following steps
1.Mouse right click on your desktop window
2.Now Popup Context Menu will appear
3.Now go to the properties item in Popup Context Menu
4.Click on properties item
5.now Display Properties window has opened.
If you will simultaneously observe the control and element value for each step through Ranorex spy. You will find when you would do right click ,Popup Context Menu will appear with Element Role: window and Name:context.
Now go to the properties Item it will appear with Element Role:MenuItem and Name:Properties.
Now I want to click on properties so it should open Display Properties Window for your Desktop.I have written following in the continuation of above code but it is not working:

Element *context = form->Element->FindChild(Ranorex::Role::Window, "Context");
Element *MenuItem1 = form->Element->FindChild(Ranorex::Role::MenuItem , "Hide Controls");
Mouse::MoveToElement(MenuItem1 );
Mouse::ClickElement(MenuItem1 );

Note:Here “Hide Controls” is one of the Menu item of Popup Context Menu in my application here you can replace this with Menu Item “Properties “

Please provide me correct code ASAP. Its argent.
Thanks in Advance!
_________________
Regards,
Saurabh Shrivastava
GE Global Research
Bangalore India
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Fri Aug 03, 2007 5:05 pm    Post subject:
A context menu is a top-level window and not a child of a Form or Windows application.
You can popup a context menu and select an item as follows:

Code: click into code to enlarge
// Click right mouse button
Mouse.ClickElement(element, MouseButtonType.RightButton);
// Wait 200msec
Application.Sleep(200);
// Select the context menu item with the name "Properties"
Application.PopupMenuSelectItem("Properties", 200);

or
Code: click into code to enlarge
// Click right mouse button
Mouse.ClickElement(element, MouseButtonType.RightButton);
// Wait 200msec
Application.Sleep(200);
// Select the context menu item with the name "Properties"
ContextMenu.SelectItemText("Properties");


A standard context menu has a class name: #32768, if you get the same, then the sample above will work.
If you get an other class name in RanorexSpy, then you should search the context menu with the Application.FindForm function.

Jenö
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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