4

I'm currently trying to learn the ins and outs of pywinauto for python 2.7 however I'm having a hard time with a few concepts.

I know how to right click something and get a menu to pop up but after that how do I select or click anything on the popped up menu?

I've tried quite a few ways but nothing seems to be working.

from pywinauto.application import Application


app = Application().Connect(title=u'Untitled - Notepad', 
class_name='Notepad')
notepad = app.Notepad
notepad.RightClickInput()
notepad.MenuSelect('Paste')

This is just my latest attempt. I'm fairly new to programming so the concepts aren't coming easily to me.

Any suggestions on how this could be accomplished would be greatly appreciated.

Elka
  • 63
  • 7

1 Answers1

4

Popup menu is a top-level window for win32 backend. Usually it can be accessed so:

app.UntitledNotepad.right_click_input()
app.PopupMenu.menu_item('Select &All').click_input()

Available texts can be printed using list comprehension:

print [item['text'] for item in app.PopupMenu.menu_items()]
Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
  • Welcome. :) I see you're asking similar questions for other tools. If you were prepared big comparison of the tools, could you please share it with me? To find my gmail just replace `-` with dots in my GitHub nickname. – Vasily Ryabov Jun 02 '17 at 17:16