pixel range problem Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ronney tan

pixel range problem

03 Sep 2018, 14:12

I am trying to get a message-box popup if the color in the area 426,686 is any shade of black. My code fails badly :thumbdown: , how can I get any shade of black?

Code: Select all

^q::
PixelGetColor, colorA, 426, 686,
    if (colorA >= "0x000000" ) AND (colorA <= "0x010101" )
msgbox, a shade of black
exitapp
User avatar
rommmcek
Posts: 1478
Joined: 15 Aug 2014, 15:18

Re: pixel range problem

03 Sep 2018, 18:27

Color is pure Black, Gray or White if its components (RGB) are equal.
So try:

Code: Select all

if ((colorA>>16)=(colorA>>8&0xff))&&((colorA>>16)=(colorA&0xff)) ;&&(colorA<0x010101) ; limit the allowed brightness
	msgbox, a shade of black
ronney tan

Re: pixel range problem

03 Sep 2018, 18:53

rommmcek wrote:Color is pure Black, Gray or White if its components (RGB) are equal.
So try:

Code: Select all

if ((colorA>>16)=(colorA>>8&0xff))&&((colorA>>16)=(colorA&0xff)) ;&&(colorA<0x010101) ; limit the allowed brightness
	msgbox, a shade of black
thank you , that gave me a lot of not black items, i want black and dark grey more
User avatar
rommmcek
Posts: 1478
Joined: 15 Aug 2014, 15:18

Re: pixel range problem  Topic is solved

04 Sep 2018, 02:42

How much black/dark items do you want? Just uncomment "limit the allowed brightness" and you'll get black and only one (the darkest) shade of gray: 0x010101 - providing you correct my typo to: (colorA<=0x010101). This is the limit you set in your code above. If you want to allow more shades just increase the number to e.g.: 0x333333 or what ever you want. (Note that 0xffffff would be the same as now)

bye!
Edit: Not very well explained, true? This one might be better:

Code: Select all

RcolorA:=colorA>>16, GcolorA:=colorA>>8&0xff, BcolorA:=colorA&0xff
if (RcolorA=GcolorA)&&(RcolorA=BcolorA)&&(colorA<0xffffff) ; to limit the brightness decrease 0xffffff to e.g. 0x333333 or the like.
   MsgBox % colorA " is black or shade of black"
Edit2: Actually your code isn't too bad neither! Adding the format:

Code: Select all

SetFormat, integer, Hex
if (colorA >= "0x000000" ) AND (colorA <= "0x010101" )
   msgbox, a shade of black
works fine, it just doesn't allow more shades!
Edit3: More shades you can get with a bit alterring it:

Code: Select all

if (colorA=0x000000)||(colorA=0x010101)||(colorA=0x020202) ;||(colorA=0x030303) ; etc
No need to use format!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest and 309 guests