Hey! Can you make my python roblox autoclicker more reliable? All this code does is…
- User
Hey! Can you make my python roblox autoclicker more reliable? All this code does is click a roblox window every 600s, but sometimes it just skips because of windows errors - some, ironically erroring with success. Hey, I have premade a roblox window clicker, but it is somewhat unreliable. Arteficial delays will not suffice. Can you take a look at it and have your spin on it? import pygetwindow as gw import pyautogui import time import logging import threading from tkinter import Tk, Label, StringVar from screeninfo import get_monitors
Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def is_window_fullscreen(window): """ Checks if the specified window is in full-screen mode. """ screen = pyautogui.size() x, y, width, height = window.box return (width, height) == (screen.width, screen.height)
def get_secondary_monitor(): """ Returns the secondary monitor if available, else returns None. """ monitors = get_monitors() return monitors[1] if len(monitors) > 1 else None
def bring_window_to_foreground(window, secondary_monitor): """ Brings the specified window to the foreground on the secondary monitor and unminimizes it if needed. """ if window.isMinimized: # Check if the window is minimized window.restore() # Unminimize the window if secondary_monitor: window.moveTo(secondary_monitor.x, secondary_monitor.y) # Move to secondary monitor window.activate() # Activate the window
def is_window_on_secondary_monitor(window, secondary_monitor): """ Checks if the window is on the secondary monitor. """ if not secondary_monitor: return False x, y, width, height = window.box return (secondary_monitor.x <= x < secondary_monitor.x + secondary_monitor.width and secondary_monitor.y <= y < secondary_monitor.y + secondary_monitor.height)
def click_windows(title, excluded_apps, click_count, delay_between_clicks, loop_delay, update_clicks_callback): total_clicks = 0 pyautogui.FAILSAFE = False secondary_monitor = get_secondary_monitor()
while True:
Store the current mouse position
initial_mouse_position = pyautogui.position()
windows_to_click = [win for win in gw.getAllWindows() if title in win.title and not any(app in win.title for app in excluded_apps)]
for win in windows_to_click: try: logging.info(f"Processing window: {win.title}")
if win.isMinimized or not win.isActive: logging.info("Window is minimized or not active, maximizing and bringing to foreground.") bring_window_to_foreground(win, secondary_monitor) time.sleep(0.1) # Wait a bit for the window to respond
if not is_window_on_secondary_monitor(win, secondary_monitor): logging.info("Window is not on secondary monitor, skipping.") continue
if is_window_fullscreen(win): logging.info("Window is fullscreen, skipping.") continue
x, y, width, height = win.box click_x, click_y = x + width / 2, y + height / 2 # Center of the window
- Assistant