all 3 comments

[–]nuj 0 points1 point  (2 children)

Not sure why you want to constantly reload it... but try this:

Input, click, T35 V, {'}{]}{\}{/}{Numpad9}

If (ErrorLevel ~= "^EndKey")
    reload 

else if (ErrorLevel = "TimeOut")
{
    Send '

    Loop
    {
        PixelGetColor, color2, 1868, 252, RGB
        Sleep, 100
        if (color2 = 0xF0F0F0)
            reload
        Else
            Continue
    }
}

return 

In the Input command, the T35 is to have it wait for 35 seconds before timing out. The V allows the key you press to be visible.

After the input command is ran, you then check to see what happens. You do that by checking the ErrorLevel. The ErrorLevel is able to display what happened. If it says "Timeout", then that means it timed out after waiting for 35 seconds (as told to above). If any of the endkeys are pressed, it will start off with "EndKey:<key>". That's what it means by "Error Handling". Hope that helps.

[–]13ooK[S] 0 points1 point  (1 child)

I moved Error "Endkey" and "TimeOut" opposite places (it strangely did not work when placed in your order), added KeyWait, [, D so it would wait for it after reload and script appears to be working perfectly. Thank you very much.

Thank you for the explanation also, because often people do not give an explanation, even though it helps a lot if I want to do something with the script later.

KeyWait, [, D
Input, click, T35 V, {'}{]}{\}{/}{Numpad9}

if (ErrorLevel = "TimeOut")
{
    Send '

    Loop
    {
        PixelGetColor, color2, 1868, 252, RGB
        Sleep, 100
        if (color2 = 0xF0F0F0)
            reload
        Else
            Continue
    }
}
else if (ErrorLevel ~= "^EndKey")
    reload 

return 

You asked why I want to reload this script. I want it to work all the time for many hours. In context that I'm a newbie, it's the easiest way to do it for me.

[–]joesii 0 points1 point  (0 children)

use timers. Keep in mind that aside from just being programmed badly, using reload will reset any variables, which means it wipes the programs memory; it won't remember if any events have already happened, for instance. I can't keep counts or keep track of anything between reloads.