如何在linux上的python 3中检测鼠标点击?

如何在linux上的python 3中检测鼠标点击?,第1张

概述我是 python的新手,我希望能够在整个屏幕上检测鼠标点击事件. This question最接近我想要的,但没有一个答案是非常具有描述性的. 我怎样才能做到这一点? 您可以使用lib PyUserInput处理鼠标输入(来自github的代码示例): from pymouse import PyMouseEventdef fibo(): a = 0 yield a 我是 python的新手,我希望能够在整个屏幕上检测鼠标点击事件.

This question最接近我想要的,但没有一个答案是非常具有描述性的.

我怎样才能做到这一点?

解决方法 您可以使用lib PyUserInput处理鼠标输入(来自github的代码示例):

from pymouse import PyMouseEventdef fibo():    a = 0    yIEld a    b = 1    yIEld b    while True:        a,b = b,a+b        yIEld bclass Clickonacci(PyMouseEvent):    def __init__(self):        PyMouseEvent.__init__(self)        self.fibo = fibo()    def click(self,x,y,button,press):        '''Print Fibonacci numbers when the left click is pressed.'''        if button == 1:            if press:                print(self.fibo.next())        else:  # Exit if any other mouse button used            self.stop()C = Clickonacci()C.run()

否则,你可以使用Xlib lib:Python Xlib catch/send mouseclick

总结

以上是内存溢出为你收集整理的如何在linux上的python 3中检测鼠标点击?全部内容,希望文章能够帮你解决如何在linux上的python 3中检测鼠标点击?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/1025151.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存