commend thats know if its red(all the kind of red) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
UZIEL7717
Posts: 20
Joined: 26 Aug 2016, 09:02

commend thats know if its red(all the kind of red)

26 Aug 2016, 14:11

i need commend thats know if its red ,
there is more then 6k diffrent red colors code #ff0000
there is a way to do all the reds ? in one simple command
foxhunter
Posts: 72
Joined: 04 Aug 2016, 04:27

Re: commend thats know if its red(all the kind of red)

26 Aug 2016, 14:38

Have a look at the PixelSearch command with Variation of 0-255
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: commend thats know if its red(all the kind of red)

26 Aug 2016, 15:46

UZIEL7717 wrote: there is more then 6k diffrent red colors code #ff0000
How do you come to that conclusion? For example, If red is defined as XX0000, where X =0,...,9,A,...F, then there is 256 different reds, but FF0001, looks more red than 010000, so how do you define red?

Edit: I suppose no one would define 000000 as red, so 255 reds then.
Edit 2:

Code: Select all

isRed(color)
{
	; Messed up this comment...
	return color > 65535
}
Last edited by Helgef on 27 Aug 2016, 07:27, edited 1 time in total.
User avatar
boiler
Posts: 16954
Joined: 21 Dec 2014, 02:44

Re: commend thats know if its red(all the kind of red)

26 Aug 2016, 15:55

There are way more than 255 reds. Definitely thousands of reds. Are you saying you wouldn't classify FF0101 as red? If you look at it, you wouldn't call it anything but red. Same for a whole lot of other levels of green and blue added to it as well.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: commend thats know if its red(all the kind of red)

26 Aug 2016, 16:16

I'm not saying that. Author said, there is more than 6k and typed FF0000, I asked how the author defines red. How many reds exists depends on definition and the space considered. In real life there is infinite many reds, and it's subjective. isRed is a useful function if you want to know if a color contains any red information, its not meant to answer a question like, does this color look red to the (a) human eye?
UZIEL7717
Posts: 20
Joined: 26 Aug 2016, 09:02

Re: commend thats know if its red(all the kind of red)

26 Aug 2016, 17:49

Helgef wrote:I'm not saying that. Author said, there is more than 6k and typed FF0000, I asked how the author defines red. How many reds exists depends on definition and the space considered. In real life there is infinite many reds, and it's subjective. isRed is a useful function if you want to know if a color contains any red information, its not meant to answer a question like, does this color look red to the (a) human eye?
this is my code right now :

Code: Select all

F1::pause, toggle

F3::
Loop,
{
CoordMode, Pixel, Screen
x1:=960
y1:=540


color1:=0xbe7367
color2:=0xfe8a8a
color3:=0xff0000


repeat:
Loop
	PixelGetColor,colorFound,x1,y1,
until (colorFound=color1 || colorFound=color2 || colorFound=color3||  )
MouseClick, left
}

return



what i need to put in color1 to make it only red ..
can you help me and chang it for me please
what i want its to send left click mouse when its see red in x1:=960
y1:=540
p3trus
Posts: 137
Joined: 02 Aug 2016, 03:20

Re: commend thats know if its red(all the kind of red)

26 Aug 2016, 19:57

UZIEL7717 wrote:what i need to put in color1 to make it only red ..
can you help me and chang it for me please
only red would be
- 0x0000FF if you use PixelGetColor the way you do (BGR format)
- 0xFF0000 if you use PixelGetColor with the additional , RGB parameter

Otherwise you have to specify a custom function to test, e.g.

Code: Select all

isReddish(p_rgb_color){
	; split color:
	_r :=  p_rgb_color        & 255
	_g := (p_rgb_color >> 8)  & 255
	_b := (p_rgb_color >> 16) & 255
	
	; totally deliberate definition of reddish: red channel must be 1.5 times of the sum of green & blue
	Return, _r > (_g + _b) * 1.5
}

; ...

