1)When the pixelsearch result is positive, it hits (pressing E), and it stops when this is no longer true.
2) when it is no longer true, keep pressing L
The reason: i trying to do a bot that keep pressing L (to target the enemy), and it targets, pixelsearch gets the enemy life color (red) and keep hitting until this color go out (the enemy dies). When it dies, it go back to pressing L. (I cant count the time it takes to kill the enemy, cuz is a mmo, so it depends on number of players, gears and etc.
The part where it hits when the enemy is target is working fine, but it wont ever press L to target. I feel like is a code logic issue, but cant seem to find the error.
Can anyone help me?
I tried putting a else { Settimer, pressL, 100} after the if. Tried putting a settimer inside the If loop ( but it just stops pressing L when the enemy dies).
Code: Select all
#SingleInstance Force
keydelay = 50
weapondelay = 400
; color b92929
;smallerframe x1y1x2y2: 1114, 74. 1087,105
-::
SetTimer, pressL, 1000
Loop,
{
Sleep, 500
PixelSearch, 1114, 74, 1087, 105, 0xb92929, 5, rgb
if (ErrorLevel = 0)
{
SendEvent {E down}
Sleep, % keydelay
SendEvent {E up}
}
}
return
pressL:
SendEvent {L down}
Sleep, % keydelay
SendEvent {L up}
return