赞
踩
@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.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。