0% found this document useful (0 votes)
48 views19 pages

Trigger Bot

Uploaded by

hezhaargoshy2009
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)
48 views19 pages

Trigger Bot

Uploaded by

hezhaargoshy2009
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

import tkinter as tk

from tkinter import ttk, colorchooser, messagebox


import pyautogui
import numpy as np
import time
import threading
import sys
from PIL import ImageGrab, Image, ImageTk

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

# Get screen dimensions


self.screen_width, self.screen_height = [Link]()
self.center_x = self.screen_width // 2
self.center_y = self.screen_height // 2

# Create GUI
self.create_gui()

# Preview thread
self.preview_thread = None
self.should_update_preview = False

# Start the preview thread


self.start_preview_thread()

# Ensure clean exit


[Link]("WM_DELETE_WINDOW", self.on_close)

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)

# Left column (controls)


controls_frame = [Link](main_frame, text="Trigger Bot Settings",
padding=10)
controls_frame.pack(side="left", fill="both", padx=(0, 5), expand=True)

# Color selection
color_frame = [Link](controls_frame)
color_frame.pack(fill="x", pady=5)

[Link](color_frame, text="Target Color:").pack(side="left")

self.color_preview = [Link](color_frame, width=30, height=20,


bg="#800080")
self.color_preview.pack(side="left", padx=5)

[Link](color_frame, text="Choose Color",


command=self.choose_color).pack(side="left")

# 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")

# Color tolerance slider


[Link](controls_frame, text="Color Tolerance:").pack(anchor="w",
pady=(10, 0))
[Link](controls_frame, from_=5, to=100, variable=self.color_tolerance,
command=lambda _: self.update_settings()).pack(fill="x")
self.tolerance_label = [Link](controls_frame, text=f"Current:
{self.color_tolerance.get()}")
self.tolerance_label.pack(anchor="w")

# Click cooldown slider


[Link](controls_frame, text="Click Cooldown
(seconds):").pack(anchor="w", pady=(10, 0))
[Link](controls_frame, from_=0.01, to=0.5, variable=self.click_cooldown,
command=lambda _: self.update_settings()).pack(fill="x")
self.cooldown_label = [Link](controls_frame, text=f"Current:
{self.click_cooldown.get():.3f}")
self.cooldown_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")

[Link](buttons_frame, text="Reset Stats",


command=self.reset_stats).pack(side="left", padx=5, expand=True, fill="x")

# Right column (preview and stats)


right_frame = [Link](main_frame)
right_frame.pack(side="right", fill="both", padx=(5, 0), expand=True)

# Preview area
preview_frame = [Link](right_frame, text="Center Screen Preview",
padding=10)
preview_frame.pack(fill="both", expand=True, pady=(0, 5))

self.preview_canvas = [Link](preview_frame, width=250, height=250,


bg="black")
self.preview_canvas.pack(fill="both", expand=True)

# Statistics area
stats_frame = [Link](right_frame, text="Bot Statistics",
padding=10)
stats_frame.pack(fill="both", expand=True, pady=(5, 0))

self.stats_text = [Link](stats_frame, height=8, width=30,


state="disabled", font=("Consolas", 10))
self.stats_text.pack(fill="both", expand=True)

# 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))

[Link](hotkey_frame, text="Hotkeys:", font=("Arial", 9,


"bold")).pack(anchor="w")
[Link](hotkey_frame, text="• F8: Toggle Bot On/Off", font=("Arial",
9)).pack(anchor="w")
[Link](hotkey_frame, text="• F9: Exit Application", font=("Arial",
9)).pack(anchor="w")

# Update the settings initially


self.update_settings()

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")

# Update stats display


self.update_stats()

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)

return [Link](rgb >= lower_bound) and [Link](rgb <= upper_bound)

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))

if new_size[0] > 0 and new_size[1] > 0: # Ensure valid


dimensions
resized_img = [Link](new_size, [Link])
self.preview_img = [Link](resized_img)

# Update canvas on the main thread


