简体   繁体   English

使用 pyautogui 或 python 按 windows 键

[英]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? pyautogui 有这个功能,如 pyautogui.press(key),但我不知道如何按下 windows 键,在这种情况下有人可以帮我吗? Thanks谢谢

According to pyautogui source code (take a look at line 123) and Microsoft keyboard map the windows button key name is 'super'.根据 pyautogui 源代码(查看第 123 行)和Microsoft键盘 map windows 按钮键名称为“super”。

pyautogui.press('super')

The string representation of the Windows key is "win" : Windows 键的字符串表示形式是"win"

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

Alternatively, you could pass the "winleft" and "winright" strings, which press the left and right Windows keys, respectively.或者,您可以传递"winleft""winright"字符串,它们分别按下左右 Windows 键。

The pyautogui documentation has a list of keyboard strings which can be passed to the press() , keyDown() , and keyUp() functions. pyautogui文档有一个键盘字符串列表,可以传递给press()keyDown()keyUp()函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM