GetPixelColor and "If" problems

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Fearless
Newbie
Posts: 2
Joined: Thu Jan 25, 2007 8:41 am

GetPixelColor and "If" problems

Post by Fearless » Thu Jan 25, 2007 8:56 am

Basically i want the code to search the area i choose for the color code

if it dosnt find it it i want it to click and release where the mouse has already been placed

if it does find it i want it to move to the spot i picked and click and release

i dont know if i messed up in the pixel command or the if command because i run it i see the color come up but it dosnt mvoe the mouse and end it

here what i got so far

Let>Colors[112,380]=
Let>XStart=105
Let>XStop=121
Let>YStart=372
Let>YStop=386
GetPixelColor>x,y,color:EFEF10
IF>color=EFEF10
//MouseMove>611,493
wait>2
LClick
LUp
Else
LClick
LUp
wait>1

Also is there a way to range the pixel color you want so its not an exact color because what i want it to search someitmes isnt a solid object so it changes slightly in color from each pixel

any help much appreciated and iam sure ill have more questions later as to iam very new to this.

Fearless
Newbie
Posts: 2
Joined: Thu Jan 25, 2007 8:41 am

Post by Fearless » Thu Jan 25, 2007 2:49 pm

I searched alot and have not came up with what iam looking for...

This is what i have..

label>loop1
LClick
LUp
Let>color=40000
Let>XStart=105
Let>XStop=121
Let>YStart=372
Let>YStop=386
GetPixelColor>x,y,color
if>(%color%=5000000)
//MouseMove>611,493
wait>2
LClick
LUp
Else
wait>1
goto>loop1

Basically i need it to search the area i picked out (if i set that up right that might be a problem) and search for colors between those numbers and if its true move mouse to 611,493 and click if not i want it to reloop. it goes through and gets here fine but i can see the area i pick show up with the color but its not reconisging it or scanning it or the command i made isnt right. thanks <3

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Jan 26, 2007 3:00 pm

There are a number of problems with your code. The biggest is that you have a loop, but no way to increment the x and y values, so it will loop, but always test the same pixel. I think you have the confused in the If> (assuming you want to test if the color is between 40000 and 5000000), and that needs to be formatted as a complex expression.

The following is not fully tested but should give you enough of a start to make it work. I suggest uncommenting the message, and test with a small x y range (such as the values in this code) to see how it works.


//set XStop to the last column (x) to be scanned + 1
Let>XStop=106
//set Ystop to the last row (y) to be scanned
Let>YStop=205
//set y to the start row
Let>y=200
//start the big loop
Label>loopstart
//set x to the start column
Let>x=100
//this inner repeat loop scans in the x direction
Repeat>x
GetPixelColor>x,y,color
//drop out of the loop to dostuff if the color is in the range
//else just execute the next command
If>{(%color%>40000) AND (%color% x=x%x% y=%y%
Let>x=x+1
Until>x=XStop
//last x value has been used, check if on last row and if so end macro
If>y=Ystop,theend
//otherwise move to next row
Let>y=y+1
//and repeat the loop
Goto>loopstart
//if the color matched the code here will be executed
Label>dostuff
MouseMove>611,493
wait>2
LClick
LUp
//show's over
Label>theend

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