Search code examples
pywinauto

Notification Icon context menu


I am trying click on a menu item in a context menu that is activated by right clicking the taskbar notification icon for the application. I am stumped on how to access the menu. The following code activated the menu but I am not sure how to proceed from there. I am unable to get any information for the popup context menu. Swapy doesn't show any info for the menu.

def anchor_main_window(self, tip="Tooltip Text"):
    self.trace("anchor main window")
    taskbar.RightClickHiddenSystemTrayIcon(tip)

Solution

  • SWAPY supports "win32" backend only while pywinauto 0.6.0+ also supports "uia" backend (MS UI Automation technology). Differences are described in the Getting Started Guide - highly recommended to read.

    If your app is WPF, you must do something like that:

    app = Application(backend="uia").connect(path="your_app.exe")
    print(app.ContextMenu.menu_items(), )
    app.ContextMenu.ApproxMenuItemName.invoke()
    

    So the taskbar icons are system level contols while popup menu is an app specific control inside a target app process.