how to reduce screen shakeing from a loop PixelSearch
Posted: 12 Aug 2019, 11:46
hi i just start using ahk to help me aiming at target in a game
so i search google for a script and modify it for personal use and offline game
(im not recommended this for anyone to cheating in an online game)
the problem is it shaking pretty bad and sometime this script just random go crazy (crosshair move to nowhere)
i try to find many way to reduce the shaking but whatever i do it just does not work
please someone who has knowledge . help me out
god bless you
so i search google for a script and modify it for personal use and offline game
(im not recommended this for anyone to cheating in an online game)
the problem is it shaking pretty bad and sometime this script just random go crazy (crosshair move to nowhere)
i try to find many way to reduce the shaking but whatever i do it just does not work
please someone who has knowledge . help me out
god bless you
Code: Select all
; Part 1 - i only know what some of this do not all of them
#NoEnv
#InstallMouseHook
#InstallKeybdHook
#UseHook
#MaxHotkeysPerInterval 99999999999999999999999
CoordMode, Pixel, Screen, RGB
CoordMode, Mouse, Screen
SendMode InputThenPlay
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
PID := DllCall("GetCurrentProcessId")
Process, Priority, %PID%, Realtime
; Part 2
EMCol := 0xCE0C0C ;CE0C0C
ColVn := 20 ;30
ZeroX := 960
ZeroY := 540
CFovX := 440
CFovY := 120 ; i want this only 120
ScanL := ZeroX - CFovX
ScanR := ZeroX + CFovX
ScanT := ZeroY - CFovY
ScanB := ZeroY + CFovY
;part 3
~rbutton::
loop
{
if getkeystate("rbutton","p")
{
PixelSearch, AimPixelX, AimPixelY, ScanL, ScanT, ScanR, ScanB, EMCol, ColVn, Fast RGB
If ErrorLevel = 0
DllCall("mouse_event", "UInt", 0x02) ; i want to hold not repeat
GoSub GetAimOffset
GoSub GetAimMoves
GoSub MouseMoves
}
else
break
}
keywait rbutton
DllCall("mouse_event", "UInt", 0x04) ; release
GetAimOffset:
AimX := AimPixelX - ZeroX
AimY := (AimPixelY+60) - ZeroY ; i dont want Y at center but cant find a way better than +60 here(i want it automatic calculate but i dont know how)
If ( AimX > 0 ) {
DirX := 1
}
If ( AimX < 0 ) {
DirX := -1
}
If ( AimY > 0 ) {
DirY := 1
}
If ( AimY < 0 ) {
DirY := -1
}
AimOffsetX := AimX * DirX
AimOffsetY := AimY * DirY
Return
GetAimMoves:
RootX := Ceil(( AimOffsetX ** ( 1 / 2 ) ))
RootY := Ceil(( AimOffsetY ** ( 1 / 2 ) ))
MoveX := RootX * DirX
MoveY := RootY * DirY
Return
MouseMoves:
DllCall("mouse_event", uint, 1, int, MoveX, int, MoveY, uint, 0, int, 0)
sleep 1
Return