pixel color

Ask gaming related questions (AHK v1.1 and older)
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

pixel color

09 May 2021, 07:17

Hey everyone, i am stuck.
I'm trying to make my script see a color differance and then do something when that happends, but it wouldn't work, tryed to search a lot of thing.
Am trying the let my script see the diverance in the two grey colors in discord but wont work and says white and sometimes a different color.

Can someone please help me with this.

Thank you :)
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: pixel color

09 May 2021, 07:59

Feel free to post your script for feedback about it.
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

Re: pixel color

09 May 2021, 13:03

i geuss i have this to lead of but this is from an other post i tried to use but didn't work on discord (not tried in any otehr app)
image.png
image.png (37.01 KiB) Viewed 3256 times
Last edited by gregster on 09 May 2021, 13:06, edited 1 time in total.
Reason: Removed duplicates.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: pixel color

09 May 2021, 13:21

"Didn't work" does not provide a lot of detail for the reader to figure out how to be helpful. What actually happens when you run this script? Exactly what should happen instead?
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: pixel color

09 May 2021, 13:47

The first line of the script is missing a comma between the two numbers. That would only affect what gets shown in the GUI, though, not the part under the hotkey. But that is probably what’s wrong with the part where you say it says the wrong color since that is the only part you showed us that displays a color.

What are your coordinates based on? Are they based on Discord’s window coordinates or the overall screen coordinates? If they are based on the window, then that window needs to be the active window when the PixelGetColor is executed. If they are based on screen coordinates, then you need to specify CoordMode, Pixel, Screen (see the documentation on CoordMode).

In future posts, please post the text of your script in between [code][/code] tags, not as a screenshot of your editor.
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

Re: pixel color

10 May 2021, 10:27

@boiler
my coords are based on my pc pixels, discord is on the second screen so i geuss thats teh problem

@mikeyww
when i run it, it says it a white color but i am using dark mode on discord and i color picked it aswell so i know the color code.

does any of you have a script i can use for that?
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: pixel color

10 May 2021, 10:40

Hynatos wrote: my coords are based on my pc pixels, discord is on the second screen so i geuss thats teh problem
Then did you try it with CoordMode, Pixel, Screen at the top of your script?
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

Re: pixel color

10 May 2021, 10:44

@boiler
how do i do that?
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: pixel color

10 May 2021, 10:45

At the top of the script, you write CoordMode, Pixel, Screen. That is how it is done.

As @boiler also noted: "In future posts, please post the text of your script". Include a description of what happened, and a description of what should happen instead.
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

Re: pixel color

10 May 2021, 11:27

@mikeyww
but do i just have to write discord as screen?
and the pixel where to check right?
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: pixel color

10 May 2021, 11:36

No. You literally put the following line at the top of your script. Do not change one letter.

Code: Select all

CoordMode, Pixel, Screen
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

Re: pixel color

10 May 2021, 11:41

Code: Select all

CoordMode, Pixel, Screen
PixelGetColor, Color, 2681 513, RGB
Gui, Add, Text, vColor w200, The Color: %Color%.
Gui, Show, w185 h100, Color.

f1::
SoundBeep
loop										
	{
		PixelGetColor, Color, 2745, 629, RGB		

		if (Color == 0x36393F)				
			{
			msgbox, Bang					
			break						
			}

		else							
			{
			msgbox, try again	
			sleep 1000				
			break					
			continue						
			}
	}
	

return	
[Mod edit: [code][/code] tags added.]

I tried this but it still says white am i doing something wrong?
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: pixel color

10 May 2021, 11:48

You still haven't put the comma in between the 2681 and the 513 in the first PixelGetColor command at the top of the script.

Where would it say "white"? I see nothing in your script that shows that it would display the word "white".

Are you sure the coordinates are correct? Did you use the Window Spy tool to get them? If so, were they the numbers after the word "Screen", "Window", or "Client"?

When you post the text of your script, please put [code][/code] tags around it so it goes in a code box.
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

Re: pixel color

10 May 2021, 11:56

@boiler
well i did a thing and now it wrks i think XD, btw ty for saying the comma now i can see teh color code

Also do you know how to like check it every ms or few ms? Like a auto loop that checks until it finds it.
Hynatos
Posts: 11
Joined: 24 Feb 2021, 08:25

Re: pixel color

10 May 2021, 12:02

image.png
image.png (1.94 KiB) Viewed 3141 times
is there a way to get this ti work every few ms?


Here is my script i have rn:

Code: Select all

CoordMode, Pixel, Screen
PixelGetColor, Color, 2942, 850, Slow 
Gui, Add, Text, vColor w200, The Color: %Color%.
Gui, Show, w185 h100, Color.

f1::
SoundBeep
loop										
	{
		PixelGetColor, Color, 2942, 850, Slow 		

		if (Color == 0x36312F)				
			{
			msgbox, Bang					
			break						
			}

		else							
			{
			msgbox, try again	
			sleep 1000				
			break					
			continue						
			}
	}
	

return	
User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: pixel color

10 May 2021, 15:48

Hynatos wrote:
10 May 2021, 11:56
Also do you know how to like check it every ms or few ms? Like a auto loop that checks until it finds it.
You already have a loop that checks and breaks the loop after it finds it. Isn’t that what you want?

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 75 guests