[Link](0, self.update_preview_canvas)
except Exception as e:
print(f"Preview error: {e}")

[Link](0.1) # Update preview at 10 Hz

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 a red crosshair in the center of the preview


canvas_center_x = 250 // 2
canvas_center_y = 250 // 2

# 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)

# Draw detection circle


radius_px = [Link]() * 3 # Scale to match the preview size
self.preview_canvas.create_oval(canvas_center_x - radius_px,
canvas_center_y - radius_px,
canvas_center_x + radius_px,
canvas_center_y + radius_px,
outline="red", width=1)

# Show scanning text if bot is running


if [Link]:
self.preview_canvas.create_text(canvas_center_x, 20,
text="SCANNING FOR PURPLE",
fill="lime", font=("Arial", 10,
"bold"))

def bot_loop(self):
"""Main bot processing loop"""
try:
import keyboard # Import here to avoid issues if not available

self.status_var.set("Status: BOT ACTIVE - Watching for purple (F8:


toggle, F9: exit)")

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

# Capture screen area


img = self.capture_screen_area()
if img:
# Convert to numpy array for color checking
img_array = [Link](img)
found_target = False

# Check each pixel in the captured area


for y in range(img_array.shape[0]):
for x in range(img_array.shape[1]):
pixel = img_array[y, x]
if self.is_target_color(pixel):
self.detections_count += 1
found_target = True
break
if found_target:
break

# If found the target color, trigger a click


if found_target:
self.trigger_click()
[Link](0, self.update_stats)

# Use the configured delay to control scan frequency


[Link]([Link]())

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

# Wait a bit for threads to terminate


[Link](0.2)

