Getting color of a pixel and then clicking on it

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
FifteenWheat061
Posts: 2
Joined: 19 Jul 2018, 04:04

Getting color of a pixel and then clicking on it

19 Jul 2018, 04:15

Hi guys!

I am having trouble with this script, it should check if the color is this redish (AF1A34), and then click on it. I tryed to get the color in a lots of ways, i have it in rgb(175, 26, 52), even i grabbed it with AHK script(0x3419AF), but none of them works for me. :

Code: Select all

SetDefaultMouseSpeed, 0
Finished = 0 
Up::
while Finished<1
	{
		PixelGetColor, OutputVar, 712, 550
		if (OutputVar = 0x3419AF)
		{
			MouseClick, L, 712, 550, 1, 0
		}
		PixelGetColor, OutputVar, 969, 550
		if (OutputVar = 0x3419AF)
		{
			MouseClick, L, 969, 550, 1, 0
		}
		
	}
	return
Down::Finished := 1
Thanks for your help.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Getting color of a pixel and then clicking on it

19 Jul 2018, 06:30

what exactly doesnt work? the clicking? the pixelfinding? the looping?
your coordinates are likely messed up. ud probably want CoordMode, Screen enabled for both Mouse and Pixel
also, RGB: 0xAF1A34 is not BGR: 0x3419AF, but rather BGR: 0x341AAF
FifteenWheat061
Posts: 2
Joined: 19 Jul 2018, 04:04

Re: Getting color of a pixel and then clicking on it

19 Jul 2018, 06:42

I don't know. I successfully managed to get it to work with another color, but when I try it with this redish, it just does not work, so I am thinking that maybe I picked the color poorly.

I am thinking about staying with the white, but with the white it sometimes stops working.

This is for a Facebook game, but if I use the white, it sometimes gets about 9 points, but once it got about 80. It clicks where it should, then it just says Game Over


--- I checked it like 5 times now, and the game every time just uses another color, that for me looks exactly the same, but has another value ---

This is my new code:

Code: Select all

Up::
Finished =0
while Finished<1
	{
		PixelGetColor, OutputVar, 712, 500
		if (OutputVar = 0xFFFFFF)
		{
			MouseClick, , 715, 500, ,0
		}
		PixelGetColor, OutputVar2, 969, 500
		if (OutputVar2 = 0xFFFFFF)
		{
			MouseClick, , 970, 500, ,0
		}
	}
Down::Finished = 1

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Giresharu, inseption86, jomaweb, KruschenZ, mikeyww, Rohwedder and 278 guests