Re: automation

Posted by Alec Purdy on February 10, 2009

In Reply to Re: automation posted by Godfather on August 10, 2008

: Lol sorry about the slow reply. What I want to do is check the color of a pixel at certain location (x, y), and if the pixel is 10% brighter than before the last check then it simulates a key press. Then it checks again, and if the pixel has gotten less bright within a few milliseconds (went back down 10%) it starts the process all over. But if the brightness has stayed the same it simulates another key press and then checks to see if the brightness has gone down, again. I really don't know how to do something like this.

This answer is late for the above query, but for the curious this is the way to deal with a moving target like this. What you're trying to do is compare a current value with a previous value, and the previous value is not a fixed value, it's being updated. So you should have two variables for each of the colours: say RO and RC (for Red Original and Red Current).

Start by defining RO at some value, for instance when the program starts you'd set RO:=RC.

Then at the first check you obtain the pixel red value and set RC equal to that value.
Then you compare RC to RO and if it's 10 points higher you get your TRUE logic and go and simulate the key.

Before you get out of the logic loop, you need to update your RO value again, so set RO:=RC again.

Now when you go to the second check of pixel colour you can do the check against the updated RO and can identify if it has reduced the 10 points or if it is remaining at the higher level. Your logic loop would look for RO+10 and for RO-10; for the drop in red level the RO-10 test would return TRUE while RO+10 would return FALSE. If the level stayed at the elevated value then both tests would return FALSE. If it did return to the lower level, the loop resets RO back to the lower level and now it's able to detect an increase. Be sure to do the RO:=RC update within the loop so it happens before the next logic test, otherwise the logic test will see an out-of-date value and will not make the correct decision.

Related articles

       

Follow Ups