Reputation: 110
I have been recently trying to create a program that makes new folder in python(pyautogui). Here is my code:
import pyautogui;# import the library
pyautogui.press('ctrl');# makes our program to press 'ctrl'
pyautogui.press('n');# makes our program to press 'n'
Apparently what it does instead is pressing ctrl
and n
individually and I want from them to be pressed together. Please help.
Upvotes: 2
Views: 862
Reputation: 8593
According to the docs:
The
press()
function is really just a wrapper for thekeyDown()
andkeyUp()
functions, which simulate pressing a key down and then releasing it up.
As you want to combine several key presses, you need to call keyDown()
and keyUp()
separately:
pyautogui.keyDown('ctrl')
pyautogui.press('n')
pyautogui.keyUp('ctrl')
Upvotes: 1