Do Something When A Color Is Detected At a Certain Spot

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Hampoon
Posts: 25
Joined: 19 Oct 2018, 22:04

Do Something When A Color Is Detected At a Certain Spot

03 Jan 2019, 00:49

Hey there. I'd like to make my script search for the color black in a few specific spots and when it finds said black it can do something, in this case send a key.
For example, if it sees black at 182, 198 it can send the D key. If it sees black at 184, 991 it can press S.
Thanks so much!
I'm pretty new to this language and barely know what I'm doing. Please excuse any stupidity lol.
Oh also try and explain stuff well if I need it :P
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Do Something When A Color Is Detected At a Certain Spot

03 Jan 2019, 08:56

absolute barebones

Code: Select all

PixelGetColor color, 182, 198, RGB
if (color = 0x000000)
	Send d
Hampoon
Posts: 25
Joined: 19 Oct 2018, 22:04

Re: Do Something When A Color Is Detected At a Certain Spot

03 Jan 2019, 22:14

swagfag wrote:
03 Jan 2019, 08:56
absolute barebones

Code: Select all

PixelGetColor color, 182, 198, RGB
if (color = 0x000000)
	Send d
so uh how do i know what shade it is? it doesnt seem to be that shade, or im doing something wrong?
I'm pretty new to this language and barely know what I'm doing. Please excuse any stupidity lol.
Oh also try and explain stuff well if I need it :P
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Do Something When A Color Is Detected At a Certain Spot

04 Jan 2019, 02:24

the variable color contains the hex rgb representation of the found color at the coordinates you supplied to the command. unless u meant something else by "shade"
Hampoon
Posts: 25
Joined: 19 Oct 2018, 22:04

Re: Do Something When A Color Is Detected At a Certain Spot

04 Jan 2019, 04:14

swagfag wrote:
04 Jan 2019, 02:24
the variable color contains the hex rgb representation of the found color at the coordinates you supplied to the command. unless u meant something else by "shade"
yes i mean color. how do i find what color/hex it is?
I'm pretty new to this language and barely know what I'm doing. Please excuse any stupidity lol.
Oh also try and explain stuff well if I need it :P
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Do Something When A Color Is Detected At a Certain Spot

04 Jan 2019, 05:13

by checking the contents of the variable color?

or if ure asking how to convert it into something human readable:

Code: Select all

color := 16711935
MsgBox % Format("0x{:X}", color)
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: Do Something When A Color Is Detected At a Certain Spot

08 Jan 2019, 16:50

I saw from the other post that you're still with troubles so, you could do a simple test script to copy the color.

For example by pressing F1:

Code: Select all

F1::
	PixelGetColor color, 182, 198, RGB
	Clipboard := color
return
Is that what you mean?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Starker and 253 guests