Check the color of a certain area and initiate mouse click if color changes

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Check the color of a certain area and initiate mouse click if color changes

09 May 2021, 11:52

Is it possible to have AHK check the color of a very specific spot every 2 seconds. (800, 150 are the X & Y coordinates). Then If the color changes, I'd like to initiate 1 mouse click on that exact same spot (see the spot marked as X in the screenshot). Mouse click opens up the email.

Then copy the digit passcode contained in the second screenshot.
PM Email notification b&a.png
PM Email notification b&a.png (50.67 KiB) Viewed 894 times
I was able to obtain the HEX value of the two different colors:
Read Email: Grey background (e7ebf1)
Unread Email: White background (ffffff)

6-digit passcode:
email from Epic Games.png
email from Epic Games.png (71.98 KiB) Viewed 884 times
User avatar
mikeyww
Posts: 26895
Joined: 09 Sep 2014, 18:38

Re: Check the color of a certain area and initiate mouse click if color changes

09 May 2021, 12:11

Here is a start for you on the first part.

Code: Select all

#Persistent
x := 800, y := 150
SetTimer, Check, 2000
Check:
SoundBeep, 1500
last := color
PixelGetColor, color, x, y
If (last = "" || color = last)
 Return
MouseClick,, x, y
SoundBeep, 500
ExitApp
M4verick
Posts: 193
Joined: 03 Nov 2020, 12:00

Re: Check the color of a certain area and initiate mouse click if color changes

09 May 2021, 16:01

Sorry Mikeww, your code does not work. It is not detecting the color change at all.
User avatar
mikeyww
Posts: 26895
Joined: 09 Sep 2014, 18:38

Re: Check the color of a certain area and initiate mouse click if color changes

09 May 2021, 16:18

Is your target window active when the script is first run?
You can issue a MouseMove to the coordinate.
What is the initial color that this script detects?
What is the color that this script detects there after your color changes?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Joey5, MHMD and 253 guests