Loop
	PixelGetColor, colorFound, x1, y1, RGB
until isReddish(colorFound)
MouseClick, left
UZIEL7717
Posts: 20
Joined: 26 Aug 2016, 09:02

Re: commend thats know if its red(all the kind of red)

27 Aug 2016, 06:42

p3trus wrote:
UZIEL7717 wrote:what i need to put in color1 to make it only red ..
can you help me and chang it for me please
only red would be
- 0x0000FF if you use PixelGetColor the way you do (BGR format)
- 0xFF0000 if you use PixelGetColor with the additional , RGB parameter

Otherwise you have to specify a custom function to test, e.g.

Code: Select all

isReddish(p_rgb_color){
	; split color:
	_r :=  p_rgb_color        & 255
	_g := (p_rgb_color >> 8)  & 255
	_b := (p_rgb_color >> 16) & 255
	
	; totally deliberate definition of reddish: red channel must be 1.5 times of the sum of green & blue
	Return, _r > (_g + _b) * 1.5
}

; ...

Loop
	PixelGetColor, colorFound, x1, y1, RGB
until isReddish(colorFound)
MouseClick, left

Code: Select all

F1::pause, toggle

F3::
Loop,
{
CoordMode, Pixel, Screen
x1:=960
y1:=540

isReddish(p_rgb_color){
	; split color:
	_r :=  p_rgb_color        & 255
	_g := (p_rgb_color >> 8)  & 255
	_b := (p_rgb_color >> 16) & 255
	
	; totally deliberate definition of reddish: red channel must be 1.5 times of the sum of green & blue
	Return, _r > (_g + _b) * 1.5
}

; ...

Loop
	PixelGetColor, colorFound, x1, y1, RGB
until isReddish(colorFound)
MouseClick, left
}

return




; ...

its still dont work for red
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: commend thats know if its red(all the kind of red)

27 Aug 2016, 07:26

UZIEL7717 wrote: what i need to put in color1 to make it only red ..
Like this?

Code: Select all

makeRed(color)
{
	; Input color: 0xRRGGBB
	; Output: 0xRR0000
	; R,G,B ∈[ 0,...,9,A,...,F]
	return color >> 16 << 16 
}
; Edit: or
extractRedComponent(color)
{
	; Input color: 0xRRGGBB
	; Output: RR
	; R,G,B ∈[ 0,...,9,A,...,F]
	return color >> 16
}
p3trus
Posts: 137
Joined: 02 Aug 2016, 03:20

Re: commend thats know if its red(all the kind of red)  Topic is solved

27 Aug 2016, 09:33

UZIEL7717 wrote:its still dont work for red

Code: Select all

; define the following only once:
CoordMode, Pixel, Screen
isReddish(p_rgb_color){
	; split color:
	_r :=  p_rgb_color        & 255
	_g := (p_rgb_color >> 8)  & 255
	_b := (p_rgb_color >> 16) & 255
	
	; totally deliberate definition of reddish: red channel must be 1.5 times of the sum of green & blue
	Return, _r > (_g + _b) * 1.5
}


F1::pause, toggle

F3::
; if those coords never change, define them in the very top section, but in any case outside of the following loop
x1:=960
y1:=540

Loop,	; do you want to run this endlessly? otherwise this loop is bogus
{
	Loop
		PixelGetColor, colorFound, x1, y1, RGB
	until isReddish(colorFound)
	MouseClick, left		; <<<<< #### most likely you have to adjust that to the right position - this command clicks at the *current mouse position*
}
Return
If it STILL does not work - please provide more details about what you actually want to do with your script; maybe even some screenshots showing what you want to detect, which colors are occuring there, and what it's supposed to do.
UZIEL7717
Posts: 20
Joined: 26 Aug 2016, 09:02

Re: commend thats know if its red(all the kind of red)

27 Aug 2016, 12:15

p3trus wrote:
UZIEL7717 wrote:its still dont work for red

