I want it to loop the button A if pixel change is detected on the right side, and I want the D button to be looped when pixel change is detected on the left side.
Problems:
Currently it doesn't seem to switch between the two checks, and all I see is A D A D A D.
What I noticed is that loop within a loop seems to not work quite so well.
Offsets are set correctly and such - it's just that when Check2 is "True", then A should stop being looped, and then switch to pressing D.
Full code:
Code: Select all
AutoPlay = 0
AutoPlay1 = 0
AutoPlay2 = 0
Check1 := if (((R1-Sensitivity)<=R2) && ((R1+Sensitivity)<=R2)) or (((R1-Sensitivity)>=R2) && ((R1+Sensitivity)>=R2)) or (((G1-Sensitivity)<=G2) && ((G1+Sensitivity)<=G2)) or (((G1-Sensitivity)>=G2) && ((G1+Sensitivity)>=G2)) or (((B1-Sensitivity)<=B2) && ((B1+Sensitivity)<=B2)) or (((B1-Sensitivity)>=B2) && ((B1+Sensitivity)>=B2))
Check2 := if (((R3-Sensitivity)<=R4) && ((R3+Sensitivity)<=R4)) or (((R3-Sensitivity)>=R4) && ((R3+Sensitivity)>=R4)) or (((G3-Sensitivity)<=G4) && ((G3+Sensitivity)<=G4)) or (((G3-Sensitivity)>=G4) && ((G3+Sensitivity)>=G4)) or (((B3-Sensitivity)<=B4) && ((B3+Sensitivity)<=B4)) or (((B3-Sensitivity)>=B4) && ((B3+Sensitivity)>=B4))
#MaxThreadsPerHotkey 2
;AutoPlay Stuff
OffsetX:=200
OffsetY:=0
Sensitivity:=5
SplitRGBColor(RGBColour, ByRef Red, ByRef Green, ByRef Blue)
{
Red := RGBColour >> 16 & 0xFF
Green := RGBColour >> 8 & 0xFF
Blue := RGBColour & 0xFF
}
F13::
AutoPlay := !AutoPlay
SoundPlay, %A_ScriptDir%\Autoplay.mp3
Hotkey, *~$Space
return
*~$Space::
While AutoPlay{
loop {
GetKeyState, SpaceState, Space, P
if Spacestate = U
break
MouseGetPos, Pos1X, Pos1Y
PixelGetColor, ColourOne, Pos1X+OffsetX, Pos1Y+OffsetY
SplitRGBColor(ColourOne, R1, G1, B1)
MouseGetPos, Pos2X, Pos2Y
PixelGetColor, ColourTwo, Pos2X+OffsetX, Pos2Y+OffsetY
SplitRGBColor(ColourTwo, R2, G2, B2)
MouseGetPos, Pos3X, Pos3Y
PixelGetColor, ColourThree, Pos3X-OffsetX, Pos3Y+OffsetY
SplitRGBColor(ColourThree, R3, G3, B3)
MouseGetPos, Pos4X, Pos4Y
PixelGetColor, ColourFour, Pos4X-OffsetX, Pos4Y+OffsetY
SplitRGBColor(ColourFour, R4, G4, B4)
if Check1
loop {
Send, a
if Check2
break
}
if Check2
loop {
Send, d
if Check1
break
}
}
}
return
;------------------------------------Exit Script
F18::
SoundPlay, %A_ScriptDir%\ClosingScript.mp3, wait
ExitApp
return