Hello, I think you would be better off looking into loop timers if you want to run more then one loop. AHK can only run one loop at a time so if you wish to run many actions using loops you have to chain the loops together. Here’s an example.
Also, I’ve changed your PixelSearch a bit for the example, you can always change it to whatever you want.
Code: Select all
#SingleInstance Force
#Persistent
F1:: ;This is the hotkey.
Start: ;This is a GLable. It can be use as a timer, so this is also loop timer #one.
{ KeyWait, F1 ;This waits for F1 to come up.
Running := !Running ;This is the toggle switch command.
{ If Running
{ SetTimer, GoManGo, 500 ;this is the command to use a GLabe as a Loop Timer.
SoundBeep, 700, 50
} Else, ;If NOT Running
{ SoundBeep, 300, 75
}
}
} Return
GoManGo: ;This is loop timer #Two.
{ If Running
{ MouseGetPos, X, Y
PixelSearch, x, y, 668, 88, 954, 163, "0xFFFFFF", 10, fast RGB ;Your code 0xC8C6A3
If (ErrorLevel = 0)
{ SoundBeep, 700, 75
ToolTip, Pixel Found!
SetTimer, RemoveToolTip, -500
} Else,
{ SoundBeep, 300, 75
}
} Else,
{ ToolTip, Paused From GoManGo Loop.
SetTimer, RemoveToolTip, -2000 ;wait 1sec.
Sleep, 1000
SetTimer, GoManGo, OFF
}
} Return
RemoveToolTip:
{ ToolTip
SetTimer, RemoveToolTip, OFF
} Return
~Esc::ExitApp ;Kills the script!
And here’s a little tool I like to use for my pixel projects. It will record your mouse location and the pixel color to your clip board just by pressing the right mouse button. Then you just paste it into whatever you want.
Code: Select all
RButton::
While (GetKeyState("RButton", "P"))
{ PixelGetColor, Color, X, Y, RGB, Fast
MouseGetPos, X, Y
Clipboard := Color " PixelGetColor, Color," " "X ", "Y ", RGB Fast" ;OUTPUT = 0x00C2E4 PixelGetColor, Color, 976, 1005, RGB
ToolTip, % "Clipboard Contains `nPixel Color = " Color " " "`nPixel Location X" X " Y" Y " "
SetTimer, RemoveToolTip, -2000
} Return
RemoveToolTip:
{ ToolTip
} Return
~Esc::ExitApp ;Kills the script!