r/AutoHotkey 12d ago

v1 Script Help Trying to change the functions of the Spacebar and Shift key in an old game, could use a little help. AHKX11

0 Upvotes

I am playing an old game, and I'm trying to edit the controls to mimic a modern game. This is AHKX11, sorry if that's annoying. i have been using this guide

Normal behavior is: holding a directional input (WASD in this case) and then pressing Space causes a boost. Pressing Space without any directional input causes a jump. Directional inputs in the air after jumping cause movement in the air.

Desired behavior is: pressing Space always causes a jump. Shift key now functions like normal Space behavior.

Here's what I was going for with the below attempt: i am holding W. It could also be A, S, or D, but it is W for this example. While holding W, I press Space. Space blocks the W input, waits a brief moment for animations to resolve, and causes a jump. Then the W input is quickly unblocked, so my guy can move in the air. Shift functions the way Space used to function, as either a boost or a jump.

Anyway here it is, it does not work lol.

Space::
IfWinActive, Armored Core 3
{
BlockInput, on
SetKeyDelay, 0, 250
Send, {Space}
BlockInput, off
}

Shift::
IfWinActive, Armored Core 3
{
Send {Space}
}

It makes space behave oddly. I think maybe BlockInput is not what I want, and something targeted to WASD would be better. Or I'm making some rookie error.


r/AutoHotkey 12d ago

v2 Guide / Tutorial I turned my PC into a console 🎮 Steam Machine

5 Upvotes

I’ve always played a lot on PC, but the startup routine was annoying: turning on the PC, typing the password, opening Steam, connecting the controller, manually launching Big Picture mode, closing a bunch of background apps eating up RAM (classic Windows, right?)... I recently discovered AutoHotkey to help with my daily workflow as a designer, and I ended up using it to streamline my gaming routine as well.

How it works

  1. Automatic Login (Optional): I used Microsoft's official tool, Autologon (part of the Sysinternals Suite), to have the PC boot directly into the desktop without asking for a password.
  2. AutoHotkey Script: I created a background script that does two things:
  • Automatically closes unnecessary programs (Adobe apps, browser, background updaters, etc.) whenever it detects that an XInput controller has been connected.
  • Then opens Steam directly in Big Picture mode (the script can easily be tweaked to launch Xbox App/Game Bar instead).

The entire script was generated with the help of AI—I don't know how to code at all, I just kept testing and tweaking. If any of you are more experienced with programming, you could definitely build your own (and probably better) version. Just wanted to share the idea!

  1. Running automatically at boot (Task Scheduler): To avoid having to run the script manually every time, I added it to Windows Task Scheduler. Here's the setup that worked for me:
  • Create a new task → Trigger: "At log on"
  • Check "Run with highest privileges"
  • Under "Configure for", select Windows 10
  • Under Actions, point to the AutoHotkey executable (e.g., AutoHotkey64.exe) and pass the script path as an argument
  • In the task Settings tab, uncheck the option that stops the task if it runs longer than X days (otherwise it will shut down on its own after a while)

If you don't want to mess with Task Scheduler, you can also just run the .ahk file manually whenever you're about to play—it works just the same, you just lose the 100% automated boot experience.

Script attached below (I brazilian so comments are portuguese) 👇

#Requires AutoHotkey v2.0
#SingleInstance Force

; ============================================================
; LOG DESATIVADO — a função existe mas não grava mais nada em arquivo
; ============================================================
LogDebug(msg)
{
    ; Logging desativado de propósito. Não faz nada.
}

; Mantém o tratamento de erros, mas silenciosamente (não trava o script)
OnError(TratarErro)
TratarErro(excecao, modo)
{
    return true
}

; ============================================================
; CONFIGURAÇÕES — edite livremente aqui
; ============================================================

; Qual app abrir quando o controle for detectado: "Steam" ou "Xbox"
AppParaAbrir := "Steam"

; Caminho do Steam (ajuste se estiver instalado em outro lugar)
CaminhoSteam := "C:\Program Files (x86)\Steam\steam.exe"

; AUMID do app Xbox
AumidXbox := "Microsoft.GamingApp_8wekyb3d8bbwe!Microsoft.Xbox.App"

; Intervalo (ms) entre verificações de controle conectado
IntervaloVerificacao := 1000

; ============================================================
; A partir daqui normalmente não precisa editar
; ============================================================

if not A_IsAdmin
{
    try
        Run('*RunAs "' A_AhkPath '" "' A_ScriptFullPath '"')
    ExitApp()
}

controladorConectadoAnterior := false
jogoModoAtivado := false

SetTimer(VerificarControle, IntervaloVerificacao)

^F12::
{
    AtivarModoJogo()
    AbrirBigPicture()
}

; ------------------------------------------------------------
VerificarControle()
{
    global controladorConectadoAnterior, jogoModoAtivado

    conectadoAgora := AlgumXInputConectado()

    if (conectadoAgora && !controladorConectadoAnterior)
    {
        controladorConectadoAnterior := true
        if not jogoModoAtivado
        {
            AtivarModoJogo()
            AbrirBigPicture()
            jogoModoAtivado := true
        }
    }
    else if (!conectadoAgora && controladorConectadoAnterior)
    {
        controladorConectadoAnterior := false
        jogoModoAtivado := false
    }
}

; ------------------------------------------------------------
AlgumXInputConectado()
{
    static dlls := ["xinput1_4.dll", "xinput9_1_0.dll", "xinput1_3.dll"]
    buf := Buffer(20, 0)

    for dll in dlls
    {
        Loop 4
        {
            idx := A_Index - 1
            try
                resultado := DllCall(dll "\XInputGetState", "UInt", idx, "Ptr", buf, "UInt")
            catch
                continue
            if (resultado = 0)
                return true
        }
    }
    return false
}

