IF Color = ???

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Alluziion
Newbie
Posts: 2
Joined: Fri Feb 17, 2012 7:32 pm

IF Color = ???

Post by Alluziion » Fri Feb 17, 2012 7:41 pm

I'm new to this software but I can see the potential is incredible and has a great deal of depth and detail in comparison to software of a similar nature. I've already began writing a small script but have ran into a brick-wall which I believe is easily over-come with some alterations to my code.

Basically what I'm trying to achieve is as follows...

o Get pixel color at co-ordinates 820,150
o Is the pixel color equal to #006699
o If it is then perform an action, wait, then continue to the rest of the script
o If the pixel color does NOT equal #006699 then ignore the rest of the IF conditions and proceed with the rest of the script

Here's my code so far (I believe the problem lies with the conditions to check if the color is #006699)...

Code: Select all

GetPixelColor>820,150,color
IF>color=#006699
  Wait>0.19
  MouseMove>15,42
  Wait>0.20
  LClick
  Wait>2.00
ENDIF

//The rest of script starts here...
Hope this enough information; thanks in advance! :)

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Feb 17, 2012 8:54 pm

Macro Scheduler colors are not in a hexidecimal format so you would need to convert the hex color to the proper format

Code: Select all

VBSTART
VBEND

GetPixelColor>820,150,color

//Set hex color to a variable
//Leave off the "#" its not needed.
Let>Hex_Color=006699

//break up the number into its hex components
Midstr>Hex_Color,1,2,Hexred
Midstr>Hex_Color,3,2,Hexgrn
Midstr>Hex_Color,5,2,Hexblu

//convert each hex component to a decimal component
VBEval>CLng("&h" & "%Hexred%"),red
VBEval>CLng("&h" & "%Hexgrn%"),grn
VBEval>CLng("&h" & "%Hexblu%"),blu

//Use the decimal components to produce a Maco Scheduler color number
RGB>red,grn,blu,test_color

//Compare the pixel color number to the converted color number
IF>%color%=%test_Color%
  Wait>0.19
  MouseMove>15,42
  Wait>0.20
  LClick
  Wait>2.00
ENDIF

//The rest of script starts here...

Alluziion
Newbie
Posts: 2
Joined: Fri Feb 17, 2012 7:32 pm

Post by Alluziion » Fri Feb 17, 2012 9:26 pm

It worked! :D

That's some advanced scripting there :shock:
Thanks for writing it out and describing each step with comments, it will help me study it.

Also, I gave you +10 rep. Would have given more but don't know how often it refreshes :/

EDIT: I think I see now, the rep comes from your own and passes on to the receiver right?

Thanks again!

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

hello

Post by PepsiHog » Sat Feb 18, 2012 8:21 pm

@JRL

I love the vbScript! But you may not be entirely correct. You see, I woke up today and decided I wanted to know how to "decode" the color number that is used throughout MS. So I did some research.

I found that the number is created by a couple of steps. First change each of the RGB numbers to hex. (I actually just posted a macro to go from Hex to Dec) Then place R first and G second then B. So if the r is 1 the hex is 01. If the g is 16 the hex is 10. If the b is 0 then the hex is 00. So your hex number is 011000. If you convert that to decimal it is 69632. Which matches with MS as the same color.

Plus if you run Paint in WinXP the basic colors rgbs match as well. So am I mistaking about this?

Here are the websites I used to learn about this.

http://www.mathsisfun.com/hexadecimal-d ... olors.html

http://easyguyevo.hubpages.com/hub/Conv ... to-Decimal

http://www.binaryhexconverter.com/hex-t ... -converter

http://www.netlingo.com/tips/color-guide.php

So far as I see, the numbers do jive with MS. Please let me know what you find.

EDIT - Maybe I didn't follow you when I first read your post. Now I am thinking we might be saying the same thing only in different ways.

All the same, I'm curious.

EDIT - Yep. I was mistaking your post. Like I've said before I'm CRAZY!! You are correct. Sorry. But this also should help others. You are going from MS color backward to RGB. I was going RGB to MS color. And what I thought you were saying wasn't really what you were saying.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts