So, I am trying to learn AHK to use at work. In this little test I am running I was trying to get MSpaint to pick a different Brush, so I got the Basics of it, my problem is I don't want to have to past this long code each time I want to make it pick a brush, so I read about Labels and GoSub, So I made at the start of the script put this code in, but problem is that every time I run the script it runs that part it picks a brush. Then sits and waits, and will run the next part when I press the hotkey. So what I was wondering is there a way to not have it run the label until it is called up by the GoSub, do I have to put all labels at the end? Am I doing this all the wrong way? I thought maybe a function but there are not var to be put in. So seemed not right. I am sorry if this is been asked before, I searched, but could not find the right set of keywords on google or the forums to find a solution. Thanks in advance.
Code: Select all
Brush:
MouseClick, Left, 332, 104
Sleep, 500
Random, zBrush, 1, 9
IfEqual, zBrush, 1
{
MouseClick, Left, 335, 137
Sleep, 100
}
IfEqual, zBrush, 2
{
MouseClick, Left, 375, 137
Sleep, 100
}
IfEqual, zBrush, 3
{
MouseClick, Left, 415, 137
Sleep, 100
}
IfEqual, zBrush, 4
{
MouseClick, Left, 455, 137
Sleep, 100
}
IfEqual, zBrush, 5
{
MouseClick, Left, 335, 177
Sleep, 100
}
IfEqual, zBrush, 6
{
MouseClick, Left, 375, 177
Sleep, 100
}
IfEqual, zBrush, 7
{
MouseClick, Left, 415, 177
Sleep, 100
}
IfEqual, zBrush, 8
{
MouseClick, Left, 455, 177
}
IfEqual, zBrush, 9
{
MouseClick, Left, 335, 217
Sleep, 100
}
Return
9::
Loop, 5
{
Random, X3, 765, 962
Random, Y3, 64, 85
MouseClick, Left, X3, Y3 ; Picks a color
Sleep, 100
GoSub Brush ; Picks a brush
Return
}