3

How to get the right click context menu in a Windows application using Python, do not set the position of the cursor and when not focus that Windows application.

Context menu is not the Explorer context menu, it is the Windows application right click context menu.

enter image description here

1
  • app.UntitledNotepad.Edit.Click(button='right') works correctly, but the next command app.PopupMenu.MenuSelect('Paste') gets the Notepad window to the focus. Do you have the same kind of problem? Commented Oct 30, 2015 at 6:21

1 Answer 1

2

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()
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the answer. i didn't get correctly answer, but got a solution or way for this problem. thansk again! : )
It would be interesting to look at the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.