Check pixel in loop many times

Ask gaming related questions (AHK v1.1 and older)
luizcp
Posts: 1
Joined: 15 Dec 2017, 16:11

Check pixel in loop many times

15 Dec 2017, 16:41

Hi, I'm new here, I have no experience but I'm trying to learn.

Basically I am trying to make a script that checks if the screen is stopped by some error or popup of a flash game (in browser), checking some pixels on the screen and comparing if it is the same color some time later, if it is, send a command to refresh the browser.

I was part of the script however, I realize that the screen itself sometimes repeats the same pixels on occasion, which ends updating the page unnecessarily, which makes it necessary for this check sometimes (for example 3-5 times), I think I can Repeating the check inside the if several times, however, as I'm learning, I believe I have a way to wipe the script by doing a counter or something like that within a loop, in case I ask for this check many times before giving the refresh command, which would make the script very large and repetitive. Would you have some way to do the same check several times and if all positive or negative it leaves the loop?

As I said I'm new, I hope it was clear, I'm trying to improve myself, I thought the while loop could solve, however I could not implement the same script as I wanted, I do not think I understood its function correctly.

Thanks!

Code: Select all

Loop
{
PixelGetColor, initialcolour1, 250, 380, RGB ; Finds Colour
PixelGetColor, initialcolour2, 692, 385, RGB ; Finds Colour
PixelGetColor, initialcolour3, 1169, 450, RGB ; Finds Colour
PixelGetColor, initialcolour4, 770, 672, RGB ; Finds Colour
Sleep, 10000
PixelGetColor, currentcolour1, 250, 380, RGB ; Checks Colour
PixelGetColor, currentcolour2, 692, 385, RGB ; Checks Colour
PixelGetColor, currentcolour3, 1169, 450, RGB ; Checks Colour
PixelGetColor, currentcolour4, 770, 672, RGB ; Checks Colour
if (initialcolour1 = currentcolour1 && initialcolour2 = currentcolour2 && initialcolour3 = currentcolour3 && initialcolour4 = currentcolour4){
;here would be the command (send f5 or click in refresh)
				   }

else {
Sleep, 1000
}}
return
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: Check pixel in loop many times

16 Dec 2017, 11:23

luizcp wrote:Hi, I'm new here, I have no experience but I'm trying to learn.

Basically I am trying to make a script that checks if the screen is stopped by some error or popup of a flash game (in browser), checking some pixels on the screen and comparing if it is the same color some time later, if it is, send a command to refresh the browser.

I was part of the script however, I realize that the screen itself sometimes repeats the same pixels on occasion, which ends updating the page unnecessarily, which makes it necessary for this check sometimes (for example 3-5 times), I think I can Repeating the check inside the if several times, however, as I'm learning, I believe I have a way to wipe the script by doing a counter or something like that within a loop, in case I ask for this check many times before giving the refresh command, which would make the script very large and repetitive. Would you have some way to do the same check several times and if all positive or negative it leaves the loop?

As I said I'm new, I hope it was clear, I'm trying to improve myself, I thought the while loop could solve, however I could not implement the same script as I wanted, I do not think I understood its function correctly.

Thanks!

Code: Select all

Loop
{
PixelGetColor, initialcolour1, 250, 380, RGB ; Finds Colour
PixelGetColor, initialcolour2, 692, 385, RGB ; Finds Colour
PixelGetColor, initialcolour3, 1169, 450, RGB ; Finds Colour
PixelGetColor, initialcolour4, 770, 672, RGB ; Finds Colour
Sleep, 10000
PixelGetColor, currentcolour1, 250, 380, RGB ; Checks Colour
PixelGetColor, currentcolour2, 692, 385, RGB ; Checks Colour
PixelGetColor, currentcolour3, 1169, 450, RGB ; Checks Colour
PixelGetColor, currentcolour4, 770, 672, RGB ; Checks Colour
if (initialcolour1 = currentcolour1 && initialcolour2 = currentcolour2 && initialcolour3 = currentcolour3 && initialcolour4 = currentcolour4){
;here would be the command (send f5 or click in refresh)
				   }

else {
Sleep, 1000
}}
return
Hey,

You can try this https://www.autohotkey.com/docs/commands/Else.htm
Or you post your Script here https://autohotkey.com/boards/viewforum.php?f=5

Hope you get it :)

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Rohwedder, yuu453 and 98 guests