4

I am trying to find and click a hidden icon on the taskbar (shown by clicking the white triangle) in windows 7, using python. I've been trying to use pywinauto for this, but it doesn't seem to have the functionality to find and click one of these hidden icons. Even the taskbar module in pywinauto doesn't work (possibly due to being outdated). How can I do this?

The application I am trying to access for automation can only be shown by clicking on its hidden icon in the taskbar. By hidden icon, I mean in the notification area.

I've tried pywinauto.taskbar.SystemTrayIcons, but the DrawOutline method shows that this is the wrong area of the taskbar. And using taskbar.SystemTrayIcons.WrapperObject().Button(0) does not work anyway, but gives a GetButtonInfo failed exception.

I've also tried using SWAPY to create python code for finding and clicking the relevant buttons, and although it can click the button (helpfully named 'Button') to show the hidden icons, it does not show how to then click those icons.

Richard
  • 494
  • 7
  • 18
  • taskbar module was designed for Windows XP. Fixing it for Win7 is in nearest plans (April-May). Hidden icons are also in the plan. :) Do you use 64-bit Win7? – Vasily Ryabov Apr 14 '15 at 16:15
  • I'm using 64-bit Win7. If I can't use the taskbar module, are there any other technologies that will do the job? Literally the only way to open the app I'm trying to automate, is to click it's icon in the tray notification area. – Richard Apr 14 '15 at 16:26
  • In any case explorer.exe is 64-bit, so you're not able to connect to it using 32-bit Python+pywinauto. – Vasily Ryabov Apr 15 '15 at 14:15

1 Answers1

3

Install latest version of pywinauto on 64-bit Python (2.7 or 3.4, it doesn't matter) and run the following code:

from pywinauto import taskbar
taskbar.TaskBar.Button.click_input()
popup_dlg = taskbar.explorer_app.window(class_name='NotifyIconOverflowWindow')
popup_toolbar = popup_dlg.Overflow_Notification_Area
print(popup_toolbar.texts()[1:])

Further you can press interested button based on retrieved texts:

popup_toolbar.button('your program name').click_input(double=True)

EDIT (2019, January): this code may not work for latest Windows 10 RS1+ because notification icons area was changed significantly, though it should work for Win7 and Win8.1.

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78