Trigger Bot
Trigger Bot
class TriggerBot:
def __init__(self, root):
# Main application window
[Link] = root
[Link]("Trigger Bot")
[Link]("640x520")
[Link](False, False)
[Link](bg="#f0f0f0")
# Configuration variables
[Link] = False
[Link] = [Link](value=5) # Radius for detection circle
[Link] = [Link](value=0.001) # Delay between scans
self.color_tolerance = [Link](value=30)
self.click_cooldown = [Link](value=0.05) # Quick click cooldown for
gaming
self.target_color = [Link]([128, 0, 128]) # Default purple in RGB
# Statistics variables
self.clicks_count = 0
self.detections_count = 0
self.last_clicked_time = 0
# Create GUI
self.create_gui()
# Preview thread
self.preview_thread = None
self.should_update_preview = False
def create_gui(self):
"""Create the GUI elements"""
# Style configuration
style = [Link]()
[Link]("TButton", font=("Arial", 10, "bold"))
[Link]("TLabel", font=("Arial", 10))
# Main frame
main_frame = [Link]([Link], padding=10)
main_frame.pack(fill="both", expand=True)
# Color selection
color_frame = [Link](controls_frame)
color_frame.pack(fill="x", pady=5)
# Radius slider
[Link](controls_frame, text="Detection Radius:").pack(anchor="w",
pady=(10, 0))
[Link](controls_frame, from_=1, to=20, variable=[Link],
command=lambda _: self.update_settings()).pack(fill="x")
self.radius_label = [Link](controls_frame, text=f"Current:
{[Link]()} pixels")
self.radius_label.pack(anchor="w")
# Delay slider
[Link](controls_frame, text="Scan Delay (seconds):").pack(anchor="w",
pady=(10, 0))
[Link](controls_frame, from_=0.001, to=0.1, variable=[Link],
command=lambda _: self.update_settings()).pack(fill="x")
self.delay_label = [Link](controls_frame, text=f"Current:
{[Link]():.3f}")
self.delay_label.pack(anchor="w")
# Control buttons
buttons_frame = [Link](controls_frame)
buttons_frame.pack(fill="x", pady=10)
self.start_button = [Link](buttons_frame, text="START BOT",
command=self.toggle_bot)
self.start_button.pack(side="left", padx=5, expand=True, fill="x")
# Preview area
preview_frame = [Link](right_frame, text="Center Screen Preview",
padding=10)
preview_frame.pack(fill="both", expand=True, pady=(0, 5))
# Statistics area
stats_frame = [Link](right_frame, text="Bot Statistics",
padding=10)
stats_frame.pack(fill="both", expand=True, pady=(5, 0))
# Status bar
self.status_var = [Link](value="Status: Ready - Press START BOT or F8
to activate")
status_bar = [Link]([Link], textvariable=self.status_var,
relief="sunken", anchor="w")
status_bar.pack(side="bottom", fill="x")
# Hotkey information
hotkey_frame = [Link](controls_frame)
hotkey_frame.pack(fill="x", pady=(10, 0))
def choose_color(self):
"""Open color chooser dialog and update the target color"""
rgb_color = [Link](title="Choose Target Color",
initialcolor="#800080")
if rgb_color[1]: # If color was chosen (not canceled)
# Update the color preview
self.color_preview.configure(bg=rgb_color[1])
# Update the target color (convert from 0-255 to array)
self.target_color = [Link]([int(rgb_color[0][0]), int(rgb_color[0]
[1]), int(rgb_color[0][2])])
self.update_settings()
def update_settings(self):
"""Update settings labels and scanner parameters"""
# Update labels
self.radius_label.config(text=f"Current: {[Link]()} pixels")
self.delay_label.config(text=f"Current: {[Link]():.3f} seconds")
self.tolerance_label.config(text=f"Current: {self.color_tolerance.get()}")
self.cooldown_label.config(text=f"Current: {self.click_cooldown.get():.3f}
seconds")
def get_scan_box(self):
"""Calculate the scan box coordinates based on the center and radius"""
radius = [Link]()
return (
self.center_x - radius, # Left
self.center_y - radius, # Top
self.center_x + radius + 1, # Right
self.center_y + radius + 1 # Bottom
)
def capture_screen_area(self):
"""Capture the scan area from the screen"""
try:
return [Link](bbox=self.get_scan_box())
except Exception as e:
self.status_var.set(f"Status: Error capturing screen: {e}")
return None
def trigger_click(self):
"""Perform a mouse click at the center of the screen"""
current_time = [Link]()
if current_time - self.last_clicked_time > self.click_cooldown.get():
# Click exactly in the middle of the screen
[Link](self.center_x, self.center_y)
self.clicks_count += 1
self.last_clicked_time = current_time
self.update_stats()
def update_stats(self):
"""Update the statistics display"""
self.stats_text.config(state="normal")
self.stats_text.delete(1.0, [Link])
stats = (
f"Bot Running: {'✓ ACTIVE' if [Link] else '✗ INACTIVE'}\n"
f"Detection Radius: {[Link]()} pixels\n"
f"Target Color: RGB {tuple(self.target_color)}\n"
f"Color Tolerance: {self.color_tolerance.get()}\n"
f"Scan Delay: {[Link]():.3f}s\n"
f"Click Cooldown: {self.click_cooldown.get():.3f}s\n\n"
f"Purple Detections: {self.detections_count}\n"
f"Clicks Triggered: {self.clicks_count}\n"
)
self.stats_text.insert([Link], stats)
self.stats_text.config(state="disabled")
def reset_stats(self):
"""Reset the statistics counters"""
self.clicks_count = 0
self.detections_count = 0
self.update_stats()
self.status_var.set("Status: Statistics reset")
def toggle_bot(self):
"""Toggle the bot on/off"""
[Link] = not [Link]
if [Link]:
self.start_button.config(text="STOP BOT")
self.status_var.set("Status: TRIGGER BOT ACTIVE - Watching for purple")
[Link](target=self.bot_loop, daemon=True).start()
else:
self.start_button.config(text="START BOT")
self.status_var.set("Status: Trigger Bot Stopped")
def start_preview_thread(self):
"""Start the preview update thread"""
self.should_update_preview = True
self.preview_thread = [Link](target=self.update_preview_loop,
daemon=True)
self.preview_thread.start()
def update_preview_loop(self):
"""Continuously update the preview canvas"""
while self.should_update_preview:
try:
# Capture the screen area
img = self.capture_screen_area()
if img:
# Resize the image to fit the canvas
scale_factor = min(250 / [Link], 250 / [Link])
new_size = (int([Link] * scale_factor * 3), int([Link] *
scale_factor * 3))
def update_preview_canvas(self):
"""Update the preview canvas with the latest image (called from main
thread)"""
self.preview_canvas.delete("all")
if hasattr(self, 'preview_img'):
# Center the image in the canvas
x = (250 - self.preview_img.width()) // 2
y = (250 - self.preview_img.height()) // 2
self.preview_canvas.create_image(x, y, anchor="nw",
image=self.preview_img)
# Draw crosshair
self.preview_canvas.create_line(canvas_center_x - 10, canvas_center_y,
canvas_center_x + 10, canvas_center_y,
fill="red", width=1)
self.preview_canvas.create_line(canvas_center_x, canvas_center_y - 10,
canvas_center_x, canvas_center_y + 10,
fill="red", width=1)
def bot_loop(self):
"""Main bot processing loop"""
try:
import keyboard # Import here to avoid issues if not available
while [Link]:
# Check for hotkeys
if keyboard.is_pressed('f8'):
[Link](0, self.toggle_bot)
[Link](0.3) # Debounce
continue
if keyboard.is_pressed('f9'):
[Link](0, self.on_close)
break
except Exception as e:
self.status_var.set(f"Status: Error in bot loop: {e}")
[Link] = False
[Link](0, lambda: self.start_button.config(text="START BOT"))
def on_close(self):
"""Clean up and close the application"""
[Link] = False
self.should_update_preview = False
[Link]()
[Link](0)
if __name__ == "__main__":
try:
# Check for required modules
import keyboard
except ImportError:
print("Error: Required module 'keyboard' not found.")
print("Please install it with: pip install keyboard")
[Link](1)
root = [Link]()
app = TriggerBot(root)
[Link]()
import tkinter as tk
from tkinter import ttk, colorchooser, messagebox, font
import pyautogui
import numpy as np
import time
import threading
import sys
from PIL import ImageGrab, Image, ImageTk
class AdvancedTriggerBot:
def __init__(self, root):
# Main application window
[Link] = root
[Link]("Advanced Trigger Bot")
[Link]("800x650") # Larger GUI
[Link](True, True)
[Link](bg="#1E1E1E") # Dark theme
# Configuration variables
[Link] = False
[Link] = [Link](value=10) # Default larger radius
[Link] = [Link](value=0.0) # Default 0ms delay
self.color_tolerance = [Link](value=40)
self.click_cooldown = [Link](value=0.02) # Quick click cooldown
self.target_color = [Link]([128, 0, 128]) # Default purple in RGB
# Statistics variables
self.clicks_count = 0
self.detections_count = 0
self.last_clicked_time = 0
# Create GUI
self.create_gui()
# Preview thread
self.preview_thread = None
self.should_update_preview = False
def create_styles(self):
"""Create custom styles for widgets"""
# Configure ttk styles
style = [Link]()
style.theme_use('clam') # Use clam theme as base
# Configure colors
[Link](".",
background="#1E1E1E",
foreground="#FFFFFF",
fieldbackground="#333333")
# Button styles
[Link]("TButton",
font=("Segoe UI", 12, "bold"),
padding=8,
background="#444444",
foreground="#FFFFFF")
[Link]("TButton",
background=[('active', '#666666')])
[Link]("[Link]",
background=[('active', '#008800')])
[Link]("[Link]",
background=[('active', '#B22222')])
# Label styles
[Link]("TLabel",
font=("Segoe UI", 10),
background="#1E1E1E",
foreground="#FFFFFF")
# Frame styles
[Link]("TFrame", background="#1E1E1E")
[Link]("TLabelframe", background="#1E1E1E", foreground="#FFFFFF")
[Link]("[Link]", background="#1E1E1E",
foreground="#00BFFF")
# Scale styles
[Link]("TScale",
background="#1E1E1E",
troughcolor="#333333")
# Notebook styles
[Link]("TNotebook", background="#1E1E1E", foreground="#FFFFFF")
[Link]("[Link]",
background="#333333",
foreground="#FFFFFF",
padding=[10, 5])
[Link]("[Link]",
background=[('selected', '#0078D7')],
foreground=[('selected', '#FFFFFF')])
def create_gui(self):
"""Create the GUI elements"""
# Main frame
main_frame = [Link]([Link], padding=10)
main_frame.pack(fill="both", expand=True)
# Create tabs
tab_control = [Link](main_frame)
# Main tab
main_tab = [Link](tab_control)
tab_control.add(main_tab, text="Trigger Settings")
# Advanced tab
advanced_tab = [Link](tab_control)
tab_control.add(advanced_tab, text="Advanced Settings")
tab_control.pack(expand=True, fill="both")
main_right = [Link](main_tab)
main_right.pack(side="right", fill="both", expand=True, padx=(5, 0))
self.delay_label = [Link](delay_frame,
text=f"{int([Link]()*1000)}", width=3)
self.delay_label.pack(side="right")
# Statistics area
stats_frame = [Link](main_right, text="Bot Statistics", padding=10)
stats_frame.pack(fill="both", expand=True, pady=(5, 0))
self.tolerance_label = [Link](tolerance_frame,
text=f"{self.color_tolerance.get()}", width=3)
self.tolerance_label.pack(side="right")
# Click settings
click_settings = [Link](advanced_tab, text="Click Behavior
Settings", padding=10)
click_settings.pack(fill="x", expand=False, pady=10)
# Click cooldown
[Link](click_settings, text="Click Cooldown (ms):", font=("Segoe UI",
12)).pack(anchor="w")
cooldown_frame = [Link](click_settings)
cooldown_frame.pack(fill="x", pady=5)
self.cooldown_label = [Link](cooldown_frame,
text=f"{int(self.click_cooldown.get()*1000)}", width=3)
self.cooldown_label.pack(side="right")
# Burst settings
burst_frame = [Link](click_settings, text="Burst Mode Settings",
padding=10)
burst_frame.pack(fill="x", expand=False, pady=10)
# Burst count
[Link](burst_frame, text="Clicks per Burst:").pack(anchor="w")
burst_count_frame = [Link](burst_frame)
burst_count_frame.pack(fill="x", pady=5)
self.burst_count_label = [Link](burst_count_frame,
text=f"{self.burst_count.get()}", width=2)
self.burst_count_label.pack(side="right")
# Burst interval
[Link](burst_frame, text="Burst Interval (ms):").pack(anchor="w")
burst_interval_frame = [Link](burst_frame)
burst_interval_frame.pack(fill="x", pady=5)
self.burst_interval_label = [Link](burst_interval_frame,
text=f"{int(self.burst_interval.get()*1000)}", width=3)
self.burst_interval_label.pack(side="right")
# Help text
help_frame = [Link](advanced_tab, text="Instructions", padding=10)
help_frame.pack(fill="both", expand=True, pady=10)
help_text = (
"TRIGGER BOT INSTRUCTIONS:\n\n"
"1. Choose your target color (purple recommended)\n"
"2. Adjust the detection radius (larger = more coverage)\n"
"3. Set scan delay (0ms for fastest response)\n"
"4. Choose click mode:\n"
" • Single Click: One click per detection\n"
" • Burst: Multiple rapid clicks per detection\n"
" • Rapid Fire: Continuous clicking while color is detected\n\n"
"HOT KEYS:\n"
"• F8: Quickly toggle trigger bot on/off\n"
"• F9: Emergency exit application\n\n"
"The bot will detect your selected color in the center of your screen\
n"
"and automatically click for you."
)
# Status bar
self.status_var = [Link](value="Status: Ready - Press ACTIVATE
TRIGGER or F8 to start")
status_bar = [Link]([Link], textvariable=self.status_var,
relief="sunken", anchor="w",
font=("Segoe UI", 10))
status_bar.pack(side="bottom", fill="x")
def choose_color(self):
"""Open color chooser dialog and update the target color"""
rgb_color = [Link](title="Choose Target Color",
initialcolor="#800080")
if rgb_color[1]: # If color was chosen (not canceled)
# Update the color preview
self.color_preview.configure(bg=rgb_color[1])
def update_settings(self):
"""Update settings labels and scanner parameters"""
# Update labels
self.radius_label.config(text=f"{[Link]()}")
self.delay_label.config(text=f"{int([Link]()*1000)}")
self.tolerance_label.config(text=f"{self.color_tolerance.get()}")
self.cooldown_label.config(text=f"{int(self.click_cooldown.get()*1000)}")
self.burst_count_label.config(text=f"{self.burst_count.get()}")
self.burst_interval_label.config(text=f"{int(self.burst_interval.get()*1000)}")
def get_scan_box(self):
"""Calculate the scan box coordinates based on the center and radius"""
radius = [Link]()
return (
self.center_x - radius, # Left
self.center_y - radius, # Top
self.center_x + radius + 1, # Right
self.center_y + radius + 1 # Bottom
)
def capture_screen_area(self):
"""Capture the scan area from the screen"""
try:
return [Link](bbox=self.get_scan_box())
except Exception as e:
self.status_var.set(f"Status: Error capturing screen: {e}")
return None
def is_target_color(self, rgb):
"""Check if RGB values are within target color range using tolerance"""
tolerance = self.color_tolerance.get()
lower_bound = [Link](self.target_color - tolerance, 0, 255)
upper_bound = [Link](self.target_color + tolerance, 0, 255)
def trigger_click(self):
"""Perform mouse click(s) based on selected mode"""
current_time = [Link]()
# Check cooldown
if current_time - self.last_clicked_time <= self.click_cooldown.get():
return
if mode == "single":
# Single click mode
[Link](self.center_x, self.center_y)
self.clicks_count += 1
self.last_clicked_time = current_time
def update_stats(self):
"""Update the statistics display"""
self.stats_text.config(state="normal")
self.stats_text.delete(1.0, [Link])
mode_desc = {
"single": "Single Click",
"burst": f"Burst ({self.burst_count.get()} clicks)",
"rapid": "Rapid Fire"
}
stats = (
f"▶ Status: {'⚠️
ACTIVE' if [Link] else ' INACTIVE'}\n"
f"▶ Detection Radius: {[Link]()} pixels\n"
f"▶ Scan Delay: {int([Link]()*1000)} ms\n"
f"▶ Click Mode: {mode_desc[self.click_mode.get()]}\n"
f"▶ Color Tolerance: {self.color_tolerance.get()}\n\n"
f"▶ Detections: {self.detections_count}\n"
f"▶ Clicks Triggered: {self.clicks_count}\n"
)
self.stats_text.insert([Link], stats)
self.stats_text.config(state="disabled")
def reset_stats(self):
"""Reset the statistics counters"""
self.clicks_count = 0
self.detections_count = 0
self.update_stats()
self.status_var.set("Status: Statistics reset")
def toggle_bot(self):
"""Toggle the bot on/off"""
[Link] = not [Link]
if [Link]:
self.start_button.config(text="STOP TRIGGER", style="[Link]")
self.status_var.set("Status: TRIGGER BOT ACTIVE - Watching for target
color")
[Link](target=self.bot_loop, daemon=True).start()
else:
self.start_button.config(text="ACTIVATE TRIGGER",
style="[Link]")
self.status_var.set("Status: Trigger Bot Stopped")
def start_preview_thread(self):
"""Start the preview update thread"""
self.should_update_preview = True
self.preview_thread = [Link](target=self.update_preview_loop,
daemon=True)
self.preview_thread.start()
def update_preview_loop(self):
"""Continuously update the preview canvas"""
while self.should_update_preview:
try:
# Capture the screen area
img = self.capture_screen_area()
if img:
# Resize the image to fit the canvas
scale_factor = min(350 / [Link], 350 / [Link])
new_size = (int([Link] * scale_factor * 3), int([Link] *
scale_factor * 3))
def update_preview_canvas(self):
"""Update the preview canvas with the latest image (called from main
thread)"""
self.preview_canvas.delete("all")
if hasattr(self, 'preview_img'):
# Center the image in the canvas
x = (350 - self.preview_img.width()) // 2
y = (350 - self.preview_img.height()) // 2
self.preview_canvas.create_image(x, y, anchor="nw",
image=self.preview_img)
# Draw crosshair
self.preview_canvas.create_line(canvas_center_x - 10, canvas_center_y,
canvas_center_x + 10, canvas_center_y,
fill="red", width=2)
self.preview_canvas.create_line(canvas_center_x, canvas_center_y - 10,
canvas_center_x, canvas_center_y + 10,
fill="red", width=2)
def bot_loop(self):
"""Main bot processing loop"""
try:
import keyboard # Import here to avoid issues if not available
while [Link]:
# Check for hotkeys
if keyboard.is_pressed('f8'):
[Link](0, self.toggle_bot)
[Link](0.3) # Debounce
continue
if keyboard.is_pressed('f9'):
[Link](0, self.on_close)
break
except Exception as e:
self.status_var.set(f"Status: Error in bot loop: {e}")
[Link] = False
[Link](0, lambda: self.start_button.config(text="ACTIVATE
TRIGGER", style="[Link]"))
def on_close(self):
"""Clean up and close the application"""
[Link] = False
self.should_update_preview = False
[Link]()
[Link](0)
if __name__ == "__main__":
try:
# Check for required modules
import keyboard
except ImportError:
print("Error: Required module 'keyboard' not found.")
print("Please install it with: pip install keyboard")
[Link](1)
root = [Link]()
app = AdvancedTriggerBot(root)
[Link]()