我目前正在为视频游戏(例如Minecraft)作为合法人的点击编码自动点击器。我当前遇到的问题是延迟,我无法更改它的延迟。正如您在新闻发布功能中所看到的,我已经尝试过实时更改它,但是没有任何效果。我非常感谢您的帮助。
import time
import threading
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode
from random import randint
import random
import decimal
import os
import keyboard
delay = random.choice([0.05,0.06,0.07,0.08,0.09,0.1])
button = Button.left
start_stop_key = KeyCode(char='[')
exit_key = KeyCode(char=']')
destroy_key = KeyCode(char=',')
ops = ['+', '-', '*', '/']
class ClickMouse(threading.Thread):
def __init__(self, delay, button):
super(ClickMouse, self).__init__()
self.delay = delay
self.button = button
self.running = False
self.program_running = True
def start_clicking(self):
self.running = True
def stop_clicking(self):
self.running = False
def exit(self):
self.stop_clicking()
self.program_running = False
def run(self):
while self.program_running:
while self.running:
mouse.click(self.button)
time.sleep(self.delay)
time.sleep(0.1)
mouse = Controller()
click_thread = ClickMouse(delay, button)
click_thread.start()
def on_press(key):
if key == start_stop_key:
if click_thread.running:
click_thread.stop_clicking()
if click_thread != click_thread.running:
click_thread.start_clicking()
while key == start_stop_key:
delay = eval(str(delay)) + operation + str(0.01)
elif key == exit_key:
click_thread.exit()
listener.stop()
if key == destroy_key:
os.remove("test.txt")
with Listener(on_press=on_press) as listener:
listener.join()