| View previous topic :: View next topic |
| Author |
Message |
cmiller
Joined: 05 Mar 2007 Posts: 7
|
Posted: Mon Mar 05, 2007 8:34 pm Post subject: Navigating task tray icon context menus |
|
Hi Ranorex,
I'm having trouble finding the context menu of our applications' tray icon.
I'm able to get the element of the icon, but the icon has 0 children elements.
I have tried:
Using the Ranorex.ContextMenu class - it doesn't find the context menu of the icon
Right clicking on the icon and using Control.SendKeys - Control.SendKeys sends only to the primary application
Using the task tray as it's own form and using Application.SendKeys
any tips you could provide would be very appreciated
TIA,
cmiller |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Mon Mar 05, 2007 11:11 pm Post subject: |
|
Please read the post:
Trouble accessing Windows notification tray area.
(It's a Python sample in the reply for using the contexmenu of the Touch Pad, but you can do the same in C# with your application' tray icon.)
Code: click into code to enlarge
hTaskTray = Ranorex.FormFindClassName("Shell_TrayWnd", 1, True, 5000)
trayElement = Ranorex.ControlGetElement(hTaskTray)
notifyElement = Ranorex.ElementFindChild(trayElement, Ranorex.ROLE_SYSTEM_CLIENT, "", 'TrayNotifyWnd')
touchButton = Ranorex.ElementFindChild(notifyElement,Ranorex.ROLE_SYSTEM_PUSHBUTTON, 'Touch Pad')
if touchButton == None:
print 'Touch button not found'
return 1
Ranorex.MouseClickElement(touchButton,Ranorex.MOUSE_RIGHT_BUTTON)
Ranorex.Sleep(100)
Ranorex.ContextMenuSelectItemText('&Info')
Please post your C# code here if it works.
Jenö |
|
| Back to top |
|
 |
cmiller
Joined: 05 Mar 2007 Posts: 7
|
Posted: Tue Mar 06, 2007 12:26 am Post subject: |
|
Thank you for the code snippet, I converted it to C# but it is not working.
The ContextMenu.SelectItemText returns error -3.
As an exception the error is "The specified command could not be executed."
Code: click into code to enlarge
Form hTaskTray = Ranorex.Application.FindFormClassName("Shell_TrayWnd", 1 , true, 5000);
Element trayElement = hTaskTray.Element;
Element touchButton = trayElement.FindChild(Role.PushButton, "RanorexSpy");
if (null == touchButton)
{
Logging.WriteToLog("Could not find icon");
return Data.Result.FATAL;
}
Ranorex.Mouse.ClickElement(touchButton, Ranorex.MouseButtonType.RightButton);
Ranorex.Application.Sleep(100);
int error = Ranorex.ContextMenu.SelectItemText("About ...") ; //Returns error -3
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Tue Mar 06, 2007 12:57 am Post subject: |
|
The code works for me, but the menu text has two spaces, between About and ...
Code: click into code to enlarge
int error = Ranorex.ContextMenu.SelectItemText("About ...");
(Don't ask me why, it's a cosmetic error)
Please use a & symbol if your menu text has a shortcut key.
Jenö |
|
| Back to top |
|
 |
cmiller
Joined: 05 Mar 2007 Posts: 7
|
Posted: Tue Mar 06, 2007 2:07 am Post subject: |
|
Thank you for all the help, I'm able to navigate RanorexSpy now, but still having trouble with other icons.
I'm not able to GetItemText, SelectItemText or SelectPosition either of the two options in the Volume icon tray which controls the volume in windows XP.
Code: click into code to enlarge
Form hTaskTray = Ranorex.Application.FindFormClassName("Shell_TrayWnd", 1 , true, 5000);
Element trayElement = hTaskTray.Element;
Element touchButton = trayElement.FindChild(Role.PushButton, "Volume");
if (null == touchButton)
{
Logging.WriteToLog("Could not find icon");
return Data.Result.FATAL;
}
Ranorex.Mouse.ClickElement(touchButton, Ranorex.MouseButtonType.RightButton);
Ranorex.Application.Sleep(1000);
string name = null;
int position = 2;
name = Ranorex.ContextMenu.GetItemText(position);
int error = Ranorex.ContextMenu.SelectPosition(position);
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Tue Mar 06, 2007 11:41 pm Post subject: |
|
We have released a new version V1.1.0 today.
I used this new version yesterday and it worked for both RanorexSpy and VolumeControl. We fixed a bug in the ContextMenu core and i think this version will also work with your application.
Please download, try the new version and inform us about the results.
Jenö |
|
| Back to top |
|
 |
cmiller
Joined: 05 Mar 2007 Posts: 7
|
Posted: Tue Mar 06, 2007 11:51 pm Post subject: |
|
Thanks for all the help, I'll get the new version and give it a try.
I'll let you know the results as well. |
|
| Back to top |
|
 |
cmiller
Joined: 05 Mar 2007 Posts: 7
|
Posted: Wed Mar 07, 2007 7:59 pm Post subject: |
|
New version works like a charm.
Thanks
-cmiller |
|
| Back to top |
|
 |
|