Control a hidden menu behind a button with pywinauto

1.1k views Asked by At

I'm very new to pywinauto ans I love it already. But I have a problem:

I want to automate an old software program with pywinauto and can control most of the buttons. But there is a certain button when clicked, there appaers a menu with icons (not the windows style of menu but a custom menu). The button's name is "Toolbar2" so I guess it's not a normal button. With this code I can click the button I want to. When I use "ctrl.Click(), the button doesn't get clicked, I need to use ClickInput(). With the normal buttons I do can use Click().

w_handle = pywinauto.findwindows.find_windows(title=u'P2-NLTlog013', class_name='TfrmDisplayFilteredData')[0]    
window = pwa_app.window_(handle=w_handle)
window.Click()
ctrl = window['ToolBar2']
ctrl.ClickInput()

My question now is: How can I get the names of the items of the hidden menu And click them. I already used this code, but then he gives a 'MatchError'.

window = pwa_app.Window_(best_match='ToolBar2', top_level_only=True).ChildWindow(best_match='PopupMenu').Click() 

window.Click()

I don't know what language the software was written in...

Thanks in advance, Fred

1

There are 1 answers

0
SWAPYAutomation On

You may get the menu object by window.Menu() and then try to access subitem by menu.Items() Useful methods: menu_item.Index(), menu_item.SubMenu()