pyautogui.press чувствителен к регистру или, по крайней мере, в Windows.Так что вам нужно сказать
pyautogui.press('f12')
Вот список ключей .
. Возможно, было бы удобно определить эту заглушку
show_trivial_nags = True #maybe be able to toggle this on the command line
def ci_press(x):
if x != x.lower() and show_trivial_nags:
print("WARNING: press commands should be in lower case.")
pyautogui.press(x.lower())
Тестовый пример, который я использовал, был следующим: Firefox на alt-tab
import pyautogui
pyautogui.hotkey('alt', 'tab')
# Comment out the first, and the search bar still appears. Comment out the second, and it doesn't.
pyautogui.press('F3')
pyautogui.press('f3')
exit()