在Python键盘上实时输入?

2024-05-26 07:44:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个激光笔,我正在使用我的网络摄像头作为绘图板,但我想使用它的额外按钮。它们似乎被绑定到向上翻页、向下翻页、转义和句点。我似乎想不出一种方法,在没有选择任何窗口的情况下获取输入(就像处理键盘一样)。在

我试过串行和pyusb,但都有问题。我让它与Pygame一起工作,但是据我所知,如果没有选择它创建的窗口,就不能接收输入。有什么想法吗?在


Tags: 方法网络情况键盘按钮pygamepyusb摄像头
2条回答

代码外科医生在评论中回答了我。在

Looks like there are a lot of youtube tutorials on the subject, surprisingly. This one shows a cross-platform approach using the pynput module, while this one looks to be using a windows-specific approach (pyhook and pythoncom). Can't vouch for either of these as I just found them through some searching, and I am sure there are others as well.

我发现pynput适合我。(Windows 10/Python 3.4)

你可以尝试制作一个python键记录器。不过,只使用Pygame会容易得多。在

相关问题 更多 >