[
  {
    "path": "Null Movement.ahk",
    "content": "; Null Movement Script for AutoHotkey v2\n; This script updates the A and D keys so that only one is held down at a time\n; This avoids the situation where game engines treat holding both strafe keys as not moving\n; Instead, holding both strafe keys will cause you to move in the direction of the last one that was pressed\n; The same logic is applied to the W and S keys (only one can be held at a time)\n; Cheers to https://www.youtube.com/watch?v=Feny5bs2JCg&t=335s for mentioning this\n; Changelog:\n; 2024-08-10: simpler global usage with single global specifier\n; 2024-07-26: Adding MaxThreads 1 and MaxThreadsBuffer 1\n; 2024-07-26: Changing to use SendInput instead of Send, removing a couple if statements in key down events\n; 2024-07-25: Adding section to allow for end button to close script, leaving commented for the moment\n; 2024-07-25: Changed to use scancodes for multi-layout keyboard support\n; 2024-07-25: Added requires v2 line\n\n; Scan Code Mappings:\n; W   SC011\n; A   SC01E\n; S   SC01F\n; D   SC020\n\n#Requires AutoHotkey v2\n#SingleInstance force\n#MaxThreads 1\n#MaxThreadsBuffer 1\nPersistent true\nListLines False\nKeyHistory 0\nProcessSetPriority \"High\"\nA_MaxHotkeysPerInterval := 99000000\nA_HotkeyInterval := 0\n\nglobal a_held := 0  ; Variable that stores the actual keyboard state of the A key\nglobal d_held := 0  ; Variable that stores the actual keyboard state of the D key\nglobal a_scrip := 0 ; Variable that stores the state of the A key output from the script\nglobal d_scrip := 0 ; Variable that stores the state of the D key output from the script\n\nglobal w_held := 0\nglobal s_held := 0\nglobal w_scrip := 0\nglobal s_scrip := 0\n\n/* Un-comment this section if you want the end button to open a dialog that asks to close the script\nToolTip \"Script Enabled\",A_ScreenWidth/2,A_ScreenHeight/2\nSetTimer () => ToolTip(), -1000\n\nEnd:: ; <--- this button exits the script\n{ \n    Result := MsgBox(\"Are you sure you want to exit?\",, 4)\n    if Result = \"Yes\" \n    {\n        ExitApp\n    }\n}\n*/\n\n*$SC01E:: ; *$a:: ; Every time the a key is pressed, * to include occurences with modifiers (shift, control, alt, etc)\n{   \n    global\n\n    a_held := 1  ; Track the actual state of the A key\n    \n    if d_scrip\n    { \n        d_scrip := 0\n        SendInput \"{Blind}{SC020 up}\" ; Release the D key if it's held down, {Blind} so it includes any key modifiers (shift primarily)\n    }\n    \n    a_scrip := 1\n    SendInput \"{Blind}{SC01E down}\" ; A down key\n}\n\n*$SC01E up:: ; *$a up:: ; Every time the a key is released\n{    \n    global\n\n    a_held := 0\n    \n    if a_scrip\n    {\n        a_scrip := 0\n        SendInput \"{Blind}{SC01E up}\"  ; A up key\n    }\n        \n    if d_held && !d_scrip\n    {\n        d_scrip := 1\n        SendInput \"{Blind}{SC020 down}\"  ; D down key if it's held\n    }\n}\n\n*$SC020:: ; *$d::\n{    \n    global\n\n    d_held := 1\n    \n    if a_scrip\n    {\n        a_scrip := 0\n        SendInput \"{Blind}{SC01E up}\"  ; Release the A key if it's held down\n    }\n    \n    d_scrip := 1\n    SendInput \"{Blind}{SC020 down}\"  ; D down key\n}\n\n*$SC020 up:: ; *$d up::\n{    \n    global\n\n    d_held := 0\n    \n    if d_scrip\n    {\n        d_scrip := 0\n        SendInput \"{Blind}{SC020 up}\"  ; D up key\n    }\n    \n    if a_held && !a_scrip\n    {\n        a_scrip := 1\n        SendInput \"{Blind}{SC01E down}\"  ; A down key if it's held\n    }\n}\n\n*$SC011:: ; *$w::\n{    \n    global\n\n    w_held := 1\n\n    if s_scrip \n    {\n        s_scrip := 0\n        SendInput \"{Blind}{SC01F up}\"\n    }\n\n    w_scrip := 1\n    SendInput \"{Blind}{SC011 down}\"\n}\n\n*$SC011 up:: ; *$w up::\n{    \n    global\n\n    w_held := 0\n\n    if w_scrip\n    {\n        w_scrip := 0\n        SendInput \"{Blind}{SC011 up}\"\n    }\n\n    if s_held && !s_scrip \n    {\n        s_scrip := 1\n        SendInput \"{Blind}{SC01F down}\"\n    }\n}\n\n*$SC01F:: ; *$s::\n{    \n    global\n\n    s_held := 1\n\n    if w_scrip \n    {\n        w_scrip := 0\n        SendInput \"{Blind}{SC011 up}\"\n    }\n\n    s_scrip := 1\n    SendInput \"{Blind}{SC01F down}\"\n}\n\n*$SC01F up:: ; *$s up::\n{    \n    global\n\n    s_held := 0\n\n    if s_scrip \n    {\n        s_scrip := 0\n        SendInput \"{Blind}{SC01F up}\"\n    }\n\n    if w_held && !w_scrip \n    {\n        w_scrip := 1\n        SendInput \"{Blind}{SC011 down}\"\n    }\n}"
  }
]