Search code examples
python-3.6pyautogui

How to press 2 key parallel by using pyautogui.press()?


I wish to save a file so the keyboard shortcut is 'ctrl'+'s', I try pyautogui.press(['ctrlleft','s']) but it end up it press key simultaneously. So how to make it happen by pressing the keys parrallel so that the save function can achieve.


Solution

  • the hotkey() can be passed several key strings which will be pressed down in order, and then released in reverse order

    pyautogui.hotkey('ctrlleft', 's')
    

    Reference:https://pyautogui.readthedocs.io/en/latest/keyboard.html