I am trying to hold down the 'shift' key and press the 'down' key using the pyautogui module. But the pyautogui.keyDown() does not function with shift key.
The py.keyDown('shift') does not seem to work. Only the py.press('down') is working without holding down the shift key.
pyautogui.keyDown('shift')
pyautogui.press('down')
pyautogui.press('down')
pyautogui.keyUp('shift')
The thing i would like to do is- hold down the shift key and use the down arrow keys on the key board to move down selecting all items below with the down arrow.
#You can try this #So, you have to make left and right shifts down at the same time to activate this feature which is wired.
pyautogui.keyDown('shiftleft')
pyautogui.keyDown('shiftright')
pyautogui.hotkey('right','right','ctrl','up')
pyautogui.keyUp('shiftleft')
pyautogui.keyUp('shiftright')
#credits:Tian Chu #https://stackoverflow.com/users/13967128/tian-chu
Previous answer is good. I was able to successfully highlight a whole Excel column using:
pyautogui.hotkey('ctrl','shiftright','shiftleft','down')
I tried using both shiftright and shiftleft on their own and it wouldn't work unless they were both used together.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With