Skip to content Skip to sidebar Skip to footer

How To Get Specific System Tray Icon Using Pywinauto?

For example the Slack icon from the notification area: And how can we get a specific icon in case of 'show hidden' icons option?

Solution 1:

This worked for me,

If your app icon are visible on taskbar

app = Application(backend="uia").connect(path="explorer.exe")
sys_tray = app.window(class_name="Shell_TrayWnd")
sys_tray.child_window(title=<your icon>).click()

In-case application icon which in hidden tray

app = Application(backend="uia").connect(path="explorer.exe")
st = app.window(class_name="Shell_TrayWnd")
t = st.child_window(title="Notification Chevron").wrapper_object()
t.click()

# Handle notify icon  overflow window

list_box = Application(backend="uia").connect(class_name="NotifyIconOverflowWindow")
list_box_win = list_box.window(class_name="NotifyIconOverflowWindow")
list_box_win.wait('visible', timeout=30, retry_interval=3)

# Select required option from drop-down 

ddm = desk.create_window(best_match="DropDownMenu")
desk.wait_for_window_to_appear(ddm, wait_for='ready', timeout=20, retry_interval=2)
ddm.child_window(title=<select option>, control_type="MenuItem").click_input()

Solution 2:

User this code ( Modified sunil-kumar code )

from pywinauto import Application
import time

app = Application(backend="uia").connect(path="explorer.exe")
st = app.window(class_name="Shell_TrayWnd")
t = st.child_window(title="Notification Chevron").wrapper_object()
t.click()

time.sleep(0.25)

list_box = Application(backend="uia").connect(class_name="NotifyIconOverflowWindow")
list_box_win = list_box.window(class_name="NotifyIconOverflowWindow")
list_box_win.wait('visible', timeout=30, retry_interval=3)

list_box_win.child_window(title="APPLICATION NAME").click()

Post a Comment for "How To Get Specific System Tray Icon Using Pywinauto?"