当前位置:   article > 正文

python做按键精灵脚本_使用Python实现一个按键精灵 | 蓝士钦

python制作安卓按键精灵

@HANK1998

其实,你这个代码,还有一个问题,鼠标键盘动作回放时,顺序会乱,线程同步问题,做不到鼠标动作和键盘动作交叉执行。,,我能力不太够了,,学的不深,不知道这个问题你解决没???

------------------ 原始邮件 ------------------

发件人: "蓝士钦"notifications@github.com;

发送时间: 2019年8月9日(星期五) 中午11:43

收件人: "lanshiqin/lanshiqin-blog"lanshiqin-blog@noreply.github.com;

抄送: "常宏朝"595777097@qq.com; "Mention"mention@noreply.github.com;

主题: Re: [lanshiqin/lanshiqin-blog] 使用Python实现一个按键精灵 | 蓝士钦 (#24)

鼠标动作监听

class MouseActionListener(threading.Thread):

E_sc = False ----->>>这里放一个标识变量

def init(self, file_name='mouse.action'):

##################################

def on_release(key): if key == keyboard.Key.esc: 停止监听 startListenerBtn['text'] = '开始录制' startListenerBtn['state'] = 'normal' MouseActionListener.E_sc = True ---->>>修改刚刚设置的鼠标监听类的标识变量为True keyboardListener.stop()

####################################

鼠标移动事件

def on_move(x, y): if self.E_sc == True: ----->>>监听到鼠标移动时先判断这个标识变量是否为true,为true说明按下了esc键,就进行线程关闭。 mouseListener.stop()

@HANK1998

鼠标动作监听

class MouseActionListener(threading.Thread):

E_sc = False ----->>>这里放一个标识变量

def init(self, file_name='mouse.action'):

##################################

def on_release(key): if key == keyboard.Key.esc: 停止监听 startListenerBtn['text'] = '开始录制' startListenerBtn['state'] = 'normal' MouseActionListener.E_sc = True ---->>>修改刚刚设置的鼠标监听类的标识变量为True keyboardListener.stop()

####################################

鼠标移动事件

def on_move(x, y): if self.E_sc == True: ----->>>监听到鼠标移动时先判断这个标识变量是否为true,为true说明按下了esc键,就进行线程关闭。 mouseListener.stop()

非常感谢你的建议,目前已经按照这个方案修复(^▽^)

You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub, or mute the thread.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/236631
推荐阅读
相关标签
  

闽ICP备14008679号