Select element in system tray (Windows 7) using WDTP
There was a question from my colleague, how do I select an element from system tray icon in Windows 7 using windtp. I came up with the following code:
from ldtp import *
generatemouseevent(s + s/2, s + s/2, 'b1c')
generatemouseevent(s1 + s1/2, s1 + s1/2, 'b3c')
He asked me how do get to identify these objects, when I use UI Automation Verify, I could not identify the object as the icon in sys tray disappears after I select something in the tool.
I explained him this what I did to find the object in a python prompt:
First used getojbectlist('pane0') to verify whether its the bottom panel and noticed 'Start' button was part of the output.
Tried clicking all the objects one by one in the tray icon to see which one has all the hidden app icons and found 'Notification Chevron' button.
He asked me why do you use s + s / 2 ... I explained as: to click on the center of the widget, get the object size (x, y, width, height) then do x + width / 2, y + height / 2 and get the center point on the object and do left click (b1c).
Once the app icons popup do right click on the object, which pops up the menu.
Next question from him was, how did you found 'mnuContext' as the window name ?
I did getwindowlist() before right clicking the object and after that as well, with that I found one additional window name in the list which is 'mnuContext'.
Now you are all set for selecting the element from sys tray icon.