Skip to content

Instantly share code, notes, and snippets.

@Byteflux
Created June 3, 2024 07:27
Show Gist options
  • Save Byteflux/5065f32103391775fec19e6af4d5ad07 to your computer and use it in GitHub Desktop.
Save Byteflux/5065f32103391775fec19e6af4d5ad07 to your computer and use it in GitHub Desktop.
AHK script for Diablo 4 to enable basic skills to be performed by shift-click despite left-click being bound to Move or Move/Interact. Additionally prevents stutter stepping when spamming shift-click attacks.
; For my personal use, this script slightly changes how shift-clicking
; works in Diablo 4.
;
; The script requires a couple of key binding changes:
; 1. Move or Move/Interact must be bound to the Left Mouse Button.
; 2. Basic Skill must be bound to Mouse Button 5 (M5).
;
; After key bindings have been set, as you'd expect you can no longer
; perform a basic skill with left click.
;
; Under these changes, this script enables basic skills to be
; performed while holding shift-click.
;
; While shift-click is being held, left-click movement is disabled
; because the script releases the game's left-click.
;
; This behavior is intentional, to prevent unwanted stutter stepping
; when spamming left click while holding down shift.
;
; Anyone is free to use this script at their own discretion, however,
; I claim no responsibility for any damages that may occur from its use.
;
; Lastly, I grant unlimited access to any person or organization to
; use, modify and redistribute this script as they see fit.
#Requires AutoHotkey v2.0
#SingleInstance Force
A_HotkeyInterval := 2000
A_MaxHotkeysPerInterval := 200
WinTitle := "ahk_class Diablo IV Main Window Class"
; Checks that the game window is active and the mouse is over it.
; Used to ensure the script's functionality only works within the game.
IsActive()
{
MouseGetPos , , &id
return WinExist(WinTitle " ahk_id " id) && WinActive(WinTitle)
}
; On pressing shift while left click is being physically pressed,
; release left click and instead press the M5 button.
*~LShift::
{
if (IsActive() && GetKeyState("LButton", "P"))
{
Click "Down X2"
Click "Up"
}
}
; On releasing shift while left click is being physically pressed,
; release the M5 button and instead press left click.
*~LShift Up::
{
if (IsActive() && GetKeyState("LButton", "P"))
{
Click "Up X2"
Click "Down"
}
}
; On physically pressing left click while shift is being pressed,
; press the M5 button instead.
*$LButton::
{
if (!IsActive() || !GetKeyState("LShift", "P"))
{
Click "Down"
}
else if (!GetKeyState("XButton2"))
{
Click "Down X2"
}
}
; On physically releasing left click while shift is being pressed,
; release the M5 button instead.
*$LButton Up::
{
if (!IsActive() || !GetKeyState("LShift", "P"))
{
Click "Up"
}
else if (GetKeyState("XButton2"))
{
Click "Up X2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment