Reputation: 23
Here is what i am trying to do,
step 1 get the color of the mouse location
step 2 enter the loop
step 3 get the second color of the new mouse location
step 4 compare the two colors
error = no matter what the output of color 1 or color 2 the script below is stating true.
!^b::
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
sleep, 5000
loop
{
MouseGetPos, MouseX, MouseY
PixelGetColor, color2, %MouseX%, %MouseY%
if (%color%=%color2%)
{
MsgBox, it matchs %color% = %color2%
sleep,5000
}
else
{
MsgBox, It dosnt match %color% != %color2%
sleep, 5000
}
}
Upvotes: 1
Views: 494
Reputation: 2344
Your problem is with if (%color%=%color2%)
Once you declare an if
statement like this, you do not need to enclose variables with the %var%
. Instead, you can replace the line with if (color==color2)
.
Full code:
!^b::
MouseGetPos, MouseX, MouseY
PixelGetColor, color, %MouseX%, %MouseY%
sleep, 5000
loop
{
MouseGetPos, MouseX, MouseY
PixelGetColor, color2, %MouseX%, %MouseY%
if (color==color2)
{
MsgBox, it matchs %color% = %color2%
sleep,5000
}
else
{
MsgBox, It dosnt match %color% != %color2%
sleep, 5000
}
}
Upvotes: 2