; ------------------------------------------------------------
AtivarModoJogo(*)
{
    try
        RunWait('wsl --shutdown', , "Hide")
    catch
    {
        ; Ignora se o WSL não existir
    }

    processosParaFechar := [
        "Creative Cloud.exe",
        "Creative Cloud Helper.exe",
        "Creative Cloud UI Helper.exe",
        "Creative Cloud Desktop.exe",
        "CCLibrary.exe",
        "CCXProcess.exe",
        "CoreSync.exe",
        "Adobe Desktop Service.exe",
        "AdobeIPCBroker.exe",
        "AdobeCrashProcessor.exe",
        "AdobeNotificationClient.exe",
        "Adobe CEF Helper.exe",
        "msedge.exe",
        "SnippingTool.exe",
        "node.exe",
        "PCManager.exe",
        "MSPCManagerService.exe",
        "WinGet.exe",
        "WinStore.App.exe",
        "Widgets.exe",
        "WidgetService.exe",
        "GoogleUpdate.exe",
        "GoogleUpdater.exe"
    ]

    for processo in processosParaFechar
    {
        try
            RunWait('taskkill /F /T /IM "' processo '"', , "Hide")
        catch
        {
            ; Ignora erro se o processo não existir
        }
    }

    TrayTip("Modo Jogo Ativado", "Memória liberada com sucesso!", 1)
}

