我正在使用PyMouse(Event)检测是否按下鼠标按钮:
from pymouse import PyMouseEvent
class DetectMouseClick(PyMouseEvent):
def __init__(self):
PyMouseEvent.__init__(self)
def click(self, x, y, button, press):
if button == 1:
if press:
print("click")
else:
self.stop()
O = DetectMouseClick()
O.run()
到目前为止,这是有效的,但现在我想循环print("click")
直到鼠标不再按下。。。我试过了:
还有smth。比如:
while press:
print("click")
有人能帮我吗?谢谢!在
我想正如奥利在他的评论中指出的那样,当鼠标按下时,不会有一个连续的点击流,所以你必须循环使用
print
。在同一个线程上运行while
循环可以防止鼠标释放时触发click事件,因此我可以想到的唯一方法是从一个单独的线程print("click")
。在我不是一个Python程序员,但我有一个可以在我的机器上运行的stab(在windows8.1上运行python2.7):
相关问题 更多 >
编程相关推荐