Reputation: 13
I'm trying to automate some activities, but when I try to use the function hotkey(), an ERROR is detected:
import pyautogui
import pyperclip
# Step 1 - Open the link in a new tab
pyautogui.PAUSE = 1
pyautogui.hotkey('ctrl','t') #open a new tab
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-37-2e2b6412b575> in <module>
6 pyautogui.PAUSE = 1
7
----> 8 pyautogui.hotkey('ctrl','t') #open a new tab
9
TypeError: 'tuple' object is not callable
Does anyone know what is wrong? My teacher used the same code and it worked.
Upvotes: 1
Views: 92
Reputation: 63
The code as written is accurate. There is nothing programatically wrong with the code you provided:
import pyautogui
import pyperclip
pyautogui.PAUSE = 1
pyautogui.hotkey('ctrl','t')
Tested on Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)], PyAutoGUI version 0.9.53.
Troubleshooting steps that may resolve the issue include restarting your kernel or copying into a new .py or .ipnyb file in order to make sure there is nothing else in your script that may be causing this error.
Upvotes: 0
Reputation: 38
You can try:
pyautogui.keyDown('ctrl')
pyautogui.press('t')
pyautogui.keyUp('ctrl')
Upvotes: 1