Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Press windows key with pyautogui or python

pyautogui has this functions such as pyautogui.press(key), but I can't figure out how to press the windows key, can someone help me in this situation? Thanks

like image 650
Usual_Coder Avatar asked May 14 '26 12:05

Usual_Coder


2 Answers

The string representation of the Windows key is "win":

>>> import pyautogui
>>> pyautogui.press("win")

Alternatively, you could pass the "winleft" and "winright" strings, which press the left and right Windows keys, respectively.

The pyautogui documentation has a list of keyboard strings which can be passed to the press(), keyDown(), and keyUp() functions.

like image 181
Jacob Lee Avatar answered May 16 '26 00:05

Jacob Lee


According to pyautogui source code(take a look at line 123) and Microsoft keyboard map the windows button key name is 'super'.

pyautogui.press('super')

like image 26
Joao Pedro P.P Avatar answered May 16 '26 01:05

Joao Pedro P.P



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!