Pyautogui - Need to hold shift and click

Viewed 6983

How does one hold shift and and click with the mouse using pyautogui?

    pyautogui.hotkey('shift', click(1611, 600))

have tried the line above. But it doesn't work

2 Answers

The hotkey() function only works with keys. To shift-click, you need code like this:

import pyautogui
pyautogui.keyDown('shift')
pyautogui.click()
pyautogui.keyUp('shift')

I tried the solution above but for some reason keyDown('shift') didnt work. I used the solution in this thread: keyDown function not working with shift key

pyautogui.keyDown('shiftleft')
pyautogui.keyDown('shiftright')
pyautogui.hotkey('right','right','ctrl','up')
pyautogui.keyUp('shiftleft')
pyautogui.keyUp('shiftright')
Related