[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

# Click mode settings


self.click_mode = [Link](value="single") # Default to single click
self.burst_count = [Link](value=3) # Clicks per burst
self.burst_interval = [Link](value=0.02) # Time between burst clicks

# Statistics variables
self.clicks_count = 0
self.detections_count = 0
self.last_clicked_time = 0

# Get screen dimensions


self.screen_width, self.screen_height = [Link]()
self.center_x = self.screen_width // 2
self.center_y = self.screen_height // 2

# Create custom styles


self.create_styles()

# Create GUI
self.create_gui()

# Preview thread
self.preview_thread = None
self.should_update_preview = False

# Start the preview thread


self.start_preview_thread()

# Ensure clean exit


[Link]("WM_DELETE_WINDOW", self.on_close)

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')])

# Start button style


[Link]("[Link]",
background="#006400",
foreground="#FFFFFF")

[Link]("[Link]",
background=[('active', '#008800')])

# Stop button style


[Link]("[Link]",
background="#8B0000",
foreground="#FFFFFF")

[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 Tab Content - Split into left and right


main_left = [Link](main_tab)
main_left.pack(side="left", fill="both", expand=True, padx=(0, 5))

main_right = [Link](main_tab)
main_right.pack(side="right", fill="both", expand=True, padx=(5, 0))

# === LEFT SIDE: CONTROLS ===


controls_frame = [Link](main_left, text="Trigger Controls",
padding=10)
controls_frame.pack(fill="both", expand=True)

# Color selection with preview


color_frame = [Link](controls_frame)
color_frame.pack(fill="x", pady=10)

[Link](color_frame, text="Target Color:", font=("Segoe UI", 12,


"bold")).pack(side="left")

self.color_preview = [Link](color_frame, width=40, height=30,


bg="#800080", highlightthickness=0)
self.color_preview.pack(side="left", padx=10)

[Link](color_frame, text="Choose Color",


command=self.choose_color).pack(side="left")

# Radius slider - with larger range


[Link](controls_frame, text="Detection Radius:", font=("Segoe UI",
12)).pack(anchor="w", pady=(15, 0))
radius_frame = [Link](controls_frame)
radius_frame.pack(fill="x")

radius_scale = [Link](radius_frame, from_=1, to=100,


variable=[Link],
command=lambda _: self.update_settings(), length=300)
radius_scale.pack(side="left", fill="x", expand=True)

self.radius_label = [Link](radius_frame, text=f"{[Link]()}",


width=3)
self.radius_label.pack(side="right")

# Delay slider - with 0ms option


[Link](controls_frame, text="Scan Delay (ms):", font=("Segoe UI",
12)).pack(anchor="w", pady=(15, 0))
delay_frame = [Link](controls_frame)
delay_frame.pack(fill="x")

delay_scale = [Link](delay_frame, from_=0.0, to=10.0,


variable=[Link],
command=lambda _: self.update_settings(), length=300)
delay_scale.pack(side="left", fill="x", expand=True)

self.delay_label = [Link](delay_frame,
text=f"{int([Link]()*1000)}", width=3)
self.delay_label.pack(side="right")

# Click mode selection


[Link](controls_frame, text="Click Mode:", font=("Segoe UI",
12)).pack(anchor="w", pady=(15, 0))
modes_frame = [Link](controls_frame)
modes_frame.pack(fill="x", pady=5)

self.single_radio = [Link](modes_frame, text="Single Click",


variable=self.click_mode, value="single",
command=self.update_settings)
self.single_radio.pack(side="left", padx=(0, 10))

self.burst_radio = [Link](modes_frame, text="Burst",


variable=self.click_mode, value="burst",
command=self.update_settings)
self.burst_radio.pack(side="left", padx=(0, 10))

self.rapid_radio = [Link](modes_frame, text="Rapid Fire",


variable=self.click_mode, value="rapid",
command=self.update_settings)
self.rapid_radio.pack(side="left")

# Buttons: large action buttons


buttons_frame = [Link](controls_frame)
buttons_frame.pack(fill="x", pady=20)

self.start_button = [Link](buttons_frame, text="ACTIVATE TRIGGER",


command=self.toggle_bot, style="[Link]")
self.start_button.pack(side="left", padx=5, expand=True, fill="x",
ipady=10)

[Link](buttons_frame, text="Reset Stats",


command=self.reset_stats).pack(side="left", padx=5, expand=True, fill="x")

# === RIGHT SIDE: PREVIEW ===


preview_frame = [Link](main_right, text="Center Screen Preview",
padding=10)
preview_frame.pack(fill="both", expand=True, pady=(0, 5))
self.preview_canvas = [Link](preview_frame, width=350, height=350,
bg="black", highlightthickness=0)
self.preview_canvas.pack(fill="both", expand=True)

# Statistics area
stats_frame = [Link](main_right, text="Bot Statistics", padding=10)
stats_frame.pack(fill="both", expand=True, pady=(5, 0))

self.stats_text = [Link](stats_frame, height=6, width=30,


state="disabled",
font=("Consolas", 12), bg="#333333", fg="#FFFFFF")
self.stats_text.pack(fill="both", expand=True)

# === ADVANCED TAB CONTENT ===


# Color settings
color_settings = [Link](advanced_tab, text="Color Detection
Settings", padding=10)
color_settings.pack(fill="x", expand=False, pady=(0, 10))

[Link](color_settings, text="Color Tolerance:", font=("Segoe UI",


12)).pack(anchor="w")
tolerance_frame = [Link](color_settings)
tolerance_frame.pack(fill="x", pady=5)

tolerance_scale = [Link](tolerance_frame, from_=5, to=150,


variable=self.color_tolerance,
command=lambda _: self.update_settings())
tolerance_scale.pack(side="left", fill="x", expand=True)

self.tolerance_label = [Link](tolerance_frame,
text=f"{self.color_tolerance.get()}", width=3)
self.tolerance_label.pack(side="right")

[Link](color_settings, text="Higher values detect more shades of the


target color").pack(anchor="w", pady=(0, 10))

# 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)

cooldown_scale = [Link](cooldown_frame, from_=0, to=100,


variable=self.click_cooldown,
command=lambda _: self.update_settings())
cooldown_scale.pack(side="left", fill="x", expand=True)

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)

burst_count_scale = [Link](burst_count_frame, from_=2, to=10,


variable=self.burst_count,
command=lambda _: self.update_settings())
burst_count_scale.pack(side="left", fill="x", expand=True)

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)

burst_interval_scale = [Link](burst_interval_frame, from_=1, to=50,


variable=self.burst_interval,
command=lambda _: self.update_settings())
burst_interval_scale.pack(side="left", fill="x", expand=True)

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."
)

help_label = [Link](help_frame, text=help_text, justify="left",


font=("Segoe UI", 10))
help_label.pack(fill="both", expand=True)

# 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")

# Update the settings initially


self.update_settings()

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])])

