mhd
mhd

Reputation: 43

pywinauto - access submenu from tray

I am trying to access a submenu from a tray item.

This is how I click on a menu:

import pywinauto
from pywinauto import taskbar
app = pywinauto.application.Application()
taskbar.RightClickSystemTrayIcon('App tray icon', exact=True)
app.PopupMenu.MenuItem("SomeMenuItem").ClickInput()  # Clicks an item from the app's main tray menu

I tried using various functions from the pywinauto menuwrapper docs, but without success. Is it possible that these functions only work for application menus?: https://pywinauto.github.io/docs/code/pywinauto.controls.menuwrapper.html

Here is an example of a submenu type that I want to access:

enter image description here

Upvotes: 0

Views: 1839

Answers (1)

Vasily Ryabov
Vasily Ryabov

Reputation: 9991

You need to connect to the application process before performing any action with it. It seems missed in your code (of course, the output would be very useful to understand what's really happening). Assume the code should look like that:

import pywinauto
from pywinauto import taskbar
app = pywinauto.application.Application()

# start/connect is required before any action
app.connect(path='your.exe')

taskbar.RightClickSystemTrayIcon('App tray icon', exact=True)
app.PopupMenu.MenuItem("SomeMenuItem").ClickInput()
app.PopupMenu.MenuItem("SomeMenuItem->sub-menu item").ClickInput()

Upvotes: 1

Related Questions