Mac M1 python 连点器脚本

这篇博客分享了一位用户如何为M1 Mac编写一个Python脚本来实现游戏连点器的功能。用户首先升级了pip,然后利用pynput和pykeyboard库创建了一个自动按顺序按键的程序,实现了'1234'的循环按键,通过监听键盘的'l'键切换连点器的开启和关闭。这个脚本为M1用户提供了自定义游戏辅助工具的可能。
摘要由CSDN通过智能技术生成

M1 打游戏没有连点器很不爽,自己写了一个!
M1 自带python3 不过安装依赖pip要升级一下!

#coding=utf-8
#!/usr/bin/python3

from pynput.keyboard import Listener
import time
#亲测有效!
from pykeyboard import PyKeyboard
import threading

isrunning = False
keyb = PyKeyboard()

#按键设置
def running():
    global isrunning
    global keyb
    while isrunning:
        print("isrunning = ",isrunning)
        keyb.press_key('1')
        keyb.release_key('1')
        time.sleep(0.2)
        keyb.press_key('2')
        keyb.release_key('2')
        time.sleep(0.2)
        keyb.press_key('3')
        keyb.release_key('3')
        time.sleep(0.2)
        keyb.press_key('4')
        keyb.release_key('4')
        time.sleep(0.4)

def switch(key):
    # 监听开关
    global isrunning
    if str(key)=="'"+'l'+"'" :
        isrunning = bool(1-isrunning)
        if(isrunning):
            #启动线程
            thread = threading.Thread(target=running,name="runingThread")
            thread.start()


# 监听
while True:
    with Listener(on_press=switch) as listener:
        listener.join()

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值