Need help making an until function (or something similar) work with my script
Posted: 10 Sep 2020, 15:42
currently, i'm trying to make a script that will execute w, a, s, and d randomly for random amounts of time at a random interval until it detects a pixel at the top of the screen is a different color. Then, it will execute 3 button presses, and remain idle until the color changes back to normal. However, when i try to use the script, the script doesnt read the until command and just plays everything in a loop over and over. Is there a way to fix the until command, or replace it with something that works better?
thanks!
Code: Select all
x::
;------------------------------------------------------------------------------------;
x := 680, y := 63, target := "0x007600" ; The target place & color
Sendmode, event
Random, walkoffset , 500, 2000
Random, stopoffset , 50, 300
SetKeyDelay, 10, %walkoffset%
Keys = {w},{a},{s},{d}
StringSplit, key, keys, `,
again: ;label that sends script back to the beginning
loop
{
Random, key, 1, %key0%
Send, % "{blind}" key%key%
Sleep %stopoffset%
} until (x, y, target, False) ;script loops until it sees a color other than green, THIS IS NOT WORKING FOR SOME REASON!!!
SendInput {Esc}
Sleep, 300
SendInput, r
Sleep, 500
SendInput, {Enter}
wait(1000, x, y, target, True) ;waits for the color to return to normal, THIS IS ALSO NOT WORKING!!!
goto again
;------------------------------------------------------------------------------------;
;something i found to detect colors, not really sure what it does but the script seems to break without it
wait(pause, x, y, color, same) { ; Wait until the (x,y) color equals or differs from the stated color
CoordMode, Pixel
done := False
While !done {
PixelGetColor, thisColor, %x%, %y%
done := same = (thiscolor = color)
Sleep, % pause * (1 - done)
}
}
;------------------------------------------------------------------------------------;
f1:: ;the key to toggle the script on and off
Pause
Suspend
return