Reputation: 43
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:
Upvotes: 0
Views: 1839
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