vorg Posted June 25, 2021 Report Share Posted June 25, 2021 Hi everyone, im new to Macro express and im trying to do what many of you may consider a simple task. so im trying to use the get pixel color function, in the manual the macro script example is: Get Pixel If Variable %N[1]% = 255 Text Type: <TAB> 123xyz Else Web Site: https://www.macros.com End If im trying to do something similar, like if this x color is detected in a specific pixel do this chain of command, else do a different chain of command , i already made the commands that i want the macro to execute in both cases, but i still don't know how to make the conditions using the color detection in a specific area of the screen to execute the commands, i don't really knows how this work on macro express i tried different things to figure this out but no luck. thank you for taking time reading and potentialy helping me to figure this out. Quote Link to comment Share on other sites More sharing options...
Cory Posted June 25, 2021 Report Share Posted June 25, 2021 <GET PIXEL COLOR Option="\x01" Rel_To_Screen="TRUE" X="500" Y="500" Destination="%Color%"/> <IF VARIABLE Variable="%color%" Condition="\x00" Value="16777215" IgnoreCase="FALSE"/> <MESSAGEBOX Caption="Result" Message="The color is %color%" Icon="0"/> <ELSE/> <MESSAGEBOX Caption="Result" Message="The color is %color%, not 16777215" Icon="0"/> <END IF/> This text you can paste into your macro. Create an integer variable %color% Get Pixel Color at (500, 500) Relative to Screen into %Color% If Variable %color% Equals "16777215" MessageBox: Result Else MessageBox: Result End If This is what it looks like in the scripting editor. In my case the desired color is 16777215. If the color at 500, 500 is that, it displays the first message. If it isn't, it displays the second message. This is how you use logic with a pixel color. Quote Link to comment Share on other sites More sharing options...
vorg Posted June 25, 2021 Author Report Share Posted June 25, 2021 I did some tests with different colors it's working perfectly thank you a lot for your help, you just saved my life. One last question just by curiosity, the value "16777215" is a decimal value of the color ? Quote Link to comment Share on other sites More sharing options...
Cory Posted June 25, 2021 Report Share Posted June 25, 2021 There's a description it in the "Launch Mouse Locator" section of the help file. It's the decimal display of the hexadecimal value. So if you convert it to hex, you get 6 digits. The first two make 256 combinations because it's 16 squared and that's the value for how much blue. Normally we say "Red Green Blue" for RGB, but it's reversed here as BGR. 2 for blue, 2 for green, and 2 for red. This can be useful as many of the colors vary slightly. But if the blue varies only slightly, the integer value changes much. So one must parse it into the 3 values. I've done this before where I use mathematical operations to get the hex string then I parse the 3 hex values. Then I converted them back to decimal. Now I have distinct values 0-255 for the three component colors and I can apply a tolerance. For instance if the red, green, and blue values are within 2 of the ideal value, I can say I can accept that becasue the color will be visually close. Quote Link to comment Share on other sites More sharing options...
vorg Posted June 26, 2021 Author Report Share Posted June 26, 2021 Oh now i get why i had a wrong decimal value, it's BGR not RGB, didn't knew that the mouse locator was showing the decimal value too, i tough i had to do a conversion in a 3rd party service, at some point in the beginning i had a suspicion that the value the launche mouse locator was showing is the decimal value, but since the conversion services i used were all giving me the same decimal value that was different from the Launche mouse locator was giving me i tough it wasn't the decimal value, now i reversed the 3 values and indeed they give me the same launch mouse locator value. Sir, your teaching was really helpfull to me, thank you again for your time and your knowledge sharing, i really appreciate that. Quote Link to comment Share on other sites More sharing options...
Cory Posted June 26, 2021 Report Share Posted June 26, 2021 You can use External Script to get the hex string. <GET PIXEL COLOR Option="\x01" Rel_To_Screen="TRUE" X="500" Y="500" Destination="%Color%"/> <EXTERNAL SCRIPT Language="VBScript" Dest="%Test%" Script="Wscript.Echo Hex(%color%)" Encoding="0"/> <MESSAGEBOX Caption="Hex Value" Message="%Test%" Icon="0"/> Get Pixel Color at (500, 500) Relative to Screen into %Color% External Script: VBScript MessageBox: Hex Value In this example the message box displays "FFFFFF". To go back from hex "FF" to a decimal, use Wscript.Echo cint("&H%HexValue%") in the script. Don't miss the "&H". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.