首页 > 解决方案 > 在 pyautogui 中使用功能键的宏

问题描述

我正在尝试获得与 AutoHotKey 应用程序类似的功能,以使用 pyautogui 在 python 脚本中捕获功能键(比如 F1)。但似乎没有什么可以捕获功能键作为输入。我附上了一个示例组合来打开“This_Pc”,只要我按下退出关键字,这个脚本就会一直运行。

import pyautogui x = '' while x != 'exit':
y=input('enter the key') **'Here I would like to capture a function key'**
print(y)
if y != NULL:
        pyautogui.hotkey("win",'e')
elif y == 'exit':
    x = 'exit'

当我按任何功能键作为输入时,无论如何都会触发代码提前谢谢

标签: pythonautomationpyautogui

解决方案


推荐阅读