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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值