pixel color trigger

Ask gaming related questions (AHK v1.1 and older)
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

pixel color trigger

13 Apr 2021, 18:23

hi guys i need a help with this script i need modify it so it can have added 4 colors and 4 cords
thx for the help!

Code: Select all

#Persistent



SetTimer, Cura, 500

Return



Cura:

Sleep,10



PixelGetColor, Color,346, 44

If color = 0x0A0B0F
{

Send {F1}

}

Return
[Mod edit: [code][/code] tags added.]
Last edited by doomeyes2 on 13 Apr 2021, 19:27, edited 1 time in total.
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: pixel color trigger

13 Apr 2021, 19:16

Code: Select all

#Persistent
key := {0x0A0B0F: 1, 0x0A0B0E: 2, 0x0A0B0D: 3, 0x0A0B0C: 4} ; Blue, green, red
SetTimer, Cura, 500
Cura:
PixelGetColor, color, 346, 44
Send % key.HasKey(color) ? "{F" key[color] "}" : ""
Return
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

13 Apr 2021, 20:09

mikeyww wrote:
13 Apr 2021, 19:16

Code: Select all

#Persistent
SetTimer, Cura, 500
Cura:
PixelGetColor, thisColor, 346, 44
For cNum, color in [0x0A0B0F, 0x0A0B0E, 0x0A0B0D, 0x0A0B0C] ; Blue, green, red
 Send % thisColor = color ? "{F" cNum "}" : ""
Return
not working and i need 4 other cords not only 4 colors
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: pixel color trigger

13 Apr 2021, 20:15

Provide a complete description of what should happen, step by step, with examples.
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

13 Apr 2021, 20:47

i added the pixel color and isn't working....mine still works but im runing it with 4 files thats why i need compact it with 4 colors
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: pixel color trigger

13 Apr 2021, 21:02

Your post is a status update rather than a complete description of what should happen, step by step, with examples.
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

13 Apr 2021, 23:07

I need the script to look for four different colors in four different coordinates
and send the f1 command
because im having to open fours files i want to compact it in one
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: pixel color trigger

14 Apr 2021, 04:38

I do not see any examples in your post. Others may be more able to help you. You are on the right track. You can repeat your search command using different coordinates. You can add new If statements in the way that you need. The operator != will mean "does not equal". Good luck.
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: pixel color trigger

14 Apr 2021, 06:30

@doomeyes2 - I believe the code below does what you're asking. Of course you need to change the c, x, and y to be what you want for each of the four pixels. It assumes the colors are in BGR as your original script does. If you want to specify them in RGB, then add , RGB to the end of the PixelGetColor line.

Code: Select all

#Persistent
Pixels := [{c: 0x0A0B0F, x: 346, y: 44}, {c: 0x000000, x: 400, y: 50}, {c: 0xFFFFFF, x: 450, y: 60}, {c: 0xA0A0A0, x: 500, y: 70}]
SetTimer, Cura, 500
return

Cura:
	for Each, Pixel in Pixels
	{
		PixelGetColor, PixCol, Pixel.x, Pixel.y
		if (PixCol = Pixel.c)
			Send, {F1}
	}
return
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: pixel color trigger

14 Apr 2021, 06:44

Above was edited for BGR/RGB info while you may have been looking at it, so use the version that would appear now after you see this message.
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

14 Apr 2021, 06:51

boiler wrote:
14 Apr 2021, 06:30
@doomeyes2 - I believe the code below does what you're asking. Of course you need to change the c, x, and y to be what you want for each of the four pixels. It assumes the colors are in BGR as your original script does. If you want to specify them in RGB, then add , RGB to the end of the PixelGetColor line.

Code: Select all

#Persistent
Pixels := [{c: 0x0A0B0F, x: 346, y: 44}, {c: 0x000000, x: 400, y: 50}, {c: 0xFFFFFF, x: 450, y: 60}, {c: 0xA0A0A0, x: 500, y: 70}]
SetTimer, Cura, 500
return

Cura:
	for Each, Pixel in Pixels
	{
		PixelGetColor, PixCol, Pixel.x, Pixel.y
		if (PixCol = Pixel.c)
			Send, {F1}
	}
return
when i open says missing a }
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: pixel color trigger

14 Apr 2021, 06:54

Copy the whole script, not just the part that’s visible without scrolling or expanding the code box.
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

14 Apr 2021, 06:55

is it possible if color it not x send a key until that color goes back
a play pause button
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

14 Apr 2021, 06:59

i copy the whole script i opened it then worked but when i set my colors and cords when i try to open it says nmissing }
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: pixel color trigger

14 Apr 2021, 07:01

I'm not sure if this is what you mean.

Code: Select all

#Persistent
Pixels := [{c: 0x0A0B0F, x: 346, y: 44}, {c: 0x000000, x: 400, y: 50}, {c: 0xFFFFFF, x: 450, y: 60}, {c: 0xA0A0A0, x: 500, y: 70}]
SetTimer, Cura, 500
return

Cura:
	for Each, Pixel in Pixels
	{
		loop
		{
			PixelGetColor, PixCol, Pixel.x, Pixel.y
			if (PixCol != Pixel.c)
				Send, {F1}
			Sleep, 50
		} until (PixCol = Pixel.c)
	}
return

F1::Pause ; press F1 to play/pause
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: pixel color trigger

14 Apr 2021, 07:02

doomeyes2 wrote:
14 Apr 2021, 06:59
i copy the whole script i opened it then worked but when i set my colors and cords when i try to open it says nmissing }
Then you deleted a } when you entered your colors and coords. If you can't see where, post your script.
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

14 Apr 2021, 09:57

boiler wrote:
14 Apr 2021, 07:02
doomeyes2 wrote:
14 Apr 2021, 06:59
i copy the whole script i opened it then worked but when i set my colors and cords when i try to open it says nmissing }
Then you deleted a } when you entered your colors and coords. If you can't see where, post your script.
this one
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: pixel color trigger

14 Apr 2021, 10:26

I take that to mean you found that you accidentally removed a character. If not, and you can’t see where the problem is, post your script so the problem can be identified.
doomeyes2
Posts: 13
Joined: 13 Apr 2021, 18:19

Re: pixel color trigger

15 Apr 2021, 05:23

Code: Select all

#Persistent
Pixels := [{c: 0x0A0B0F, x: 346, y: 44}, {c: 0x0B0D10, x: 32, y: 45}, {c: 0x0A0B0F, x: 342, y: 45}, {c: 0x0A0C0F, x: 328, y: 63}]
SetTimer, Cura, 500
return

Cura:
	for Each, Pixel in Pixels
	{
		PixelGetColor, PixCol, Pixel.x, Pixel.y
		if (PixCol = Pixel.c)
			Send, {F1}
[Mod edit: [code][/code] tags added.]
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: pixel color trigger

15 Apr 2021, 07:36

Where is the rest of the script? You said you copied the whole script, not just the part that’s initially visible in the code box. Click “Expand View” at the top of the code box where I posted the script to see the whole thing. Or you can click and drag the scroll bar at right of the code box to see the rest of the code. Or you can just click “Select all” at the top of the code box to select everything inside it, then press Ctrl+C to copy it.
code box.jpg
code box.jpg (28.94 KiB) Viewed 1465 times

The whole script looks like this:
code box 2.jpg
code box 2.jpg (25.61 KiB) Viewed 1465 times

And the other one looks like this:
code box 3.jpg
code box 3.jpg (33.17 KiB) Viewed 1465 times

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 58 guests