Please, masters of AHK, help me!
Here is the algorithm:
There is a moving circle target of various colors. When you hover over it, red text appears above. When that red text appears, it means the cursor is on target. So 5ms after that instant I want the cursor to lock on the pixel it is situated on for as long as the red text is visible. When red text disappears, unlock cursor and start searching for the red text around the pointer again.
Here is my script that finds the red text when I hold a button:
Code: Select all
#NoEnv
SendMode Input
#MaxThreadsperHotkey 1
SetBatchLines -1
CoordMode, Mouse, Screen
~*LButton::
BreakLoop = 0 ; this section is for breaking the loop
Loop,
{
if (BreakLoop = 1)
{
break
}
Else
Loop,
{
MouseGetPos, mouseX, mouseY ; These two lines check for red color range around the pointer in 150 pixels radius
PixelSearch, rX, rY, mouseX - 150, mouseY- 150, mouseX + 150, mouseY + 150, 0x0B18A2, 35, Fast
}
*LButton Up:: ; break the loop when I release the button
BreakLoop =1
Return
Code: Select all
If ((rX != "") && (rY != "")) ;if the red color is found, move cursor on it. Loop "locks" it by repeating the steps.
MouseMove, %rX%, %rY%