Code: Select all
^+f::
ExitApp
^c::
BreakLoop = 1
return
+c::
loop
{
if BreakLoop = 1
break
IfWinActive, Game Window
{
WinGetActiveStats, Title, GameWidth, GameHeight, GameX, GameY
PixelSearch, , , (GameWidth * 4 / 5), 0, GameWidth, (GameHeight * 11/20), 0xFF00FF, 0, Fast
If ErrorLevel = 0
{
MouseClick, left, (GameWidth // 2), (GameHeight // 2)
Sleep 21
} else {
PixelSearch, , , 0, 0, GameWidth, (GameHeight * 2/15), 0x1E1E1E, 1, Fast
If ErrorLevel = 0
Loop
{
GetKeyState, M1, LButton, P
If M1 = U
Break
Send {LButton}
Sleep 95
}
}
}
}
BreakLoop = 0
return
Regardless. When I run it as presented, part of it runs fine - this bit right here.
Code: Select all
PixelSearch, , , (GameWidth * 4 / 5), 0, GameWidth, (GameHeight * 11/20), 0xFF00FF, 0, Fast
If ErrorLevel = 0
{
MouseClick, left, (GameWidth // 2), (GameHeight // 2)
Sleep 21
}
Code: Select all
else {
PixelSearch, , , 0, 0, GameWidth, (GameHeight * 2/15), 0x1E1E1E, 1, Fast
If ErrorLevel = 0
Loop
{
GetKeyState, M1, LButton, P
If M1 = U
Break
Send {LButton}
Sleep 95
}
}
Basically, what happens in the first bit, is when it sees that color in the given portion of the screen, then it clicks the center of the window repeatedly as long as the given colors are in the given portion.
The second is supposed to be a separate check entirely, and I probably could just make it a separate if check itself, and that might fix it, but I don't know the extents to which the colors that the given window will have, so I'd rather avoid having both of them trigger at the same time, hence the use of the else.
Anyways, what the second part itself is supposed to do, is check if there's a certain color at the top-ish of the screen, and if there is, make it so when you hold down left mouse, it'll click ~10 times a second for you. It doesn't do that, however.
Now for the part that's exceedingly confusing to me: If I switch the hex codes that it searches for with each other, then both of them work in the areas that you would expect them to. I have absolutely no idea why and I'm hoping for someone to be able to tell me what I messed up.