<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Hello,</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

<br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">There was a question from my colleague, how do I select an element from system tray icon in Windows 7. I came up with the following code:</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

from ldtp import *</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">s=getobjectsize(&#39;pane0&#39;, &#39;btnNotificationChevron&#39;)</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">generatemouseevent(s[0] + s[2]/2, s[1] + s[3]/2, &#39;b1c&#39;)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

wait(2)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">s1=getobjectsize(&#39;paneNotificationOverflow&#39;, &#39;btnMcAffee*&#39;)</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">generatemouseevent(s1[0] + s1[2]/2, s1[1] + s1[3]/2, &#39;b3c&#39;)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

wait(2)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">getobjectlist(&#39;mnuContext&#39;)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

selectmenuitem(&#39;mnuContext&#39;, &#39;mnuVirusScanConsole&#39;)</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

He asked me how do get to identify these objects, when I use <a href="http://uiautomationverify.codeplex.com/">UI Automation Verify</a>, I could not identify the object as the icon in sys tray disappears after I select something in the tool.</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

I explained him this what I did to find the object in a python prompt:</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">First used getojbectlist(&#39;pane0&#39;) to verify whether its the bottom panel and noticed &#39;Start&#39; button was part of the output.</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Tried clicking all the objects one by one in the tray icon to see which one has all the hidden app icons and found &#39;Notification Chevron&#39; button.</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">He asked me why do you use s[0] + s[2] / 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).</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Once the app icons popup do right click on the object, which pops up the menu.</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Next question from him was, how did you found &#39;mnuContext&#39; as the window name ?</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">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 &#39;mnuContext&#39;.</p>

<p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

Now you are all set for selecting the element from sys tray icon.</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium"><br></p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">

Thanks</p><p class="p1" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:Times;text-align:left;font-size:medium">Nagappan</p><div><br></div>-- <br>Linux Desktop (GUI Application) Testing Project - <a href="http://ldtp.freedesktop.org">http://ldtp.freedesktop.org</a><br>

<a href="http://nagappanal.blogspot.com">http://nagappanal.blogspot.com</a><br>