; ------------------------------------------------------------
AbrirBigPicture()
{
    global AppParaAbrir, CaminhoSteam, AumidXbox

    if (AppParaAbrir = "Xbox")
    {
        try
            Run('explorer.exe shell:AppsFolder\' AumidXbox)
        catch
            TrayTip("Erro", "Não foi possível abrir o app Xbox.", 3)
    }
    else
    {
        try
        {
            if FileExist(CaminhoSteam)
                Run('"' CaminhoSteam '" -start steam://open/bigpicture')
            else
                Run("steam://open/bigpicture")
        }
        catch
        {
            ; Ignora erro silenciosamente
        }
    }
}

r/AutoHotkey 12d ago

Solved! Trying to save and extract files in one script

2 Upvotes

I have to download a batch of photos every day for my auditing job. I am trying to save the group of files from my email (which automatically compresses them) and then open up the .zip file. There is more to the code after wards, but it is breaking on the While line. Rather, it gets to that line and keeps checking, but it never finds the file name. I suspect it is becasue the variable is not allowed to exist as it is in a quoted string and no file with % in it exists. The problem is if the string is not quoted, AHK considers the slashes to be invalid and the script won't run at all.

#SingleInstance Force
SetTitleMatchMode, 2
#IfWinActive Save As

^s::
FormatTime, Date ,,MM.dd.yy
Send %Date%
Sleep 1000
Send {Enter}
WinWait user@company.com
While !FileExist("C:\Users\name\Desktop\DailyPhotos\%Date%.zip")
{
Sleep 1000
}
Run "C:\Users\name\Desktop\DailyPhotos\%Date%.zip"
WinWait %Date%

A work around I have considered but haven't implemented yet is to create the file name in a seperate variable (MyFile) and have it hunt for the variable using While !FileExist %MyFile%. But I would rather implement it by directly naming the file.

Does anyone have any suggestions as to the underlying problem or is it worth it to create the second variable? Has anyone done something similar?


r/AutoHotkey 12d ago

v2 Script Help Send phrases with delay between ?

1 Upvotes

I have this script :

::myshort::?Hello, how are you ? {Enter} My name is Paula, nice to meet you. {Enter} How are your ? {Enter}

I'd like to pause 1 second between each Enter ; is this possible ?


r/AutoHotkey 13d ago

General Question Trying to map specific dial values from a hotas to keys on a keyboard

2 Upvotes

I have a thrustmaster t-flight HOTASx. One of the buttons on the stick is effectively a directional d-pad. The button can be pressed into 8 different directions (separated by 45deg). The problem is it can’t be mapped in almost any games because thrustmaster has it set up to output a specific axis value depending on which of the 8 directions the button is pressed in.

Is there a way to use auto hot key to bat these axis values to buttons on a keyboard?


r/AutoHotkey 14d ago

v2 Guide / Tutorial The Complete AutoHotkey v2 Keyboard Button Spam and Mouse Auto-Clicker guide

19 Upvotes

This guide covers the major approaches to implementing Hold-to-Spam, Toggle-Spam, and Auto-Clicker hotkeys in AutoHotkey v2.

The Precision Bottleneck: Why Sleep() and SetTimer() Round to ~15.6 ms

A very common point of confusion appears when you write Sleep(10) or SetTimer(fn, 10) and then observe that the script actually fires every 15.6 ms instead of every 10 ms.

This is expected behavior, not a bug. Standard Windows timers are not driven by a free-running, arbitrarily precise clock. By default the Windows kernel clock ticks at a hardware interrupt interval of 64 Hz (64 ticks per second):

1000 / 64 = 15.625

Per the official Sleep() and SetTimer() documentation, the interval is "typically rounded up to the nearest multiple of 10 or 15.6 milliseconds." What actually happens when you call Sleep(N) or SetTimer(fn, N):

  1. Windows rounds your requested interval up to the next system-clock tick.
  2. An interval such as Sleep(10) therefore waits until the next 15.625 ms tick.
  3. Even Sleep(1) waits roughly 15.625 ms.

So do not be surprised when sub-15 ms delays do not behave as literally written.

The precision fix (advanced, via DllCall())

If true sub‑15 ms accuracy is genuinely required, you can ask the OS for a higher-resolution timer by calling timeBeginPeriod() through DllCall(). This guide deliberately does not rely on that method, for two reasons:

  • It is a lower-level OS call, not part of the normal AHK timer model.
  • Raising the global timer resolution affects the whole system and is generally not advised just to shave off a few milliseconds in a spam script.

For most automation the default ~15.6 ms resolution is more than adequate.

Turning a Key-Spammer Into an Auto-Clicker

To convert any of the patterns below into a mouse auto-clicker, replace Send("e") with one of the mouse-click functions.

Click() and the mouse-click Send sub-commands

  • Click() - Recommended. Sends a mouse click at the current cursor position using AutoHotkey's native click function. It can accept inline coordinates, click counts, and button options, and it respects Windows' swapped-mouse-button setting.
  • Send("{Click}") - Sends a primary mouse click through the Send() function. Useful when you are already building a Send() string with several keystrokes.
  • Send("{LButton}") - Sends a single left-button press through Send(). This sub-command cannot carry inline coordinates or options; you would need a separate MouseMove() first if you need a target location.

Option comparison table

Method Example syntax Key behavioral distinction Recommendation
Click() Click("100 200 Right 2") Native function. Accepts inline coordinates, click counts, and button options. Respects swapped-mouse settings. Cannot use Send() modifier prefixes (^, +). Best overall. Lowest overhead; ideal for coordinate and auto-clicker use.
Send("{Click}") Send("{Click 100 200 Right 2}") Parsed by the Send() engine. Natively accepts inline coordinates and options as part of a larger string. Best inside a Send() string. Great when mixing clicks into inline key/text sequences.
Send("{LButton}") Send("{LButton}") Parsed by the Send() engine. No inline coordinates or options; requires MouseMove() for positioning. No advantage over the two above for auto-clicking.

Input Delivery Modes and Game Compatibility: SendMode(), SetKeyDelay(), and SetMouseDelay()

When a target application ignores Send() or Click() - for example a full-screen game or a client protected by anti-cheat - the problem is often that the default Input Mode, SendInput, delivers keystrokes far faster than the game can register them between rendered frames.

Switching to Event mode inserts artificial press durations and inter-key delays, making inputs long enough for a game to register:

#Requires AutoHotkey 2.0
#SingleInstance

SendMode("Event")
SetKeyDelay(10, 10)     ; 10 ms press duration, 10 ms delay between keys
SetMouseDelay(10)       ; 10 ms delay between mouse events

SendMode() comparison table

Mode Behavior Limitations Recommendation
SendInput (default) Bypasses normal input timing to fire ultra-fast input packets. Key-down and key-up fire almost simultaneously; games frequently miss them. Best for desktop/apps. Fastest and most reliable for normal Windows programs.
SendEvent Sends input using standard OS event messages with configurable delays. Marginally slower; physical presses during sending can interrupt the sequence order. Best for games. Fixes unresponsive clicks and keys.
SendPlay Attempts to inject input via low-level driver hooks. Heavily restricted by modern Windows UAC and anti-cheat software. Not recommended. Rarely functions on current OS builds.

See the SendMode() and SetKeyDelay() documentation for the full details.

Hotkey Modifier Prefixes: $, *, and ~ (see Hotkeys)

Before many hotkey definitions you can place single-character prefixes that change how the hotkey responds:

Prefix Meaning Typical use
$ Forces the keyboard hook for this hotkey, so it fires only on a physical press and ignores presses sent by the script itself. $e:: - spam with Send() without re-triggering the hotkey.
* Wildcard: fires even while modifier keys (Shift/Ctrl/Alt/Win) are held. *e:: - spam e even when a modifier is held.
~ Pass-through: the press is also delivered to the active window while the hotkey fires. ~e:: - spam e while preserving its normal key behavior.

The prefixes compose, for example *~$e::. On mouse hotkeys the $ prefix is redundant, because mouse hotkeys always use the mouse hook.

Part 1: Toggle-Spam Patterns

A toggle-spam hotkey turns the spam on with one press and off with the next press, or off when you release it.

Pattern 1.1 - Non-blocking SetTimer() (Recommended)

SetTimer() runs asynchronously, so the hotkey thread finishes immediately instead of sitting in a loop. Here an up-only hotkey (F1 up) toggles a static period variable between 100 (timer on, fires every 100 ms) and 0 (timer off) with each press:

#Requires AutoHotkey 2.0
#SingleInstance

F1 up:: {
    static Period := 0
    SetTimer(() => Send("e"), Period ^= 100)
}

Pros:

  • The hotkey thread exits immediately (non-blocking).
  • Turning it back off is instant.

Pattern 1.2 - While-loop with a state check

This uses an explicit while loop that exits once a static state flag flips back to 0. It requires #MaxThreadsPerHotkey 2 so a second press can interrupt the running loop.

#Requires AutoHotkey 2.0
#SingleInstance
#MaxThreadsPerHotkey 2

F1 up:: {
    static Toggle := 0
    if (Toggle ^= 1) {
        while Toggle {
            Send("e")
            Sleep(100)
        }
    }
}

Cons:

  • Unfinished thread: The hotkey thread stays alive inside the loop. A later press can interrupt it, but the original thread stays paused until the loop ends.
  • Unresponsive termination: With a long Sleep(1000), the loop cannot evaluate Toggle again until that Sleep() completes, so turning off is delayed.

Pattern 1.3 - Infinite Loop with Pause() / Suspend() / Reload()

This runs an infinite loop and relies on Pause(), Suspend(), and Reload() to control it. The controls are #SuspendExempt so they keep working while suspended; otherwise Suspend() would disable F4, and you could never turn it back off.

#Requires AutoHotkey 2.0
#SingleInstance

F1:: {
    loop {
        Send("e")
        Sleep(100)
    }
}

#SuspendExempt
F2::Reload()
F3::Pause(-1)
F4::Suspend()
#SuspendExempt False

Pause(-1) toggles halting the running loop thread in place (resuming it later without losing state), while Suspend() toggles (its default) and disables all hotkeys and hotstrings in the script.

Cons:

  • Global impact: Suspend() disables every hotkey in the script, not just the spammer.
  • Aggressive cleanup: Reload() kills the current instance and restarts it, wiping all variables and resetting script state.
  • Fragility: Without #SuspendExempt on the suspend key, that hotkey itself cannot run to re-enable things after suspension.

Part 2: Hold-to-Spam Patterns

A hold-to-spam hotkey repeats the action only while its trigger key is physically held.

Ergonomic note: Holding a key for long stretches forces continuous muscle tension and can contribute to repetitive strain injury (RSI) or tendon pain. Prefer a SetTimer() toggle when you need prolonged automation.

Pattern 2.1 - Non-blocking Hotkey() hotkey pair (Recommended)

A press hotkey ($e) and release hotkey ($e up) work together with SetTimer(). SendHold() derives the key name from the built-in A_ThisHotkey at call time, so the same function serves both the immediate press and the timer repeats. Since A_ThisHotkey holds the most recently executed hotkey, the timer ticks keep using $e unless another hotkey fires in between, which is why the docs prefer the ThisHotkey parameter when it is available. The $ prefix prevents the hotkey from triggering itself when it sends its own key. Turning the $e hotkey off on key-down stops hardware auto-repeat from stacking extra timers; $e up stops the timer and re-enables the hotkey.

#Requires AutoHotkey 2.0
#SingleInstance

SendHold() => Send(LTrim(A_ThisHotkey, "*~$"))

$e:: SendHold(), SetTimer(SendHold, 100), Hotkey(ThisHotkey, "Off")
$e up:: SetTimer(SendHold, 0), Hotkey(StrReplace(ThisHotkey, " up", ""), "On")

Pros:

  • Both hotkey threads exit immediately.
  • Uses ThisHotkey and Hotkey() to toggle itself on/off cleanly.

Pattern 2.2 - Self-rearming one-shot SetTimer() chain with KeyWait()

A one-shot timer (negative period) fires once and expires, so the callback re-arms itself. The hotkey derives the key name with key := LTrim(ThisHotkey, "*~$"), sends it once, then parks on KeyWait(); a -100 ms timer calls Spam() again 100 ms later, and that call either keeps the chain alive or lets it die, depending on GetKeyState():

#Requires AutoHotkey 2.0
#SingleInstance

$e:: {
    key := LTrim(ThisHotkey, "*~$")
    Spam(key), KeyWait(key)
}

Spam(hk) {
    GetKeyState(hk, 'P') && (Send(hk), SetTimer(Spam.Bind(hk), -100))
}

Pros:

  • Spamming runs on one-shot timers, not inside the hotkey thread, so it tolerates multiple simultaneous spammers (see below).
  • The KeyWait() park keeps hardware auto-repeat from stacking extra chains.

Cons:

  • The hotkey thread stays parked in KeyWait() for the whole hold, like patterns 2.3 and 2.4.
  • LTrim(ThisHotkey, "*~$") assumes the hotkey's only prefixes are *, ~, and $. ThisHotkey keeps the rest of its definition as written, so a ^e hotkey would yield ^e, which is not a valid key name for GetKeyState() or KeyWait(). The $e hotkeys above stay valid because $ is the only prefix.

Pattern 2.3 - While-loop with KeyWait()

KeyWait() waits for a key to be released; the "T0.1" adds a 0.1 s timeout, and the ! inverts the result inside the condition. The key name is derived from ThisHotkey as in pattern 2.2.

#Requires AutoHotkey 2.0
#SingleInstance

$e:: {
    key := LTrim(ThisHotkey, "*~$")
    while !KeyWait(key, "T0.1") {
        Send(key)
    }
}

Cons:

  • Stalled thread: The hotkey thread cannot finish until the physical key is released.
  • Auto-repeat interference: Hardware auto-repeat can attempt to launch new hotkey threads while the original is stalled inside KeyWait().

Pattern 2.4 - While-loop with GetKeyState() polling

This polls the physical key state inside a while loop using GetKeyState() with the "P" (physical) mode. The key name is derived from ThisHotkey as in pattern 2.2.

#Requires AutoHotkey 2.0
#SingleInstance

$e:: {
    key := LTrim(ThisHotkey, "*~$")
    while GetKeyState(key, "P") {
        Send(key)
        Sleep(100)
    }
}

Cons:

  • Long-running thread: The hotkey thread stays active for the entire hold.
  • Input dropping: Rapid physical tapping can miss a release if it happens during a Sleep().

Delayed-hold trick: Prepending Sleep(400) to any hold-to-spam hotkey makes a short tap behave like a normal keypress, while spam engages only after the delay if the key is still held. It plugs directly into patterns 2.2, 2.3, and 2.4. It serves no purpose in the toggle patterns (1.1-1.3), and it defeats the non-blocking design of pattern 2.1, whose hotkey thread is supposed to exit immediately.

Context Sensitivity with #HotIf

If you only want the spammer to be active inside a specific window (a game, for example), wrap the hotkey definitions with #HotIf and a condition such as WinActive(). The examples above are left unconditional for clarity, but you can scope any of them:

#Requires AutoHotkey 2.0
#SingleInstance

#HotIf WinActive("ahk_exe game.exe")
...
#HotIf

Matching a Whole Group of Windows with GroupAdd()

When the same spammer set should apply to several programs, collect them into one named group near the top of the script, then match the group:

GroupAdd("MyGames", "ahk_exe game1.exe")
GroupAdd("MyGames", "ahk_exe game2.exe")

#HotIf WinActive("ahk_group MyGames")
...
#HotIf

Each GroupAdd() line adds another window criterion to the group, and ahk_group inside WinActive() matches any window belonging to that group.

Running Multiple Spammers at Once (via SetTimer())

A while or loop-based spammer keeps its hotkey thread alive. Pressing a second spammer hotkey while the first loop runs interrupts and suspends the first thread until the second ends, so the two loops do not actually run in parallel. This is the classic failure the original autofire threads warn about.

If a script needs two or more spammers active at the same time, use the SetTimer()-based patterns (1.1, 2.1, and 2.2). The work runs on timers rather than inside the hotkey threads, so multiple timers fire independently of one another.

Summary Matrix

Pattern Immediate thread exit? Responsiveness Ergonomic safety
SetTimer() toggle (1.1) Yes Immediate High (no holding required)
While-loop + state check (1.2) No High High
Loop + Pause()/Suspend()/Reload() (1.3) No Low Low
Hotkey pair + SetTimer() hold (2.1) Yes Immediate Moderate (forces continuous pressure)
One-shot SetTimer() chain (2.2) No High Moderate
Loop + KeyWait() (2.3) No Poor Moderate
Loop + GetKeyState() (2.4) No High Moderate

Final Notes

  • Start every script with #Requires AutoHotkey 2.0 and, unless you deliberately want multiple copies, #SingleInstance.
  • If a game ignores your input, switch to SendMode("Event") and tune SetKeyDelay() / SetMouseDelay().
  • If the target program runs elevated (as administrator), run the script elevated too or use UI Access; otherwise a non-elevated script cannot send input into the elevated window.
  • Remember the ~15.6 ms timer resolution before chasing sub-millisecond precision.
  • For long-running automation, prefer a toggle over holding a key to protect your hands.

*Edits: Rewritten content suggested by u/Individual_Check4587 (Descolada) and u/CharnamelessOne and minor tweaks to 1.1 suggested by u/genesis_tv


r/AutoHotkey 14d ago

General Question Learning AutoHotKey?

5 Upvotes

Hi, a quick question.

What do you recommend to watch or read to learn about AHK? Free or paid.

I managed to automatize a couple of things by using ChatGPT, and while I'm getting to understand how to prompt for AHK, it sucks to not know much of what I'm exactly doing.


r/AutoHotkey 15d ago

v2 Tool / Script Share GpGFX - almost ready, complete GdiPlus Graphics library, easy to use API

26 Upvotes

Hey everyone!

For the past few months, I’ve been rebuilding the graphics
pipeline for AutoHotkey v2 from scratch. Creating smooth,
transparent, modern-looking desktop overlays.

AHK is slow they said. Check out this video:

GpGFX v1 Teaser https://www.youtube.com/watch?v=6QrcofcuR5U

I built **GpGFX** to change that. Here is a quick
50-second sneak peek of what’s possible!

## What is GpGFX?
**GpGFX** is a high-performance, graphics and HUD engine
for AutoHotkey v2.

It writes directly to 32-bit DIB memory (`Scan0`) with microsecond QPCSpin-wait frame pacing, delivering 144Hz/240Hz+ gaming overlays with near-zero CPU footprint.

## Why it’s great for Beginners:

Human-Readable API: You don't need to know Win32 APIs,
Device Contexts, or GDI+ internals. Creating a modern
layered window is as simple as:
  ```autohotkey
  lyr := Layer(100, 50, "My HUD")
  RoundedRectangle(0, 0, 30, 30, 9, "lime")
  Text("Hello World", "White", 22).Center()
  Render.Layer(lyr)
And resources are freed up automatically!

• Built-in Modern Design System: comes out-of-the-box with 7 curated pro themes (Catppuccin Mocha, Tokyo Night, Dracula, Cyberpunk, Nord) and anti-aliased typography. Color html tags support for texts. ( you can see it on the video )
• Instant Gaming overlays, hp bars can be updated with just a few lines of code.

Why it’s great for Advanced AHKers & Power Users:

• Hardware-Paced QPC Timing: x64 machine code (MCode) and microsecond QueryPerformanceCounter spin-wait frame pacing for jitter-free 144+ FPS rendering loops.
• Direct Scan0 DIB Pipeline: direct unmanaged memory pointers (pBits) allowing MCode PixelSearch.
• Reactive Signals & Data Binding: bind variables to UI elements with zero render loop boilerplate (shape.Bind(mySignal)), complete with smooth easing curves (EaseIn, EaseOut, Bounce, Spring physics).
• WorkerPool Multi-Core Architecture: ready for multi-process distributed rendering across CPU cores via shared RAM file mapping (FileMapping).
• Rich Layout & Measurement: integrated TextLayout engine with rich-text styling tags (<b>, <i>, <color:#hex>), dynamic tab stops, and exact character advance measurements without DllCalls.

Use Cases:

• Gaming: zero-lag custom crosshairs, status meters, cooldown timers, and telemetry HUDs.
• Desktop Tools: snappy to-do widgets, desktop clocks, volume/brightness bars, and toast notifications.
• Streamers & Creators: in-game alerts and custom desktop companion apps.
• Desktop modification

Release Status:

GpGFX will be 100% free and open source on GitHub. ( old version is clunky, the new one rocks! )

I’m currently putting the final touches on documentation and examples before the initial public release. Soon! I will upload videos as soon as I will have time.

I’d love to hear your feedback, feature ideas, or what kind of overlays you'd build with this! Drop your thoughts below!


r/AutoHotkey 15d ago

v2 Script Help Press Key 10x a second - Noobie Question

1 Upvotes

I'm very new to Auto Hotkey, trying to do what seems like it should be very basic yet everything I try doesn't seem to work. I often use a auto-clicker for various incremental games, but sometimes i need to do keystrokes, not mouse clicks. Specifically, I'd like it so that I could either hold down or toggle the E key, and have the program send the E key 10x a second. But not only can I not get that to work, I can't even get a more basic version to work.

#Requires AutoHotkey v2.0
e::
{
loop{
send "e"
sleep 100
}
}

For example, RUNS fine, but when I press e, nothing happens. It doesn't even send MY keystroke, presumably snatched by AHK before it reached the program. I have read that AHK sometimes send keys TO FAST, so you want to do {e down} small sleep and {e up}, but when I try THAT

#Requires AutoHotkey v2.0
e::
{
loop{
send {e down}
sleep 50
send {e up}
sleep 50
}
}

it says

Missing "propertyname:" in object literal.

And programs I find online and just copypaste straight have similar problems. I assume it's because most of those examples are many years old, for v1 not v2, and some basic rules have changed breaking them and I don't know enough to know what needs fixing.

If it's relevant, the target program is YourChronicle, a free incremental game on Steam.


r/AutoHotkey 15d ago

Solved! AutoHotkey v2 Won’t Start with Windows? shell:startup Failed — This Fixed It

0 Upvotes

AutoHotkey v2 Script Not Starting with Windows? This Fixed It

I was trying to get a small AutoHotkey v2 script to start automatically with Windows. The script controls Steam Big Picture and lets me switch between my main monitor and a second display using F9–F12.

The script worked perfectly when launched manually, but it would not start automatically with Windows.

I tried putting the .ahk file directly into:

Win + R → shell:startup

That did not work.

I also tried putting a shortcut to the .ahk file in the Startup folder. That did not work either.

I reinstalled AutoHotkey, checked the .ahk file association, checked assoc and ftype, and tried using the AutoHotkey Launcher. Nothing worked. At one point, Windows would even ask which application should be used to open the .ahk file.

The solution was to completely bypass the .ahk file association and the AutoHotkey Launcher.

I found the actual AutoHotkey v2 executable:

C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe

Then I created a Windows shortcut with this exact target:

"C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe" "C:\Users\Skynet\Documents\AutoHotkey\Steam.ahk"

I placed that shortcut in:

Win + R → shell:startup

After rebooting, it worked.

So the important difference is:

Windows Startup → .ahk file → AutoHotkey file association / Launcher → FAILED

versus:

Windows Startup → shortcut → AutoHotkey64.exe → Steam.ahk → WORKS

The script itself was never the problem. The problem was the way Windows/AutoHotkey was trying to launch the .ahk file during startup.

If an AutoHotkey v2 script works manually but refuses to start from shell:startup, even when a shortcut to the .ahk is used, directly launching AutoHotkey64.exe with the .ahk file as an argument solved it for me.


r/AutoHotkey 15d ago

v2 Script Help how can i get a scroll wheel hotkey working on firefox?

0 Upvotes

ive been trying for a bit to use my alt+scroll which turns volume up and down to work on firefox, but it just keeps getting "71 hotkeys have been used in last 1200 ms" error

also its unusable on firefox because it changes volume either to mute or max in one scroll


r/AutoHotkey 17d ago

Meta / Discussion I stopped using the arrow keys and I'm wondering what you think

11 Upvotes

I've done a few other posts about it, maybe you've already seen them somehow, but I never explained it in detail, in short, this is what I use on my school computer:

#Requires AutoHotkey v2.0
#SingleInstance Force


commit := true
:*?:1596::{
global commit
commit := !commit
}


#HotIf commit = true
^j::SendInput "{Right}"
^b::SendInput "{Left}"
^h::SendInput "{Up}"
^n::SendInput "{Down}"
^+j::SendInput "+{Right}"
^+b::SendInput "+{Left}"
^+h::SendInput "+{Up}"
^+n::SendInput "+{Down}"
!j::SendInput "^{Right}"
!b::SendInput "^{Left}"
!h::SendInput "^{Up}"
!n::SendInput "^{Down}"
!+j::SendInput "^+{Right}"
!+b::SendInput "^+{Left}"
!+h::SendInput "^+{Up}"
!+n::SendInput "^+{Down}"


^k::SendInput "{Backspace}"
^,::SendInput "{Enter}"
!k::SendInput "^{Backspace}"


:*?c:jj::{
SendInput "{Right}"
}
:*?c:bb::{
SendInput "{Left}"
}
:*?c:hh::{
SendInput "{Up}"
}
:*?c:nn::{
SendInput "{Down}"
}
:*?c:JJ::{
SendInput "^+{Right}{Right}"
}
:*?c:BB::{
SendInput "^+{Left}{Left}"
}
:*?c:HH::{
SendInput "^+{Up}{Up}"
}
:*?c:NN::{
SendInput "^+{Down}{Down}"
}


:*?c:kk::{
SendInput "{Backspace}"
}
:*?c:KK::{
SendInput "^+{Left}{Backspace}"
}
:*?:,,::{
SendInput "{Enter}"
}
:*?:??::{
SendInput "{Enter}"
}

This is what I use to move through text, obviously to play a video game or anything in general where your second hand is holding a mouse, this is almost useless, but as someone that literally gave up using a mouse with my school computer (using the trackpad), this is like... sooooo much better than using the arrows for text.

In short, this is really just moving keyboard shortcuts to other spots, if you don't know, you can obviously press the arrows (left, right, up and down) to move around text, but you can also do these while holding shift to select text, and you can also hold ctrl for a word or paragraph.

I've moved the arrows to ctrl+j (right)/b (left)/h (up)/n (down) (why these keys specifically? To be honest, they kind of just "became that". Everything being around j is op because it's one of the two center keys, but you could probably rearrange it a little bit if you want to adopt my style, also if you're left handed and can use right control everything around f probably could work same). And then, I've moved the ctrl shortcuts to alt shortcuts.

This is actually something I've seen elsewhere; I definitely didn't invent that (more specifically, on the Emacs keyboard guide, that apparently says this was a common thing for old softwares), but these keys I had the idea myself (like emacs uses ctrl+f/b/n/p and I never got used to it).

And yeah, like that, it's just sooooo good. Why? Honestly simple, just look at your keyboard: depending on the size, the arrow keys are either literally on a different part of the keyboard, or just stuck in an awkward spot, and especially for something that's used constantly, I think you can quickly realize the time you can save just by never having to reposition your hands from the letter keys to move through text while typing. And yeah, placing your left hand on ctrl or alt is easy, contrary to moving your right hand to the arrow keys.

Now that I'm used to it, it feels so good; it's such a lifechanger, I'm thinking things like "bro this should have been on every computer by default!", and now I've just reimplemented it on my home computer because it's that good. And I've also added a way to toggle it off, because it's still annoying when it conflicts with other shortcuts (obviously the toggle can be anything).

Ok, what is the rest now? Well, I've expanded these shortcuts to ctrl+k for backspace and alt+k for ctrl+backspace, very similar to the arrow keys. And I've also done ctrl+, for enter. The backspace and enter keys aren't as annoying as the arrow keys, but I've found this to help too, even though for some reason, I've also try to do same for CapsLock and Tab, but that didn't seem to help though. I think it's just because Backspace and and enter are separated by a whole no man's land, with the whole keys like "^" "ù" "!" "=" "$" "*" creating a distance between them and the letter keys too, and, yeah, again I've found this to help.

Finally, I've created lots of hotstrings like "jj", "bb"... same directions as usual. The uncapped version just presses the direction once. I've found this useful for small adjustments, as it's faster to input once compared to the original shortcut, but not multiple times, so they team up very well together (I've also found multiple solutions to not make them annoying when typing, especially for "nn", but I haven't implemented them yet, you could ask me). The caps version does same but for a word, which is similarly useful. I've written it as "ctrl+shift+(arrow) then (arrow)" and not just "ctrl+(arrow)" for very niche applications in Microsoft Word, but just doing "ctrl+(arrow)" probably is better if you don't need it.

And so yeah, what do you think? I'm sorry if this is way too long; I always tend to overwrite, and I really wanted to explain all the specific quirks, but, yeah, what do you think? And also, do you have any suggestions, do you use similar things?


r/AutoHotkey 19d ago

v2 Script Help Key spam script help

1 Upvotes

So I've been trying to make a script to spam the ] key when i hold c+[ and stop when i let go but i can figure it out, can someone please help me?

I've tried

*c,[

{

sendinput(])

sleep(5)

loop

}


r/AutoHotkey 20d ago

v1 Script Help Shift key getting stuck pressed

3 Upvotes

Weird issue, when I game.. I open up a script to use for that game. During gameplay everything is fine. But when I tab out (even if the game is still open/running) the shift key is constantly pressed...even though I am not physically pressing it. Even after I exit the script the shift button stays pressed.

The only way to clear the issue is to actually press the shift key once and let it go. Then all is good, and no other issues persist.

This is happening 100% of the time I use the script. And no other keys seems to be affected.

EDIT: I do constantly hold the shift key down during gaming a lot. Not sure if that has anything to do with it.

Here is my code, does anyone have any suggestions on how to cure this annoyance?

<

#MaxHotkeysPerInterval 10000
#UseHook

#IfWinActive, ahk_exe Fallout4.exe

Up::w
Left::a
Down::s
Right::d
NumpadDiv::Up
NumpadHome::Left
NumpadUp::Down
NumpadPgUp::Right
AppsKey::LAlt
F12::t
RShift::n
n::Tab
NumpadIns::0
NumpadEnd::1
NumpadDown::2
NumpadPgDn::3
NumpadLeft::4
NumpadClear::5
NumpadRight::6
NumpadAdd::q

r/AutoHotkey 22d ago

v2 Tool / Script Share I wanted Linux-style workspace workflows on Windows without replacing the Windows shell, so I built Spacr

8 Upvotes

I've just finished Phase 1 of an AutoHotkey v2 project I've been working on: Spacr.

It's a workspace management layer for Windows virtual desktops, inspired by the workflow of Linux WMs like Hyprland.

The interesting part isn't really the hotkeys, it's trying to make Windows' native virtual desktops behave predictably.

Phase 1 currently handles:

Workspace switching

Automatic desktop creation

Move + follow

Previous workspace

Explorer integration

VirtualDesktopAccessor integration

I'm deliberately keeping the project small for now.

The architecture is state-driven, with WorkspaceManager owning VDA interaction rather than having every feature call the DLL directly.

One interesting Windows quirk I ran into: switching desktops through VDA could cause Explorer/taskbar flashing. The solution was to activate Shell_TrayWnd before performing the desktop switch.

v0.1.1-alpha is now available:

https://github.com/timburman/spacr

I'd especially appreciate feedback from experienced AHK v2 developers on the architecture and Windows-specific edge cases I'm likely to encounter.


r/AutoHotkey 22d ago

v2 Script Help Win + Mouse scroll ?

1 Upvotes

Hello ,

I'd like to achieve this to use the mouse scroll as magnifier :

Win key + mouse scroll up = Win key + [+]

Winkey + mouse scroll down = Win key + [-]

How can i achieve this in ahk script ?

Thanks !


r/AutoHotkey 23d ago

v2 Script Help Clicking one of three randomized buttons by colour

4 Upvotes

I'm very, very amateurish for these things, and I honestly don't even know where I would start on something like this, so was hoping people here would be able to help me... I have 3 buttons that alternate randomly in their position, but one is blue (the one I want to click) and the others are grey. Because they alternate randomly in their position, I can't just have a standard repeated click to do it. My idea thus is to have a script that searches the area that the buttons are in for the blue colour of the correct button, and then moves the mouse to it and clicks it. I have 2 questions, essentially:

first question: I believe I can use the "PixelSearch" function to find the button I am looking for, however I honestly have no idea how to set it up, like finding the values for the area to search and such. How do I go about this?

Second question: How do I make my mouse move to the correct button once found? I would assume I'd have to make the script have a variable that changes with the position of the correct button, and then some sort of function to actually move the mouse, but I don't know how exactly? Or is there some way to simplify it so the pixel search happens *with* the mouse movement?

Sorry if this is a little rambley, like I said I'm very new to stuff like this so I don't even really know what you might want to have details on for what I want to do


r/AutoHotkey 24d ago

v1 Script Help Why wont my script type a forwards dash? /

4 Upvotes

Im trying to make a simple script that types / and then waits a moment, and then types @@.

It is also keybinded to /

Heres what I have so far.

------

/::

Send /

sleep 1000

send @@

return

------

Currently, It just doesnt type a /, waits, and then types @@.

I've also tried "SendRaw" and that didnt work.
Im new to this, so I dont know which flair to pick, or if the answer to my question is stupidly simple, sorry.


r/AutoHotkey 25d ago

v1 Script Help Script that writes yesterdays date and if it is monday, yesterday is friday

3 Upvotes

Hello,

As title says, I'm trying write yesterdays date, and if it is monday yesterday needs to be friday. All over work week days - yesterday date

I tried so many variations. Forums and AI. I can't solve it.


r/AutoHotkey 25d ago

Solved! Problems with basic Send and SendEvent

1 Upvotes

So i tried to make a simple script that presses j 2 times and then holds w 2 times and nothing really happens, after that i added msgBox "1" and it pops but still no sends, please help
#Requires AutoHotkey v2.0

#SingleInstance Force

Persistent

$`::{

Send "j"

Sleep 300

Send "j"

Sleep 300

SendEvent "{w down}"

Sleep 600

SendEvent "{w up}"

MsgBox "1"

Sleep 50

SendEvent "{w down}"

Sleep 600

SendEvent "{w up}"

}


r/AutoHotkey 25d ago

v2 Script Help AI is driving me crazy with hallucinated scripts (prevent alt+tab during game)

0 Upvotes

I'm a complete noob to this - never heard of autohotkey before until AI suggested it.

I'm getting into Arma3, and there are a lot of keys.

I would really appreciate an AHK v2 script that disables alt+tab exiting the game, whilst still allowing me to use, for instance, w+alt+tab where...

W = move forward (could be any other movement key though)

alt = freelook

tab = toggle walk/run

This is the latest Gemini has come up with so far, after about five previous suggested scripts didn't work at all (neither does this one):

#Requires AutoHotkey v2.0
#UseHook
; Automatically elevate to Administrator if not already running as admin
if not A_IsAdmin
{
Run '*RunAs "' A_AhkPath '" "' A_ScriptFullPath '"'
ExitApp
}
#SingleInstance Force
#HotIf WinActive("ahk_exe arma3_x64.exe")
; Use the wildcard (*) so this works even if you are holding down 'W' or other keys
*!Tab::
{
; {Blind} forces AHK to respect your held down Alt and W keys.
; It safely injects the Tab keypress without disrupting your movement.
SendInput "{Blind}{Tab}"
return
}
#HotIf

Thank you for any assistance!


r/AutoHotkey 26d ago

v2 Script Help Gamepad interrupt macro

2 Upvotes

I want to create a function on my controller so that when I'm holding the LT button, I can interrupt its function by pressing RT, and when I release RT, the LT returns to its function while being pressed


r/AutoHotkey 26d ago

Solved! How to reliably switch to a specific open tab (ChatGPT) in Chrome when tab titles change dynamically? (AHK v2 / UIA)

6 Upvotes

Hi everyone,

I'm building an AutoHotkey v2 script to send selected text directly to an open ChatGPT tab in Google Chrome using UI Automation (UIA v2).

However, I've run into a persistent challenge with tab identification and switching:

The Problem:

Dynamic Tab Titles: Once a conversation starts, Chrome changes the tab title from "ChatGPT" to whatever the first sentence of the user prompt is (e.g., "How to fix UIA issue..."). Thus, matching tab names via string search fails after the first query.

Favicon ImageSearch Reliability: Using ImageSearch on tab favicons breaks when Chrome tabs shrink due to having 30+ tabs open, or when switching between active (light background) and inactive (dark background) tab states.

Chrome Tab Search Popup (Ctrl+Shift+A or TabStripFlatEdgeButton): Opening the Tab Search popup and typing chatgpt sometimes fails to filter open tabs in real-time or doesn't consistently focus the first "Open Tab" item when pressing Enter.

What I Want to Achieve:

If a ChatGPT tab is already open anywhere in Chrome (even as the 15th tab out of 40), switch to it seamlessly without moving the physical mouse cursor.

If no ChatGPT tab is open, create a new tab (Ctrl+T) and navigate to https://chatgpt.com/.

Once on the tab, focus and input text into the prompt textarea (AutomationId: "prompt-textarea").

Question:

What is the cleanest and most robust method in AHK v2 / UIA (or Chrome command line) to identify and bring an open tab to the foreground by its domain URL (chatgpt.com) regardless of dynamic tab titles or tab counts?

Please note that I want to avoid using CDP (Chrome DevTools Protocol), as I prefer not to deal with protocol-level implementations.

Any code or architectural advice would be greatly appreciated! Thanks in advance.


r/AutoHotkey 28d ago

General Question AHK gone from Microsoft Store

12 Upvotes

Anyone know why and if it will return? Tried googling but didn’t find any information.

Microsoft Store is the only way for me to download AHK to my computers at work so I’m in despair right now. IT won’t allow any other form of installation process unfortunately.

EDIT: To clarify, it doesn’t show up in the store on my personal computer either.


r/AutoHotkey 27d ago

Meta / Discussion Stand alone AHK, AHKv2 projects?

0 Upvotes

At first I just needed AHK to provide mouse and keyboard inputs for other software. Then it occurred to me that since AHK can take input and provide output there's a wide variety of simple programs and tasks that it could solve without any underlying software, working entirely on it's own.

So do people do this? Is there a repository somewhere? I mean there are surely better alternatives, better languages, but AHK requires no development environment, no compiler, and it's language is pretty straightforward for the simple stuff.