Code: Select all

; define the following only once:
CoordMode, Pixel, Screen
isReddish(p_rgb_color){
	; split color:
	_r :=  p_rgb_color        & 255
	_g := (p_rgb_color >> 8)  & 255
	_b := (p_rgb_color >> 16) & 255
	
	; totally deliberate definition of reddish: red channel must be 1.5 times of the sum of green & blue
	Return, _r > (_g + _b) * 1.5
}


F1::pause, toggle

F3::
; if those coords never change, define them in the very top section, but in any case outside of the following loop
x1:=960
y1:=540

Loop,	; do you want to run this endlessly? otherwise this loop is bogus
{
	Loop
		PixelGetColor, colorFound, x1, y1, RGB
	until isReddish(colorFound)
	MouseClick, left		; <<<<< #### most likely you have to adjust that to the right position - this command clicks at the *current mouse position*
}
Return
If it STILL does not work - please provide more details about what you actually want to do with your script; maybe even some screenshots showing what you want to detect, which colors are occuring there, and what it's supposed to do.
the script you give me work but not for red.
only for blue and purple .. i need it click only red(yellow and orange also good) not purple blue
there is screenshots on colors i try :
https://s16.postimg.org/4gxg7tebp/png.png
the script you gave me click only on the colors i type "work"
UZIEL7717
Posts: 20
Joined: 26 Aug 2016, 09:02

Re: commend thats know if its red(all the kind of red)

27 Aug 2016, 12:19

Helgef wrote:
UZIEL7717 wrote: what i need to put in color1 to make it only red ..
Like this?

Code: Select all

makeRed(color)
{
	; Input color: 0xRRGGBB
	; Output: 0xRR0000
	; R,G,B ∈[ 0,...,9,A,...,F]
	return color >> 16 << 16 
}
; Edit: or
extractRedComponent(color)
{
	; Input color: 0xRRGGBB
	; Output: RR
	; R,G,B ∈[ 0,...,9,A,...,F]
	return color >> 16
}
hey again can you add this click colors red only here :

Code: Select all

F1::pause, toggle

F3::
Loop,
{
CoordMode, Pixel, Screen
x1:=960
y1:=540


color1:=0xbe7367


repeat:
Loop
	PixelGetColor,colorFound,x1,y1,
until (colorFound=color1 ||)
MouseClick, left
}

return


Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: commend thats know if its red(all the kind of red)

27 Aug 2016, 12:30

I don't mean to be neither thick nor rude here, but you have yet to make a clear definition of what you consider to be red, you said there's more than 6k reds, I don't know which 6k red you mean. I can't help you with the information I have, and I won't make any more guesses. I'm not even sure your latest question is on topic, you have marked the topic as solved.
p3trus
Posts: 137
Joined: 02 Aug 2016, 03:20

Re: commend thats know if its red(all the kind of red)

27 Aug 2016, 12:40

UZIEL7717 wrote:the script you give me work but not for red.
only for blue and purple .. i need it click only red(yellow and orange also good) not purple blue

d'oh... :oops: :oops: :oops:

Sorry, made up a wrong test func, confused RGB <> BGR myself :oops:

use instead:

Code: Select all

isReddish(p_rgb_color){
	; split color:
	_r := (p_rgb_color >> 16) & 255
	_g := (p_rgb_color >> 8)  & 255
	_b :=  p_rgb_color        & 255

	; totally deliberate definition of reddish: red channel must be 1.5 times of the sum of green & blue
	Return, _r > (_g + _b) * 1.5
}
(Only difference in getting the _r & _b values)

/edit: the Return, _r > (_g + _b) * 1.5 defines what is seen as red. You can change that to your needs. To exclude 'purplish' colors, add aor change the restriction on the _b blue channel.
eg. Return, _r > (_b * 3) - that allows only colors with the blue component being < 1/3 of the red component [ignoring the green channel completely]

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, mikeyww and 186 guests