Here is an example for Notepad:
app.UntitledNotepad.Edit.Click(button='right') # works
app.PopupMenu.MenuSelect('Paste') # seems not working when Notepad is not in focus
# though it works when app.UntitledNotepad.SetFocus() is called before
app.PopupMenu.MenuSelect('Paste')
may not work in such a case because probably WM_COMMAND
can be sent to a focused window only. To get it to work use app.PopupMenu.MenuItem('Paste').ClickInput()
though your app window will get to focus any way.
So finally there are 2 working examples. The first is:
app.UntitledNotepad.SetFocus()
app.UntitledNotepad.Edit.Click(button='right')
app.PopupMenu.MenuSelect('Paste')
The second is:
app.UntitledNotepad.Edit.Click(button='right')
app.PopupMenu.MenuItem('Paste').ClickInput()
app.UntitledNotepad.Edit.Click(button='right')
works correctly, but the next commandapp.PopupMenu.MenuSelect('Paste')
gets the Notepad window to the focus. Do you have the same kind of problem? – Vasily Ryabov