fug5333 Posted September 13, 2009 Report Share Posted September 13, 2009 Trying to get a fairly simple macro going. Just don't have a lot of experience in the logic stuff. Want to do something like this: if <color matches hex value> then <run this code> else (color doesn't match) <run this code> end Simple! Quote Link to comment Share on other sites More sharing options...
Brain Virus Posted September 13, 2009 Report Share Posted September 13, 2009 Trying to get a fairly simple macro going. Just don't have a lot of experience in the logic stuff. Want to do something like this: if <color matches hex value> then <run this code> else (color doesn't match) <run this code> end Simple! The logic looks right, what is your question/problem? Quote Link to comment Share on other sites More sharing options...
fug5333 Posted September 13, 2009 Author Report Share Posted September 13, 2009 Question is "how" to do it. I've got it down in the most basic form, but how can I turn that into something that ME understands? Thanks Quote Link to comment Share on other sites More sharing options...
Brain Virus Posted September 13, 2009 Report Share Posted September 13, 2009 Question is "how" to do it. I've got it down in the most basic form, but how can I turn that into something that ME understands? Thanks Here is a little macro with some comments to show you the structure. Pixel_Color_Logic.mex Quote Link to comment Share on other sites More sharing options...
fug5333 Posted September 14, 2009 Author Report Share Posted September 14, 2009 VERY close! I'm hung up at actualy defining the hex value for the color. The site may change, it has one of three posibilities. If it's *green* then <run this macro>, if any other color <run this one>. I can't seem to put the color into a variable and then say something like "if color under mouse is "this" then <do this>" :/ Thanks Quote Link to comment Share on other sites More sharing options...
Brain Virus Posted September 14, 2009 Report Share Posted September 14, 2009 VERY close! I'm hung up at actualy defining the hex value for the color. The site may change, it has one of three posibilities. If it's *green* then <run this macro>, if any other color <run this one>. I can't seem to put the color into a variable and then say something like "if color under mouse is "this" then <do this>" :/ Thanks well does the pixel you need to check always appear at the same spot? if so double click the get pixel command and then launch the mouse locator from the dialog box that pops up. and then you can define where to search for the pixel. that will also tell you what ME sees the pixel color as. Then you just need to find all the colors and plug them into the macro. Quote Link to comment Share on other sites More sharing options...
rberq Posted September 14, 2009 Report Share Posted September 14, 2009 I don't think you can say "if color under mouse". You get a pixel color from specific screen x-y coordinates, independent of where the mouse is. So if you WANT the mouse involved, first GET MOUSE POSITION into Nx, Ny then GET PIXEL COLOR AT Nx, Ny into Nz then IF Nz = [green] etc. etc. Be aware that GET MOUSE POSITION is not instantaneous. If the mouse is moving when the command runs, there may be some "slop" in the position coordinates returned in Nx, Ny. Also, if your macro will run on more than one computer, you may need to check for a range of color values. "Green" is not necessarily the same value on a PC running 16-bit color vs. 24-bit color vs. 32-bit color. The only constants seem to be pure black and pure white. Quote Link to comment Share on other sites More sharing options...
fug5333 Posted September 14, 2009 Author Report Share Posted September 14, 2009 Here's the issue I'm running into. Variable Set String %T1% "4E9258"(The color green I'm looking for) Variable Set String %T2% "3C2610"(The color I don't care about) Get Pixel: Screen Coords: 700,425 into %N1% If Variable %N1% = 0 <macro that I made> End if if Variable %N1% = 1 <macro I made> End if I'm setting the variables into %T1% and %T2% because I *have to*. I'd like to say something like: If (variable) = 4E9258, then run this code If not, then run this code Am I making sense? I'm a little new to ME so spelling stuff out shouldn't hurt. Thanks! Quote Link to comment Share on other sites More sharing options...
rberq Posted September 14, 2009 Report Share Posted September 14, 2009 First, put the colors into integer (N) variables, not text (T) variables. Variable Set Integer %N91% "4E9258"(The color green I'm looking for) Variable Set Integer %N92% "3C2610"(The color I don't care about) And use decimal, not hex values -- you'll have to translate them unless you use the mouse locator tool as Brain Virus suggested to find the actual screen colors. Your next line is OK: Get Pixel: Screen Coords: 700,425 into %N1% But testing N1 for zero or one does nothing for you; it's not a boolean value. Instead, compare it to N91 or N92: If Variable %N1% = %N91% .... Quote Link to comment Share on other sites More sharing options...
fug5333 Posted September 14, 2009 Author Report Share Posted September 14, 2009 I just don't think I'm getting it... Varialble Set Integer. I don't see anything to give it a string of text. Only stuff like date and time and window height/width. *sigh* Quote Link to comment Share on other sites More sharing options...
fug5333 Posted September 14, 2009 Author Report Share Posted September 14, 2009 Okay. Here's what I have, whew.. Variable Set Integer %N1% to 5149272 (4E9258) Variable Set Integer %N2% to 206352 (3C2610) Get Pixel: Window Coords: 700,425 into %N3% If Variable %N1% = variable %N3% <macro stuff> Else <macro stuff> End If It seems to run the 'else' part every time regaurdless. :/ Whew, thanks! Quote Link to comment Share on other sites More sharing options...
rberq Posted September 14, 2009 Report Share Posted September 14, 2009 Right after your GET PIXEL command, put in a temporary debugging statement TEXT BOX DISPLAY and in the body of the text put %N3%. That will show you what color value is actually being found at coordinates 700,425. Quote Link to comment Share on other sites More sharing options...
fug5333 Posted September 14, 2009 Author Report Share Posted September 14, 2009 Ugh!! The color that the website I Google'd was not the same as what ME came up with. Figured out the right color and it's working smoothly. Many thanks to all that helped!! 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.