The script can be generally used for auto clicking other buttons too, based on the images. An AutoHotkey script that automatically detects and clicks a specific button on popups by matching an image pattern. The script runs persistently in the background and checks for the specified button every 2 seconds.
- Continuously monitors the screen for a specific button image
- Performs a natural-looking click interaction when the button is found
- Preserves the original mouse position after clicking
- Works across the entire screen
- Minimal system resource usage with a 2-second check interval
- AutoHotkey v1.1 or later
- A screenshot of the target button saved as an image file
- Install AutoHotkey if you haven't already
- Clone this repository or download the script
- Take a screenshot of the button you want to auto-click
- Update the
ImagePathvariable in the script to point to your button image:
ImagePath := "C:\Users\admin\Documents\scripts\images\allow_for_this_chat.png"The script:
- Searches the entire screen for the specified button image every 2 seconds
- When found, calculates the center point of the button
- Performs a natural mouse movement pattern:
- Moves to the button center
- Slightly moves away
- Moves back to center
- Clicks
- Returns the mouse to its original position
SetTimer, CheckForButton, 2000- Adjust the 2000 to change the check frequency (in milliseconds)CenterOffsetXandCenterOffsetY- Adjust these values if your button has different dimensions- Sleep timings can be adjusted by modifying the
Sleepvalues
- The script uses screen coordinates, so it will work regardless of window position
- Make sure your button screenshot is clear and distinctive to avoid false matches
- The script runs continuously until manually stopped
- Start the script by double-clicking the .ahk file
- The script will run in the background (icon appears in system tray)
- To stop the script, right-click the AutoHotkey icon in the system tray and select "Exit"
This project is open source and available under the MIT License.
Feel free to submit issues and enhancement requests!