# Show the chosen color in hex and RGB


hex_color = rgb_color[1].upper()
r, g, b = int(rgb_color[0][0]), int(rgb_color[0][1]), int(rgb_color[0]
[2])

self.status_var.set(f"Color set to: {hex_color} (RGB: {r}, {g}, {b})")


self.update_settings()

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)}")

# Update stats display


self.update_stats()

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)

return [Link](rgb >= lower_bound) and [Link](rgb <= upper_bound)

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

# Get selected click mode


mode = self.click_mode.get()

if mode == "single":
# Single click mode
[Link](self.center_x, self.center_y)
self.clicks_count += 1
self.last_clicked_time = current_time

elif mode == "burst":


# Burst mode - multiple clicks with short interval
def burst_clicking():
for _ in range(self.burst_count.get()):
[Link](self.center_x, self.center_y)
self.clicks_count += 1
[Link](self.burst_interval.get())

# Start burst in separate thread to not block main loop


[Link](target=burst_clicking, daemon=True).start()
self.last_clicked_time = current_time

elif mode == "rapid":


# Rapid fire mode - continuous clicking
[Link](self.center_x, self.center_y)
self.clicks_count += 1
self.last_clicked_time = current_time

# Update the statistics


[Link](0, self.update_stats)

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))

if new_size[0] > 0 and new_size[1] > 0: # Ensure valid


dimensions
resized_img = [Link](new_size, [Link])
self.preview_img = [Link](resized_img)

# Update canvas on the main thread


[Link](0, self.update_preview_canvas)
except Exception as e:
print(f"Preview error: {e}")

[Link](0.1) # Update preview at 10 Hz

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 a red crosshair in the center of the preview


canvas_center_x = 350 // 2
canvas_center_y = 350 // 2

# 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)

# Draw detection circle


radius_px = min(150, [Link]() * 3) # Scale to match the
preview size but cap at 150px
self.preview_canvas.create_oval(canvas_center_x - radius_px,
canvas_center_y - radius_px,
canvas_center_x + radius_px,
canvas_center_y + radius_px,
outline="red", width=2)

# Show scanning text if bot is running


if [Link]:
self.preview_canvas.create_rectangle(canvas_center_x - 100, 15,
canvas_center_x + 100, 35,
fill="#004400",
outline="#00FF00")
self.preview_canvas.create_text(canvas_center_x, 25,
text="SCANNING ACTIVE",
fill="#00FF00", font=("Arial", 10,
"bold"))

def bot_loop(self):
"""Main bot processing loop"""
try:
import keyboard # Import here to avoid issues if not available

self.status_var.set("Status: BOT ACTIVE - Watching for target color


(F8: toggle, F9: exit)")

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

# Capture screen area


img = self.capture_screen_area()
if img:
# Convert to numpy array for color checking
img_array = [Link](img)
found_target = False

# Check each pixel in the captured area


for y in range(img_array.shape[0]):
for x in range(img_array.shape[1]):
pixel = img_array[y, x]
if self.is_target_color(pixel):
self.detections_count += 1
found_target = True
break
if found_target:
break

# If found the target color, trigger a click


if found_target:
self.trigger_click()

# Use the configured delay to control scan frequency


# 0ms delay for maximum speed
if [Link]() > 0:
[Link]([Link]())

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

# Wait a bit for threads to terminate


[Link](0.2)

[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]()

You might also like