This is the test code I came up with when I worked on my idea, which is kind of similar to yours.
Code: Select all
SendMode Input
#NoEnv
#MaxThreadsperHotkey 1
SetBatchLines -1
CoordMode, Screen
Suspend
*e::
BreakLoop = 0
Loop,
{
if (BreakLoop = 1)
break
MouseGetPos, mX, mY
PixelSearch, nX, nY, mX - 150, mY - 150, mX + 150, mY + 150, 0x0000E5, 10, Fast
Soundbeep,400
Sleep,500
if ErrorLevel
Continue
Soundbeep,500,500
Sleep,500
Soundbeep,500,500
Loop
{
if (BreakLoop = 1)
break
MouseGetPos, mX, mY
PixelSearch, nX, nY, mX - 150, mY - 150, mX + 150, mY + 150, 0x0000E5, 10, Fast
Soundbeep,900,100
if ErrorLevel
break
}
}
*e Up::
BreakLoop = 1
Return
*w::
MouseGetPos, nX, nY
PixelGetColor, color, %nX%, %nY%
if !ErrorLevel
MsgBox, Color is %color%
Return
*~CapsLock::
Suspend
Return
*RAlt::
Process, Close, AutoHotKey.exe
Capslock to activate script.
You can get any color value on the screen if you press w. If you press and hold e, you will hear the first loop beeps until your mouse pointer gets close to the color you need, then it starts sending the second loop and if you move mouse away from that color it starts the first loop again. releasing e stops the process.
You can easily modify this to what you need, just remember that you must run gta5 in window for this to work.