I would rather use pixelgetcolor as it looks at a specific pixel (unless it moves around). If there are small shadows, there are some functions that take an area and return an average color value for the window that you might be able to use. But your way can also work.
Untested code:
Code: Select all
f1::
Loop
{
buffcheck()
healteam()
}
Return
f2::
reload
f12::
exitapp
;-------------------------------------------
;functions start here
;-------------------------------------------
buffcheck()
{
Sleep, 50
CoordMode, Pixel, Window
PixelSearch, FoundX, FoundY, 1027, 730, 1039, 746, 0x95940F, 30, Fast RGB
If ErrorLevel = 0
{
Sleep, 50
Send, {q down}
Sleep, 90
Send, {q up}
return
}
if Errorlevel = 1
;msgbox, your party should be buffed - you are looking for the color that indicates that you are not buffed so that you can buff.
return
if Errorlevel = 2
{
msgbox, Pixelsearch could not run.... exiting app.
exit
}
}
;-------------------------------------------
healteam()
{
;your code, similar to the buffcheck() function can go here
return
}
What I have done is added some error checks to your working code, **Always do this** it makes your life more simple when something silly happens so that you know what went wrong immediately. I turned it into a function that you can call from anywhere. Functions are in my mind one of the most valuable tools you can use.
Then in your main program (triggered by F1) we call the function buffcheck() once that is done, the loop continues and calls the healteam() function. When that is done, the loop starts all over again.
F2 reloads the script if it bugs out and F12 will exit the entire thing.