使用python模拟USB键盘

问题描述 投票:0回答:1

我很清楚我可以与Python结合使用的不同自动化库(或者甚至作为一个单独的程序/实体一起使用) - 这不是我需要的......

这就是我想要完成的事情......

{COMP1}  -------->  {COMP2}

(1) --> = COMP1 USB port[01] is connected to COMP2 USB port[01]
    (it could be any port, I'm just using [01] as an example)
(2) COMP1 USB port[01] "looks-like" a Generic USB keyboard
    (I'll maybe need to spoof HID values so COMP2 treats it as a keyboard)
(3) My program would send keystroke signals into COMP2 in such a way that
    COMP2 would treat the input as any other connected keyboard device

我看起来有点像pyusb,但我认为它看起来像是控制连接设备,它不是模拟/模拟设备。如果我有错误,请指出正确的文档,以便了解如何通过USB端口发出信号,就像我是键盘一样

我认为这个article开始真正划伤表面,但我不知道接下来要做什么。

也许PySerial可能是另一种方法,但我没有找到任何可靠的例子,其中python发出键盘给USB(它似乎是在侦听)

非常感谢任何帮助或想法!

python usb pyserial hid pyusb
1个回答
1
投票

我最终使用Teensy 3.2设备而不是用python编码这里你可以研究/购买它https://www.pjrc.com/teensy/

基本上,这个arduino-cousin硬件可以伪装/模仿任何USB设备(发送一个特定的HID号码)......一旦连接到另一台计算机(和一点点编码),你可以编程方式发送一系列击键/命令到目标计算机 - 这很容易(第一次确实焊接感觉有点疯狂科学家)但它也很有趣。

我会在github上发布代码示例,如果有人好奇或将来回应这个帖子。

© www.soinside.com 2019 - 2024. All rights reserved.