我目前正在让我的 Nintendo Wiimote(实际上有点难过)与我的电脑一起作为鼠标工作。我已经设法让双节棍的摇杆控制实际上在屏幕上上下左右移动鼠标!这太令人兴奋了。现在我被困住了。
当我按A时我想通过python左/右键单击东西,当我去搜索时,它想出的只是tkinter?
所以我的问题是,我应该调用什么来让 python 在桌面上左/右键单击,如果可能的话,也许提供一个片段?
感谢您的帮助!
注意:我想我忘了说这是针对 Linux 的。
最佳答案
您可以使用 PyMouse现在已与 PyUserInput 合并.我是通过 pip 安装的:
apt-get install python-pip
pip install pymouse
在某些情况下,它使用光标,而在其他情况下,它在没有光标的情况下模拟鼠标事件。
from pymouse import PyMouse
m = PyMouse()
m.position() #gets mouse current position coordinates
m.move(x,y)
m.click(x,y) #the third argument "1" represents the mouse button
m.press(x,y) #mouse button press
m.release(x,y) #mouse button release
您还可以指定要使用的鼠标按钮。前左键:
m.click(x,y,1)
请记住,在 Linux 上它需要 Xlib。
关于python - 在 Python 上模拟鼠标点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3545230/