如何使用 PyAutoGUI 检测按键事件? [英] How do I detect a keypress event with PyAutoGUI?

查看:49
本文介绍了如何使用 PyAutoGUI 检测按键事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 PyAutoGUI 检测按键事件?在我的研究中,我无法在这个模型中举例:

How do I use PyAutoGUI to detect a keypress event? In my research, I could not make an example in this model:

import pyautogui

num = 0
if pyautogui.press('b'): # I know the right thing is not to use the press, but, what do I put in place?
    num = 1

推荐答案

在 PyAutoGUI 中无法检测击键.您可能想尝试使用 Pynput 模块:https://pypi.org/project/pynput/

Detecting keystrokes isn't possible in PyAutoGUI. You might want to try the Pynput module instead: https://pypi.org/project/pynput/

这篇关于如何使用 PyAutoGUI 检测按键事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