Or Operator (||)

Posts 1–15 of 46 · Page 1 of 4
Or Operator (||)
Idk y but this part of my code isn't working. I spent a while trying to figure this out but never did. I want it to check the color of coordinate one and nine. It will then compare the colors of those coordinates to screen_now which is the color of the spot right now. If it does not match the colors then i want it to start rs_event_alert.exe. The problem is that it starts rs_event_alert.exe anyway, even if the statement is true. Here is the code:

Code:
COLORREF tree = RGB(r_pixel_one, g_pixel_one, b_pixel_one);
		COLORREF background = RGB(r_pixel_two, g_pixel_two, b_pixel_two);
		
		int r_2,g_2,b_2;
		int r_3, g_3, b_3;
		int r_4, g_4, b_4;
		pixel3 = GetPixel(hdc, one.x, one.y);
		r_3 = GetRValue(pixel3);
		g_3 = GetGValue(pixel3);
		b_3 = GetBValue(pixel3);
		COLORREF screen_now = RGB(r_3, g_3, b_3);
		if(screen_now != tree || background){system("START rs_event_alert.exe"); system("PAUSE");}
		pixel2 = GetPixel(hdc, eight.x, eight.y);
		r_2 = GetRValue(pixel2);
		g_2 = GetGValue(pixel2);
		b_2 = GetBValue(pixel2);
		if(r_2 == r_targetpix && g_2 == g_targetpix && b_2 == b_targetpix){ autodump();   } 
		Sleep(1500);
if(screen_now != tree && screen_now != background)

assuming you want to start it if screen_now isn't equal to tree and not equal to background.
Thanks [MPGH]Hell_Demon, i might have another question about this program in a little bit. Lol, i feel like something bad is going to happen.
Quote Originally Posted by 258456 View Post
Thanks [MPGH]Hell_Demon, i might have another question about this program in a little bit. Lol, i feel like something bad is going to happen.
Why would it be bad? :L
i meant like it won't work. Ok, so that code did work Thanks HD, but sometimes the color isn't stable, there are changes by like 1 value all the way up to 4 in the RGB's. So obviously i decided to change the range but i am not sure it is working. Here is the code and tell me if it is correct:

Code:
tree = RGB(r_pixel_one > r_pixel_one -20 && r_pixel_one < r_pixel_one +20,
g_pixel_one > g_pixel_one -20 && g_pixel_one < g_pixel_one +20,
b_pixel_one > b_pixel_one -20 && b_pixel_one < b_pixel_one +20);
// and then the same thing for background just too lazy to write it, lol
Would this set it in a range of 40 values for each color value?
use
Code:
char R = (char*)(tree)[0];
char G = (char*)(tree)[1];
char B = (char*)(tree)[2];
char A = (char*)(tree)[3];
then check if its in beween the values u want
sorry HD but i don't get it. why would it be char?
probably pointless at this point but just watch the order of precedence... i use a retarded amount of unnecessary brackets in or and and statements.
can you explain what you mean by your code HD, it looks so simple it's genious. I just don't understand how to use it
*cough* ARGB stand for Alpha Red Green Blue. Each color is represented by one byte. So each color has an intensity that ranges from 0 -255. A char is also 1 byte so it can be used to hold the value of each color element. Alpha controls the transparency and is not a color.

So all the values combined look like:
0xFFFFFFFF <- that would be white
0x000000FF <-that would be black

I forget if the alpha channel is the first or last byte though...

You can even test it yourself with the forums colors. Look:
Test color=#FFFFFF
TestBlack color=#000000
Green color=#00FF00
red color=#FF0000
blue color=#0000FF
thanks for the info why but i already knew this. I just don't understand how to use the code that HD has presented.
Yeh I figured you did, hmm.. let me put it like this, COLORREF is a DWORD, but by casting it he can iterate through it like a string. hence why he is able to use [1] indexes like so, because he casted it as a char*
so how does this apply to my code? can you show me an example of how i can use it? i am really puzzled. I know you are giving me huge hints but i still don't get it.
Quote Originally Posted by 258456 View Post
so how does this apply to my code? can you show me an example of how i can use it? i am really puzzled. I know you are giving me huge hints but i still don't get it.
Hmmm... It's got nothing to do with ur code, just another way of getting the rgb values. So I guess HD never really answered your question...
I just want to know why my last code snippet didn't work.
Posts 1–15 of 46 · Page 1 of 4

Post a Reply

Tags for this Thread

None

Talk with us