0% found this document useful (0 votes)
3 views3 pages

Deepseek Python 20250509 b887f

The document describes the implementation of an 'Advanced TriggerBot' using Python's Tkinter for the GUI and other libraries for functionality. The bot allows users to set a trigger key, target color, tolerance, scan radius, and delay for automated clicking based on color detection on the screen. The application runs in a separate thread and provides options to start and stop the bot while displaying its status in the GUI.

Uploaded by

brawlyspike
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Deepseek Python 20250509 b887f

The document describes the implementation of an 'Advanced TriggerBot' using Python's Tkinter for the GUI and other libraries for functionality. The bot allows users to set a trigger key, target color, tolerance, scan radius, and delay for automated clicking based on color detection on the screen. The application runs in a separate thread and provides options to start and stop the bot while displaying its status in the GUI.

Uploaded by

brawlyspike
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import tkinter as tk

from tkinter import ttk, colorchooser


import pyautogui
import keyboard
import numpy as np
from PIL import ImageGrab
import time
import threading

class AdvancedTriggerBot:
def __init__(self, root):
self.root = root
self.root.title("Advanced TriggerBot")
self.root.geometry("450x400")

# Переменные настроек
self.is_running = False
self.trigger_key = tk.StringVar(value="shift")
self.target_color = (255, 0, 255) # Фиолетовый по умолчанию
self.tolerance = tk.IntVar(value=30)
self.scan_radius = tk.IntVar(value=5)
self.delay = tk.DoubleVar(value=0.05)
self.hotkey_enabled = tk.BooleanVar(value=True)

# Создание интерфейса
self.create_gui()

# Поток для работы бота


self.bot_thread = None

def create_gui(self):
main_frame = ttk.Frame(self.root, padding=10)
main_frame.pack(fill=tk.BOTH, expand=True)

# Блок настроек цвета


color_frame = ttk.LabelFrame(main_frame, text="Настройки цвета",
padding=10)
color_frame.pack(fill=tk.X, pady=5)

self.color_preview = tk.Canvas(color_frame, width=30, height=30,


bg="#FF00FF")
self.color_preview.pack(side=tk.LEFT, padx=5)

ttk.Button(color_frame, text="Выбрать цвет",


command=self.choose_color).pack(side=tk.LEFT, padx=5)

# Блок параметров
params_frame = ttk.LabelFrame(main_frame, text="Параметры", padding=10)
params_frame.pack(fill=tk.X, pady=5)

ttk.Label(params_frame, text="Клавиша активации:").grid(row=0, column=0,


sticky="w")
ttk.Entry(params_frame, textvariable=self.trigger_key,
width=10).grid(row=0, column=1, sticky="w")

ttk.Label(params_frame, text="Допуск цвета:").grid(row=1, column=0,


sticky="w")
ttk.Scale(params_frame, from_=0, to=100, variable=self.tolerance,
orient="horizontal").grid(row=1, column=1, sticky="ew")
ttk.Label(params_frame, text="Радиус сканирования:").grid(row=2, column=0,
sticky="w")
ttk.Spinbox(params_frame, from_=1, to=20, textvariable=self.scan_radius,
width=5).grid(row=2, column=1, sticky="w")

ttk.Label(params_frame, text="Задержка выстрела:").grid(row=3, column=0,


sticky="w")
ttk.Spinbox(params_frame, from_=0.01, to=1.0, increment=0.01,
textvariable=self.delay, width=5).grid(row=3, column=1, sticky="w")

ttk.Checkbutton(params_frame, text="Горячая клавиша",


variable=self.hotkey_enabled).grid(row=4, columnspan=2, sticky="w")

# Блок управления
control_frame = ttk.Frame(main_frame)
control_frame.pack(pady=10)

self.start_btn = ttk.Button(control_frame, text="Запустить",


command=self.start_bot)
self.start_btn.pack(side=tk.LEFT, padx=5)

ttk.Button(control_frame, text="Остановить",
command=self.stop_bot).pack(side=tk.LEFT, padx=5)

# Статус
self.status_var = tk.StringVar(value="Готов к работе")
ttk.Label(main_frame, textvariable=self.status_var).pack()

# Информация
ttk.Label(main_frame, text="Удерживайте выбранную клавишу для активации",
font=("Arial", 8)).pack()

def choose_color(self):
color = colorchooser.askcolor(title="Выберите цвет цели")[0]
if color:
self.target_color = tuple(map(int, color))
hex_color = "#{:02x}{:02x}{:02x}".format(*self.target_color)
self.color_preview.config(bg=hex_color)

def start_bot(self):
if not self.is_running:
self.is_running = True
self.status_var.set("Работает - активация: " + self.trigger_key.get())
self.start_btn.config(state=tk.DISABLED)

self.bot_thread = threading.Thread(target=self.bot_loop, daemon=True)


self.bot_thread.start()

def stop_bot(self):
self.is_running = False
self.status_var.set("Остановлен")
self.start_btn.config(state=tk.NORMAL)

def bot_loop(self):
while self.is_running:
if not self.hotkey_enabled.get() or
keyboard.is_pressed(self.trigger_key.get()):
x, y = pyautogui.position()
screen = ImageGrab.grab(bbox=(
x - self.scan_radius.get(),
y - self.scan_radius.get(),
x + self.scan_radius.get(),
y + self.scan_radius.get()
))

pixels = np.array(screen)
for row in pixels:
for pixel in row:
if all(abs(p - t) <= self.tolerance.get() for p, t in
zip(pixel[:3], self.target_color)):
pyautogui.click()
time.sleep(self.delay.get())
break

time.sleep(0.01)

if __name__ == "__main__":
root = tk.Tk()
app = AdvancedTriggerBot(root)
root.mainloop()

You might also like