In your script, remove all the % in the PixelSearch command. Read on for the reason why. BTW, how do you plan to end your loop ?
http://www.autohotkey.com/docs/commands/PixelSearch.htm
X1,X2,X3,X4 The X and Y coordinates ... corner(s) of the rectangle to search,
which can be expressions.
http://www.autohotkey.com/docs/Variable ... xpressions
Quote:
Expressions are used to perform one or more operations upon a series of variables, literal strings, and/or literal numbers.
Variable names in an expression are not enclosed in percent signs (except for arrays and other double references). Consequently, literal strings must be enclosed in double quotes to distinguish them from variables.
Just for fun, I changed your search into mousemoves (which also use expressions). With the % in place there was no movement.
Code:
BaseCoord1=147
BaseCoord2=91
BaseCoord3=171 ; +500 ; for testing
BaseCoord4=130
Loop
{
;PixelSearch, Px, Py, %BaseCoord1%, %BaseCoord2%+(42*(a_index-1)), %BaseCoord3%, %BaseCoord4%+(42*(a_index-1)),%Green%, 0, Fast
MouseMove, BaseCoord1, BaseCoord2+(42*(a_index-1)), 10
sleep, 100
MouseMove, BaseCoord3, BaseCoord4+(42*(a_index-1)), 10
}
esc::
exitapp