Code:
;#########################
;# Configuration #
;#########################
#NoEnv ; Improves performance and compatibility with future AHK updates.
#SingleInstance force ; It allows to run only one at the same time.
SetTitleMatchMode, 2 ; Matching for window title.
#ifwinactive, PLAYERUNKNOWN'S BATTLEGROUNDS ; enabled only when in PUBG.
;#####################
;# Variables #
;#####################
isMouseShown() ; To suspend script when mouse is visible.
ADS = 0 ; Var for fast aiming.
CrouchJump = 1 ; Var for crouch when jumping.
;########################################
;# Suspendsifmouseisvisible #
;########################################
isMouseShown() ; It suspends the script when mouse is visible (map, inventory, menu).
{
StructSize := A_PtrSize + 16
VarSetCapacity(InfoStruct, StructSize)
NumPut(StructSize, InfoStruct)
DllCall("GetCursorInfo", UInt, &InfoStruct)
Result := NumGet(InfoStruct, 8)
if Result > 1
Return 1
else
Return 0
}
Loop
{
if isMouseShown() ==1
Suspend On
else
Suspend Off
Sleep 1
}
;#######################
;# FastAiming #
;#######################
*RButton:: ; Fast Aiming
if ADS = 1
{ ; If enabled, clicks once and clicks again when button is released.
SendInput {RButton}
SendInput {RButton Down}
KeyWait, RButton
SendInput {RButton Up}
} else { ; If not, just keeps holding until button is released.
SendInput {RButton Down}
KeyWait, RButton
SendInput {RButton Up}
}
Return
;######################
;# CrouchJump #
;######################
*$Space::
if CrouchJump = 1
{
KeyWait, Space, T0.08
If ErrorLevel = 1 ; If Space is holding then jumps and crouch.
{
SendInput {Space}{c down}
Sleep 500 ; And keeps crouching 0.5 seconds to improve the jump.
SendInput {c up}
} else { ; Else just jumps.
SendInput {Space}
}
} else
SendInput {Space}
Return
;###################
;# ToolTip #
;###################
ToolTip(Text) ; Function to show a tooltip when activating, deactivating or changing values.
{
activeMonitorInfo(X, Y, Width, Height) ; Get current resolution
xPos := Width / 2 - 50
yPos := Height / 2 + (Height / 10)
ToolTip, %Text%, xPos, yPos ; Tooltips are shown under crosshair.
SetTimer, RemoveToolTip, 1300 ; Removes tooltip after 1.3 seconds.
return
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
Return
}
/*
ToolTip(Text, Color) {
activeMonitorInfo(X, Y, Width, Height) ; Get current resolution
xPos := Width / 2 - 30
yPos := Height / 2 + (Height / 10)
;SoundPlay, *64 ; Simple beep. If the sound card is not available, the sound is generated using the speaker.
CustomColor = EEAA99
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, %CustomColor%
Gui, Font, s16, Arial
Gui, Add, Text, c%Color% , %Text%
WinSet, TransColor, %CustomColor%
Gui, Show, x%xPos% y%yPos% NoActivate
Sleep, 600
Gui, Destroy
Return
}
*/
;####################################
;# Hotkeys to change values #
;####################################
; Toggles
Pause::
Suspend
if (A_IsSuspended)
{
ToolTip("SCRIPT OFF")
} else
ToolTip("SCRIPT ON")
return
*NumPad1::( ADS = 0 ? (ADS := 1,ToolTip("ADS ON")) : (ADS := 0,ToolTip("ADS OFF")) ) ; ADS Toggle
*NumPad0::( CrouchJump = 0 ? (CrouchJump := 1,ToolTip("CrouchJump ON")) : (CrouchJump := 0,ToolTip("CrouchJump OFF")) ) ; CrouchJump Toggle
;##########################
;# GetResolution #
;##########################
activeMonitorInfo( ByRef X, ByRef Y, ByRef Width, ByRef Height )
{ ; Retrieves the size of the monitor, the mouse is on
CoordMode, Mouse, Screen
MouseGetPos, mouseX , mouseY
SysGet, monCount, MonitorCount
Loop %monCount%
{ SysGet, curMon, Monitor, %a_index%
if ( mouseX >= curMonLeft and mouseX <= curMonRight and mouseY >= curMonTop and mouseY <= curMonBottom )
{
X := curMonTop
y := curMonLeft
Height := curMonBottom - curMonTop
Width := curMonRight - curMonLeft
return
}
}