Here is my idea:
1.PixelGetColor the color at 724,310
2.end F8 to start my program
3.Gosub color
4.PixelGetColor the the color at 724,310 every second.
5.if the color changed, back to the main code.
But it looks my code doesn't work, is there somehing wrong ?
Thanks in advance
========================================================
....main code....
PixelGetColor,color-before,724,310,RGB
Sleep, 200
Send, {F8}
Sleep, 5000
Gosub, color
Sleep, 1000
....main code....
color:
loop
{
PixelGetColor,color-after,724,310,RGB
if (color-before = color-after)
{
sleep,1000
Continue
}
else
{
break
}
}
return
why PixelGetColor doesn't work here ? Topic is solved
Re: why PixelGetColor doesn't work here ?
try using "color_before" and "color_after"
Re: why PixelGetColor doesn't work here ?
It works if you make them valid variable names (dashes are not allowed but underscores are). Also make sure you set CoordMode as necessary.
By the way, you may want to make use of while and until in your loops rather than making the equivalent of them with if/else/break. The following is equivalent to yours (well, mostly equivalent; it does sleep whether the condition is true or not, but that can be accounted for):
Edit: Just saw @John's post. The other information may be useful.
By the way, you may want to make use of while and until in your loops rather than making the equivalent of them with if/else/break. The following is equivalent to yours (well, mostly equivalent; it does sleep whether the condition is true or not, but that can be accounted for):
Code: Select all
loop
{
PixelGetColor,color_after,724,310,RGB
sleep,1000
} until color_before != color_after
Re: why PixelGetColor doesn't work here ?
Thank you so mcuh, Now it is great workingboiler wrote: ↑02 Oct 2019, 08:46It works if you make them valid variable names (dashes are not allowed but underscores are). Also make sure you set CoordMode as necessary.
By the way, you may want to make use of while and until in your loops rather than making the equivalent of them with if/else/break. The following is equivalent to yours (well, mostly equivalent; it does sleep whether the condition is true or not, but that can be accounted for):Edit: Just saw @John's post. The other information may be useful.Code: Select all
loop { PixelGetColor,color_after,724,310,RGB sleep,1000 } until color_before != color_after
Re: why PixelGetColor doesn't work here ?
Dear @boiler
Thank you so much for your kind help, but I got another problem.
this code in first loop is very good, It will display the clolor difference in first loop.
but in the next loops, it will display the clolor difference every 2 second nomatter the color changed or not.
here is my code.
Thank you so much for your kind help, but I got another problem.
this code in first loop is very good, It will display the clolor difference in first loop.
but in the next loops, it will display the clolor difference every 2 second nomatter the color changed or not.
here is my code.
Code: Select all
loop
{
PixelGetColor,color_before,724,310,RGB
Sleep, 2000
Gosub, color
MsgBox, color_before= %color_before%. color_after= %color_after%
}
color:
{
loop
{
PixelGetColor,color_after,724,310,RGB
if (color_before = color_after)
{
sleep,1000
Continue
}
else
{
break
}
}
}
return
Re: why PixelGetColor doesn't work here ?
I don't understand what your question is. The second loop doesn't display colors, it just loops until the colors are different and returns to the first loop, which then displays the colors. Do you want it to display the colors every 2 seconds whether they have changed or not?
Re: why PixelGetColor doesn't work here ?
boiler wrote: ↑04 Oct 2019, 08:08I don't understand what your question is. The second loop doesn't display colors, it just loops until the colors are different and returns to the first loop, which then displays the colors. Do you want it to display the colors every 2 seconds whether they have changed or not?
Code: Select all
loop
{
PixelGetColor,color_before,646,362,RGB
Sleep, 2000
loop
{
PixelGetColor,color_after,646,362,RGB
sleep,1000
} until color_before != color_after
MsgBox, new color is %color_after%
}
But I have a question regarding this code:
if the color of 646,362 changed one time when code is runing, will this code display one time MsgBox message or it will display MsgBox message every three second ?
I thought it will display only one time MsgBox message, But I am wrong, I find it will display MsgBox message every three second....
So I am very confused. color_before and color_after are the same in the next loop after color changing. this code should keep quiet until color change again ?
could you please help me on it ?
Thank you so much
Re: why PixelGetColor doesn't work here ? Topic is solved
It's really pretty simple. Just add another loop after the first one that keeps checking the color at that pixel until it's the same as color_before again:
Code: Select all
loop
{
; keep checking until pixel color changes then report it:
PixelGetColor,color_before,646,362,RGB
Sleep, 2000
loop
{
PixelGetColor,color_after,646,362,RGB
sleep,1000
} until color_before != color_after
MsgBox, new color is %color_after%
; wait until color is the same again before continuing outer loop:
loop
{
PixelGetColor,color_after,646,362,RGB
sleep,1000
} until color_before = color_after
}