this is the code
Code: Select all
init:
#NoEnv
#SingleInstance, Force
#Persistent
#InstallKeybdHook
#UseHook
#KeyHistory, 0
#HotKeyInterval 1
#MaxHotkeysPerInterval 127
traytip,
SetKeyDelay, -1, 1
SetControlDelay, -1
SetMouseDelay, -1
SetWinDelay, -1
SendMode, InputThenPlay
SetBatchLines, -1
ListLines, Off
CoordMode, Pixel, Screen, RGB
CoordMode, Mouse, Screen
PID := DllCall("GetCurrentProcessId")
Process, Priority, %PID%, High
EMCol := 0xc9008d
ColVn := 1
ZeroX := 955
ZeroY := 500
CFovX := 200
CFovY := 200
ScanL := ZeroX - CFovX
ScanT := ZeroY - CFovY
ScanR := ZeroX + CFovX
ScanB := ZeroY + CFovY
targetX := 40
targetY := 40
Loop, {
targetFound := False
if GetKeyState("LButton", "P") or GetKeyState("RButton", "P") {
; search for target pixel in a smaller region around the last known position
PixelSearch, AimPixelX, AimPixelY, targetX-40, targetY-40, targetX+40, targetY+40, EMCol, ColVn, Fast RGB
if (!ErrorLevel) {
targetX := AimPixelX
targetY := AimPixelY
targetFound := True
} else {
PixelSearch, AimPixelX, AimPixelY, ScanL, ScanT, ScanR, ScanB, EMCol, ColVn, Fast RGB
if (!ErrorLevel) {
targetX := AimPixelX
targetY := AimPixelY
targetFound := True
}
}
if (targetFound) {
AimX := targetX - ZeroX
AimY := targetY - ZeroY
DirX := -0.5
DirY := -0.5
if ( AimX > 0 ) {
DirX := 0.5
}
if ( AimY > 0 ) {
DirY := 0.5
}
AimOffsetX := AimX * DirX
AimOffsetY := AimY * DirY
MoveX := Floor(( AimOffsetX ** ( 1 / 2 ))) * DirX
MoveY := Floor(( AimOffsetY ** ( 1 / 2 ))) * DirY
;DllCall ( "mouse_event" , uint , 1 , int , MoveX * 0.5 , int , MoveY , uint , 0 , int , 0 )
DllCall("mouse_event", uint, 1, int , MoveX * 0.5 , int , MoveY , uint , 0 , int , 0)
;DllCall("mouse_event", uint, 1, int, 0, int, CursorOffset, uint, 0, int, 0)
}
}
}
toggle := false
; Hotkey to toggle on/off
\::
toggle := !toggle
if (toggle) {
SoundBeep, 800, 400
}
return
if (targetFound && toggle) {
click down
} else {
click up
}
Paused := False
e::
Pause
Paused := !Paused
if (Paused) {
SoundBeep, 750, 500
}
Return
[Mod actions: Moved to v1 section because posted code is v1. The main section is for v2. Added [code][/code] tags. Please use them yourself when posting code.]