Class library usage, coding and language questions.
-
mollusk
- Posts: 5
- Joined: Wed Dec 13, 2006 9:08 pm
Post
by mollusk » Mon Dec 18, 2006 6:13 am
Hi,
I'm trying to write a test to right-click on an icon in the Windows notification tray and then identify a context menu item by text and left-click on that.
What I have so far looks something like:
Code: Select all
hTaskTray = r.FormFindClassName("Shell_TrayWnd", 1, TRUE, TIMEOUT)
hNotifyTray = r.FormFindChildClassName(hTaskTray, "TrayNotifyWnd", 1)
hNotifyArea = r.FormFindChildClassName(hNotifyTray, "ToolbarWindow32", 1)
# Print the number of notification area icons
print r.ToolStripGetItemCount(hNotifyArea)
# Select Windows volume control icon and select the second item on
# its menu
print r.ToolStripSelectPosition(hNotifyArea, 1, 2) # CRASHES PythonWin
I suspect I'm not using ToolStripSelectPosition() correctly as there is no possibility of specifying right-clicking on the icon. Unfortunately I'm not familiar with .Net so a lot of the terminology itself is new to me (things like forms, controls, elements, etc...).
Cheers.
-
webops
- Site Admin

- Posts: 350
- Joined: Wed Jul 05, 2006 7:44 pm
Post
by webops » Mon Dec 18, 2006 11:34 pm
Please try this sample, i used it for the Touch Pad, but it should also work with the volume control:
Code: Select all
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')
Jenö Herget
Ranorex Team
-
mollusk
- Posts: 5
- Joined: Wed Dec 13, 2006 9:08 pm
Post
by mollusk » Tue Dec 19, 2006 12:53 am
Thanks Jenö! Worked a treat.
Seems I'm going to have to learn a lot more about the Windows API to be competent at this
Just one more question: Is it possible for Ranorex.ElementFindChild() to accept a regular expression of some form as the 'name' parameter? The name of the notification app I'm testing changes depending on the application's state. I'm sure I can find another work around if this is not possible.
Cheers.
-
webops
- Site Admin

- Posts: 350
- Joined: Wed Jul 05, 2006 7:44 pm
Post
by webops » Tue Dec 19, 2006 10:10 pm
mollusk wrote:Is it possible for Ranorex.ElementFindChild() to accept a regular expression?
Some other user also asked us about regular expressions.
We will support this feature in V1.1 or in V1.2, at the beginning of next year.
But i'm sorry, i cannot write you an exact time now.
Jenö Herget
Ranorex Team
-
mollusk
- Posts: 5
- Joined: Wed Dec 13, 2006 9:08 pm
Post
by mollusk » Wed Dec 20, 2006 11:58 pm
admin wrote: We will support this feature in V1.1 or in V1.2, at the beginning of next year.
Sounds great. Thanks again.