0

I'm using python 2.7 in windows and I need to be able to code a right click at a certain xy coordinate. I already have the left click capability using this:

def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)

Any similar/completely different way to code a right click xy dependant function?

2 Answers 2

1

Use win32con.MOUSEEVENTF_RIGHTDOWN and win32con.MOUSEEVENTF_RIGHTUP as the first argument for the respective calls to mouse_event. If this change alone does not help it can be beneficial when inserting a short pause between the mouse down and up with time.sleep(0.05)

Sign up to request clarification or add additional context in comments.

Comments

0

from this link: mouse_even function on MSDN

looks like you can replace

MOUSEEVENTF_LEFTDOWN -> MOUSEEVENTF_RIGHTDOWN

MOUSEEVENTF_LEFTUP -> MOUSEEVENTF_RIGHTUP

Comments

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.