Jump to content
Macro Express Forums

if/ifend/else.....``


fug5333

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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% ....

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...