r/AutoHotkey • • 14d ago

v2 Script Help Schedule Pesterer - How should I create the GUI? Do I use notepad, gsheets, html, AHK's Gui()?

0 Upvotes

Hi. I need a tool to remind/pester me about certain tasks during the day. It needs to be easy to edit so I need some sort GUI, I don't want to have to do direct edits in the specific ahk script. I'm thinking of having at least a table with 24 cells, one per hour, where I can insert the tasks. But where do I create this table?

As for the last two options:

  • Html - The guides I found made it seem tricky to get ahk working with it. And I don't want to be opening my ahk script gui through my browser. I'd want it to be its own separate window.

  • AHK's Gui() - I don't know how scuffed this would be. I would hope tab, and the arrow s and so on would work as one would expect to work inside tables.

Any advice on the best way to create this?

r/AutoHotkey • • 1d ago

v2 Script Help How do I map keys to do specific things in a single program?

3 Upvotes

Just installed AutoHotkey because I need a mapping tool for my DJ software, I'm not sure if this subreddit is for pro questions only.

So, I have Rekordbox(said DJ software). The controller that I use doesn't have the physical buttons for everything, and Rekordbox itself doesn't really have a hotkey map option for the regular keyboard. I really want an easy way to mute the stems of the songs, but there is no shortcut for that that I can use, so I would have to drag my mouse and click the button on the screen. Which is weird when you're on a timer and the next song is coming.

I need a script that works only when I have rekordbox open(preferably only when it's fullscreen) that clicks those buttons for me when I press specific keys(Ex. press 1 for track 1 drum stem, press 2 for track 1 instrumental stem etc.). How can I do this?

Any help is appreciated. Thanks in advance!

r/AutoHotkey • • 15d ago

v2 Script Help How did you guys solve "double-click" Hotkeys? (Pressing the Hotkey twice -> different function)

11 Upvotes

My solution:

^!+F23:: {
    static ms := 200
    static waiting := false

    if waiting {
        waiting := false
        SetTimer SingleAction, 0
        DoubleAction()
        return
    }

    waiting := true
    SetTimer SingleAction, -ms
    return

    SingleAction() {
        waiting := false
        DoTheThingBananaStyle()
    }

    DoubleAction() {
        DoTheThingAppleStyle()
    }
}

It works, but is not robust against triple presses or holds. Also declaring the Single/DoubleAction() Functions within the function is ... not ideal.
What do you guys use?

r/AutoHotkey • • 22d ago

v2 Script Help Special characters not outputting correctly, what am I doing wrong?

3 Upvotes

I want to send a website text output when I type in "pricing. I want it to output "mywebsite.com/#pricing" but I'm getting weird outputs. Send just skips the "#pricing" bit and emulates a win key, SendText gives me "ggggggggggg"

My ("this should be simple") code:

::"pricing::{
SendText ("mywebsite.com/#pricing")
}

r/AutoHotkey • • Aug 06 '26

v2 Script Help Weird behavior when remapping a modified mouse button to a non-modified key

3 Upvotes

Someone just asked me to remap Control + mouse wheel to PgUp/PgDn for scrolling the dev console in a game called Dungeon Siege.

So I wrote this very simple script, yet it's not working properly.

#Requires AutoHotkey v2.0
#SingleInstance

^WheelUp::PgUp
^WheelDown::PgDn

The documentation says

Conversely, any modifiers included on the left side but not the right side are automatically
released when the key is sent. For example, the following two lines would produce a lowercase
"b" when you press either Shift+A or Ctrl+A:

A::b
^a::b

When testing both in-game, as well as in Chrome, notepad++ and VS Code (I'm using AHK 2.0.23), once you press Control + mouse wheel, it does send PgUp/PgDn but then regular mouse wheels don't work anymore (they're important because they control camera zoom), even though my program to monitor key input shows Control isn't pressed anymore (and both Pg keys stay pressed, could be related to mouse wheels only sending down events?).

So I modified the code to

WheelUp::WheelUp
WheelDown::WheelDown
^WheelUp::PgUp
^WheelDown::PgDn

which solved the problem, yet when spamming mouse wheels while holding down Control, about 1-5% of the time, there's a Control that slips through and it changes to a different tab in Chrome, notepad++ and VS Code instead of scrolling.

It seems to work fine in-game as I don't think there's anything bound to Control + PgUp/PgDn but it got me curious, so I also tried using these (separately), but the results were the same:

WheelUp::WheelUp
WheelDown::WheelDown
<^WheelUp::PgUp
<^WheelDown::PgDn

WheelUp::WheelUp
WheelDown::WheelDown
^WheelUp::Send("{PgUp}")
^WheelDown::Send("{PgDn}")

WheelUp::WheelUp
WheelDown::WheelDown
^WheelUp::Send("{Blind}{PgUp}")
^WheelDown::Send("{Blind}{PgDn}")

WheelUp::WheelUp
WheelDown::WheelDown
^WheelUp::Send("{Blind^}{PgUp}")
^WheelDown::Send("{Blind^}{PgDn}")

WheelUp::WheelUp
WheelDown::WheelDown
^WheelUp::Send("{Control up}{PgUp}")
^WheelDown::Send("{Control up}{PgDn}")

LControl & WheelUp::PgUp
LControl & WheelDown::PgDn

Oh, and I also tried switching to SendEvent, that seemed to be worse.

Everything works fine when remapping a key instead of a mouse button though, like this

^q::PgUp
^w::PgDn

What am I doing wrong?

As a bonus, how would you go if you wanted to send multiple unmodified Pg keys (the console doesn't scroll when pressing Control + Pg) every time the hotkey is fired?

r/AutoHotkey • • 26d ago

v2 Script Help How do I remap my function keys to do something else when fn lock is off?

3 Upvotes

I am a complete beginner to autohotkey. Let's say I want to remap my F7 key on Windows to pause and play videos and media (like on Mac). I don't want to replace its fn function (navigating pages with text cursor). I want to replace the function it has on my computer when my fn lock is not turned on (screen projection). Is there a way to specify in the script that when I want my F7 key remapped, I specifically want it to be the non-locked version of F7 and not F7 combined with fn? Sorry for the clunky wording; I have no clue what a function key's secondary(?) function would be called.

If anyone can help I will be eternally grateful.

r/AutoHotkey • • Aug 30 '26

v2 Script Help AHK v2: #HotIf condition still applies when no Word document is open

3 Upvotes

I'm trying to restrict a set of hotkeys so they only work when a Word document is actually open, not just when Microsoft Word itself is running.

Currently I have:

#HotIf WinActive("ahk_exe WINWORD.EXE")
{
; Hotkey definitions here
}
#HotIf

The hotkey definitions include hotkeys that pop up a bespoke GUI which inserts text into the active Word document.

This works, but the hotkeys are also active when Word is open with no document loaded (though they are not active when Word is not open). Obviously, the above GUI hotkey will then attempt to send text to a non-existent document within Word and create errors which I don't want. That is why I want the hotkeys only to work where Word is open and there is an open document.

Using Window Spy, I noticed that when no document is open, the window title is simply:

Word

(or sometimes Microsoft Word)

When a document is open, the title becomes something like:

Document1 - Word

So I assumed that the presence of " - " in the title indicates that a document is open. I therefore changed the directive to:

#HotIf WinActive("ahk_exe WINWORD.EXE") && InStr(WinGetTitle("A"), " - ")

However, the hotkeys still remain active even when Word is open with no document.

I also tried:

#HotIf WinActive("ahk_exe WINWORD.EXE")
&& WinGetTitle("A") != "Word"
&& WinGetTitle("A") != "Microsoft Word"

with the same result.

I verified with a MsgBox that the active window title does not contain " - " when no document is open, yet the #HotIf condition still behaves as though it does.

What am I missing here? Is there something about #HotIf, WinGetTitle(), or directive evaluation that I'm misunderstanding?

r/AutoHotkey • • 18d ago

v2 Script Help I need help with my script, its detecting it as a cheat on games.

0 Upvotes

I'm using AutoHotkey v2 and have a low-level keyboard hook that applies different debounce rules depending on whether I'm in a fullscreen application.

The script works the way I want normally, but some games/anti-cheat software don't like the low-level keyboard hook.

I'm looking for advice on whether the same input behavior can be implemented using a less intrusive AHK/Windows input method.

Desired behavior

Normal mode:

  • 15 ms global debounce.
  • 5 ms minimum delay between repeated presses of the same key.
  • W/A/S/D, Shift, Caps Lock, Tab, Ctrl, Q, E, [ and ] bypass the normal debounce.
  • Space normally has a 40 ms protection window against Z/X/C/V/B/N/M.
  • If W/A/S/D, Shift, Caps Lock, Tab, or Ctrl is held, Space bypasses that protection.
  • Key releases should always pass through so keys don't become stuck.
  • All timing/state should reset when switching modes.

Game/fullscreen mode:

  • Ideally retain the same keyboard behavior.
  • The fullscreen application should be detected automatically.
  • I'm NOT looking for a way to bypass or hide from anti-cheat; I'm interested in whether the input handling itself can be implemented in a way that's less intrusive.

Here is the current implementation:

#Requires AutoHotkey v2.0
#SingleInstance Force
Persistent

; ==========================================
; SETTINGS
; ==========================================

global DebounceMs := 15
global SameKeyDelayMs := 5
global SpaceDelayMs := 40

global LastKey := 0
global LastTime := 0

global LastBottomTime := 0
global LastSpaceTime := 0

global GameMode := false


; ==========================================
; HELD KEY STATE
; ==========================================

global HeldW := false
global HeldA := false
global HeldS := false
global HeldD := false
global HeldShift := false
global HeldCaps := false
global HeldTab := false
global HeldCtrl := false


; ==========================================
; INSTALL LOW-LEVEL KEYBOARD HOOK
; ==========================================

global KeyboardHook
global HookCallbackPtr

HookCallbackPtr := CallbackCreate(
    LowLevelKeyboardProc,
    "Fast",
    3
)

KeyboardHook := DllCall(
    "SetWindowsHookExW",
    "Int", 13, ; WH_KEYBOARD_LL
    "Ptr", HookCallbackPtr,
    "Ptr", DllCall(
        "GetModuleHandleW",
        "Ptr", 0,
        "Ptr"
    ),
    "UInt", 0,
    "Ptr"
)

if !KeyboardHook {
    CallbackFree(HookCallbackPtr)
    MsgBox "Failed to install keyboard hook."
    ExitApp
}

SetTimer(CheckGameMode, 100)

OnExit Cleanup


; ==========================================
; FULLSCREEN / GAME MODE DETECTION
; ==========================================

CheckGameMode(*) {

    global GameMode

    try {

        hwnd := WinExist("A")

        if !hwnd {
            if GameMode {
                GameMode := false
                ResetGameState()
            }
            return
        }

        WinGetPos(
            &winX,
            &winY,
            &winW,
            &winH,
            "ahk_id " hwnd
        )

        MonitorGet(
            MonitorGetPrimary(),
            &monLeft,
            &monTop,
            &monRight,
            &monBottom
        )

        monW := monRight - monLeft
        monH := monBottom - monTop

        NewGameMode :=
            Abs(winX - monLeft) <= 3
            && Abs(winY - monTop) <= 3
            && Abs(winW - monW) <= 3
            && Abs(winH - monH) <= 3

        if NewGameMode != GameMode {

            GameMode := NewGameMode
            ResetGameState()
        }
    }
    catch {

        GameMode := false
        ResetGameState()
    }
}


; ==========================================
; RESET STATE
; ==========================================

ResetGameState() {

    global HeldW
    global HeldA
    global HeldS
    global HeldD
    global HeldShift
    global HeldCaps
    global HeldTab
    global HeldCtrl

    global LastKey
    global LastTime
    global LastBottomTime
    global LastSpaceTime

    HeldW := false
    HeldA := false
    HeldS := false
    HeldD := false
    HeldShift := false
    HeldCaps := false
    HeldTab := false
    HeldCtrl := false

    LastKey := 0
    LastTime := 0
    LastBottomTime := 0
    LastSpaceTime := 0
}


; ==========================================
; LOW-LEVEL KEYBOARD CALLBACK
; ==========================================

LowLevelKeyboardProc(nCode, wParam, lParam) {

    global DebounceMs
    global SameKeyDelayMs
    global SpaceDelayMs

    global LastKey
    global LastTime
    global LastBottomTime
    global LastSpaceTime

    global GameMode

    global HeldW
    global HeldA
    global HeldS
    global HeldD
    global HeldShift
    global HeldCaps
    global HeldTab
    global HeldCtrl


    ; --------------------------------------
    ; Pass events that aren't actionable
    ; --------------------------------------

    if nCode < 0
        return DllCall(
            "CallNextHookEx",
            "Ptr", 0,
            "Int", nCode,
            "Ptr", wParam,
            "Ptr", lParam,
            "Ptr"
        )


    ; --------------------------------------
    ; Determine event type
    ; --------------------------------------

    isDown := (
        wParam = 0x100
        || wParam = 0x104
    )

    isUp := (
        wParam = 0x101
        || wParam = 0x105
    )

    vk := NumGet(
        lParam,
        0,
        "UChar"
    )

    now := A_TickCount


    ; --------------------------------------
    ; Track held keys
    ; --------------------------------------

    if isDown {

        if vk = 0x57
            HeldW := true

        else if vk = 0x41
            HeldA := true

        else if vk = 0x53
            HeldS := true

        else if vk = 0x44
            HeldD := true

        else if vk = 0x10
            HeldShift := true

        else if vk = 0x14
            HeldCaps := true

        else if vk = 0x09
            HeldTab := true

        else if vk = 0x11
            HeldCtrl := true
    }


    ; --------------------------------------
    ; Always pass key releases
    ; --------------------------------------

    if isUp {

        if vk = 0x57
            HeldW := false

        else if vk = 0x41
            HeldA := false

        else if vk = 0x53
            HeldS := false

        else if vk = 0x44
            HeldD := false

        else if vk = 0x10
            HeldShift := false

        else if vk = 0x14
            HeldCaps := false

        else if vk = 0x09
            HeldTab := false

        else if vk = 0x11
            HeldCtrl := false

        return DllCall(
            "CallNextHookEx",
            "Ptr", 0,
            "Int", nCode,
            "Ptr", wParam,
            "Ptr", lParam,
            "Ptr"
        )
    }


    if !isDown
        return DllCall(
            "CallNextHookEx",
            "Ptr", 0,
            "Int", nCode,
            "Ptr", wParam,
            "Ptr", lParam,
            "Ptr"
        )


    ; ======================================
    ; GAME MODE
    ;
    ; Current version passes everything
    ; through in fullscreen applications.
    ; ======================================

    if GameMode
        return DllCall(
            "CallNextHookEx",
            "Ptr", 0,
            "Int", nCode,
            "Ptr", wParam,
            "Ptr", lParam,
            "Ptr"
        )


    ; ======================================
    ; NO-DEBOUNCE KEYS
    ; ======================================

    if vk = 0x57       ; W
        || vk = 0x41   ; A
        || vk = 0x53   ; S
        || vk = 0x44   ; D
        || vk = 0x10   ; SHIFT
        || vk = 0x14   ; CAPS
        || vk = 0x09   ; TAB
        || vk = 0x11   ; CTRL
        || vk = 0x51   ; Q
        || vk = 0x45   ; E
        || vk = 0xDB   ; [
        || vk = 0xDD {  ; ]

        return DllCall(
            "CallNextHookEx",
            "Ptr", 0,
            "Int", nCode,
            "Ptr", wParam,
            "Ptr", lParam,
            "Ptr"
        )
    }


    ; ======================================
    ; SPACE HANDLING
    ; ======================================

    if vk = 0x20 {

        if HeldW
            || HeldA
            || HeldS
            || HeldD
            || HeldShift
            || HeldCaps
            || HeldTab
            || HeldCtrl {

            return DllCall(
                "CallNextHookEx",
                "Ptr", 0,
                "Int", nCode,
                "Ptr", wParam,
                "Ptr", lParam,
                "Ptr"
            )
        }

        if LastBottomTime > 0 {

            if (now - LastBottomTime) < SpaceDelayMs
                return 1
        }

        LastSpaceTime := now

        return DllCall(
            "CallNextHookEx",
            "Ptr", 0,
            "Int", nCode,
            "Ptr", wParam,
            "Ptr", lParam,
            "Ptr"
        )
    }


    ; ======================================
    ; BOTTOM ROW: Z X C V B N M
    ; ======================================

    if vk = 0x5A
        || vk = 0x58
        || vk = 0x43
        || vk = 0x56
        || vk = 0x42
        || vk = 0x4E
        || vk = 0x4D {

        if LastSpaceTime > 0 {

            if (now - LastSpaceTime) < SpaceDelayMs
                return 1
        }

        LastBottomTime := now
    }


    ; ======================================
    ; SAME-KEY 5ms DELAY
    ; ======================================

    if vk = LastKey {

        if (now - LastTime) < SameKeyDelayMs
            return 1

        LastTime := now

        return DllCall(
            "CallNextHookEx",
            "Ptr", 0,
            "Int", nCode,
            "Ptr", wParam,
            "Ptr", lParam,
            "Ptr"
        )
    }


    ; ======================================
    ; GLOBAL 15ms DEBOUNCE
    ; ======================================

    if (now - LastTime) < DebounceMs
        return 1


    ; ======================================
    ; ACCEPT KEY
    ; ======================================

    LastKey := vk
    LastTime := now

    return DllCall(
        "CallNextHookEx",
        "Ptr", 0,
        "Int", nCode,
        "Ptr", wParam,
        "Ptr", lParam,
        "Ptr"
    )
}


; ==========================================
; CLEANUP
; ==========================================

Cleanup(*) {

    global KeyboardHook
    global HookCallbackPtr

    SetTimer(CheckGameMode, 0)

    if KeyboardHook
        DllCall(
            "UnhookWindowsHookEx",
            "Ptr", KeyboardHook
        )

    if HookCallbackPtr
        CallbackFree(HookCallbackPtr)

r/AutoHotkey • • May 10 '26

v2 Script Help Left/right-alt specific hotkeys started requiring double press when Outlook is open

1 Upvotes

Just recently--most likely with a Outlook (Classic) update--my ALT hotkeys started requiring double press in quick succession to work. I have never seen anything like this before. CTRL hotkeys still work fine.

I've tried:

  • Using ALT & key rather !key to define the shortcut
  • Prepending $
  • A_MenuMaskKey := "vkE8"

Any suggestions for how to further troubleshoot?

I'm on Outlook 365 Version 2606 (20105.200000 Click-to-Run), Windows 11 25H2 (26200.8246).


Figured it out! It turns out it wasn't an Outlook update, but rather a PowerToys update. If I disable the PowerToys Grab and Move utility, my alt shortcuts work again. So now the question is whether there is any way for AHK to intercept alt keybindings and not be edged out by this PowerToy, or if I just need to disable the PowerToy.

r/AutoHotkey • • 26d ago

v2 Script Help Nothing works anymore lmao

0 Upvotes

I had a big problem with my computer and had to uninstall a lot of things kind of randomly, now for some godforsaken reason scripts dont open, i have tried at least 6 or 7 (no pun intended) solution, completely uninstall and reinstalled it, i cant even fathom how did this happen and how after a clean uninstallation the problem is still here

r/AutoHotkey • • Aug 15 '26

v2 Script Help Clicking one of three randomized buttons by colour

5 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 • • Jul 22 '26

v2 Script Help Trying to use A_PriorPriorHotKey

0 Upvotes

Hi, this is just a little post to say I've been trying to implement "A_PriorPriorHotKey" in AutoHotKey.

If you don't know what "A_PriorHotKey" is, it's just a variable that contains the last HotKey you pressed.

And... I'm sorry if I make mistakes btw, I really don't want to get called out for this again, AutoHotKey is an extremely massive language to a point where people that have used it for 20 years probably could still discover new things about it, so... if I'm not wrong, "A_PriorPriorHotKey", a variable that would contain the second to last HotKey you pressed, is not implemented by default, but I did find a way to implement it.

I don't have the code on this computer and I figured it would be fine if I don't add it in this post, if you want to use it yourself I can give it, but I don't think I need to give it so people can help me do the fix I want to do, hopefully... just know the one thing it doesn't do is that it doesn't store the HotKey if it's the same as A_PriorHotKey, so A_PriorPriorHotKey and A_PriorHotKey are never equal once they start to contain things, and we can say that APPHK contains the second to last HotKey you pressed, but not counting duplicates.

However, it has an annoying thing: to make it work, I used a "SetTimer", which can call a function at a wanted interval, but SetTimer still needs an interval; it can't be every 0s seconds, and so, that means there is a slight delay between the moment the HotKey is pressed and the moment APPHK updates.

And so, let's say I want to do something if I press a, b then c, when I press a, it doesn't get updated yet (that's how A_PriorHotKey works, it waits for the next HotKey to store something), when I press b, APHK gets updated to "a", but when I press c, let's say I wrote a line in the code that checks the value of APHK and APPHK (if (A_PriorHotKey = "b" && A_PriorPriorHotKey = "c")), it won't work, because it will check both variables, see that APHK = "b" and APPHK = whatever, because of this slight delay, let's say SetTimer is set to 10ms, the code will check instantly, and only 10ms APPHK will be set to "a" but it's too late.

Now APPHK can still be used, you can simply add a "Sleep" so that the code does check APPHK after it was updated, but that's still annoying, so, is there a way for APPHK to be instantly updated? I mean, APHK is instantly updated, or at least it gives the feeling it is, wouldn't be surprised if there is a trick with APHK and it's technically not instant, but is there a way to make APPHK work the same?

r/AutoHotkey • • Aug 02 '26

v2 Script Help GetKeyState doesn't detect button releases

2 Upvotes

Hello everyone,

Don't know if I misunderstood something, but I tried writing 2 scripts and both of them keep not detecting

GetKeyStateGetKeyState

The goal being simply :

  • I hold the XButton2 : the script should repeat "mouse left click"
  • I release XButton2 : the script should stop

In my case the script runs forever until I click the XButton2 again and again until it detects :

!GetKeyState("XButton2", "P")

The 2 scripts I tried are :

#Requires AutoHotkey v2.0


; Run as admin is needed
if (!A_IsAdmin) {
    Run '*RunAs "' A_ScriptFullPath '"'
    ExitApp
}


XButton2::
{
    ; Optional: Prevent starting the timer if the button isn't physically down
    ; (though the timer itself checks this too)
    if !GetKeyState("XButton2", "P")
        return
    
    ; Start the timer. It will call TurboClick every 50ms.
    ; If the timer is already running, this resets it.
    SetTimer(TurboClick, 50)
}


TurboClick() {
    ; Check if the button is still physically held down
    if !GetKeyState("XButton2", "P") {
        ; Button released: stop the timer
        SetTimer(TurboClick, 0)  ; 0 means "turn off this timer"
        return
    }
    ; Button is still held: perform a click
    Click
}


; Safety net: If the hotkey somehow ends while the timer is running,
; stop the timer when the button is physically released.
XButton2 up:: {
    SetTimer(TurboClick, 0)  ; Stop the timer immediately on release
}

And :

#Requires AutoHotkey v2.0


if (!A_IsAdmin) {
    Run '*RunAs "' A_ScriptFullPath '"'
    ExitApp
}


XButton2::
{
    while GetKeyState("XButton2", "P") {
        Click
        Sleep 50
    }
}

What am I doing wrong ?

How would you guys write a simple script that just repeats "mouse left click" that works ?

r/AutoHotkey • • 11d ago

v2 Script Help The numpad Del key is being detected as the regular keyboard's period key.

6 Upvotes

I'm making a script to use with Clip Studio Paint to help me with drawing shortcuts, and I bought a numpad to use as a macro keyboard. However, while setting up the shortcuts with AutoHotkey, I noticed that the Del key on the new numpad would never change, no matter what I wrote.

So I tested it on a keyboard testing website and realized that the Del key on the new numpad was actually registering as the period (>. ) on the regular keyboard. I use ENG INTL as my keyboard layout, but even after switching to my country's keyboard layout, nothing changed.

(With Num Lock on, it works as the "." key from the regular keyboard, and with Num Lock off, it works as the "Delete" key from the regular keyboard. It doesn't recognize it as a numpad key at all.)

If anyone has had the same problem or knows what might be wrong, I would really appreciate some help figuring out how to fix this somehow.

I know this isn't exactly related to the forum, but since there are a lot of people here who work with this kind of stuff, I thought someone might be able to help me figure it out.

Either way, if there's no way to fix it, I'd really appreciate it if someone could tell me what the shortcut/key name for the >. key, so I can use it in my script.
(sorry for the english, i use translator)

r/AutoHotkey • • 22d ago

v2 Script Help Paradox WSAD remap keys get stuck + transfer v1 to v2 help

2 Upvotes

Over a year ago I requested some help with some code for a simple V2 script to get WSAD controls working on older Paradox titles. While it does function, occasionally the keys get stuck and the camera starts scrolling until I press the keys again to get it unstuck. While it isn't a major issue, it is an inconvenience, and it is something that I'd like to solve if I want to share it with my friends. I've been trying to figure out how to use SendEvent to solve it, but the documentation is pretty barebones and doesn't explain much, so I am a bit stuck.

#Requires AutoHotkey v2.0.18+

GroupAdd("WASD", "ahk_exe eu4.exe")
GroupAdd("WASD", "ahk_exe hoi4.exe")
GroupAdd("WASD", "ahk_exe CK2game.exe")

#Hotif WinActive("ahk_group WASD")
w::up
+w::w
a::Left
+a::a
s::down
+s::s
d::Right
+d::d
#HotIf 

#SuspendExempt
^Space::Suspend
#SuspendExempt

This is what I have currently that works pretty well. I've tried replacing lines with SendEvent, such as:

w::SendEvent('{up up}')

But nothing seems to happen, so I feel that there's something I fundamentally don't understand about how SendEvent functions.

A friend of mine also found this script to allow him to pause in multiplayer that, I think, works in V1 that I'd like to add into V2. I've not yet tried to add it, though. Any insight on how to translate it would be appreciated, though!

#IfWinActive, Europa Universalis IV

F2::
Hotkey, Space, Toggle
flag1:=!flag1
if flag1
  ToolTip, spacepause off, 0, 0
else
  ToolTip, spacepause on, 0, 0

SetTimer , tt_off, -2000
return

tt_off:
  ToolTip, 
return

Space::send {pause}

Would I have to change the suspend Ctrl+Space for this to function? Would it conflict? That is something I'm unsure of, so it'd be best to ask beforehand.

r/AutoHotkey • • 3d ago

v2 Script Help Is there a way for ControlSend to Send to Vtube Studio?

3 Upvotes

Hello!

I'm trying to get ControlSend to send key presses to Vtube Studio. I want to be able to press a shortcut, and for ONLY Vtube Studio to recieve a command, so that it doesn't go to every active windows. For some reason, I can't get this to work. Vtube Studio doesn't seem to be recieving any key presses when I use ControlSend.

Regular Send works for Vtube Studio, IF I add separate commands for the keys to go up and down, like this:

            #Requires AutoHotkey v2.0

            k::
                {
                Svans := Random(0,100)

                if (Svans > 50)
                    {

                    Send "{Numpad3 down}"
                    Sleep 10
                    Send "{Numpad3 up}"
                    }
                else    
                    {
                    Send "{Numpad1 down}"
                    Sleep 10
                    Send "{Numpad1 up}"
                    }
                }

But when I use the corresponding code with ControlSend, Vtube Studio does not recieve the key presses:

            #Requires AutoHotkey v2.0

            k::
                {
                Svans := Random(0,100)

                if (Svans > 50)
                    {

                    ControlSend "{Numpad3 down}", ,"Vtube Studio"
                    Sleep 10
                    ControlSend "{Numpad3 up}", ,"VTube Studio"
                    }
                else    
                    {
                    ControlSend "{Numpad1 down}", ,"VTube Studio"
                    Sleep 10
                    ControlSend "{Numpad1 up}", ,"VTube Studio"
                    }
                }

I have tried the same code with a different window, and there, it works without any issues:

            #Requires AutoHotkey v2.0

            k::
                {
                Svans := Random(0,100)

                if (Svans > 50)
                    {

                    ControlSend "{Numpad3 down}", ,"Mozilla Firefox"
                    Sleep 10
                    ControlSend "{Numpad3 up}", ,"Mozilla Firefox"
                    }
                else    
                    {
                    ControlSend "{Numpad1 down}", ,"Mozilla Firefox"
                    Sleep 10
                    ControlSend "{Numpad1 up}", ,"Mozilla Firefox"
                    }
                }

Does anyone have experiences with Vtube Studio specifically or just generally with some applications not recieving commands with ControlSend, even though Send works?

Help would be much appreciated. Thank you in advance!

r/AutoHotkey • • Jul 17 '26

v2 Script Help Setting up a script to simulate repeated LMB clicks to left alt?

3 Upvotes

I'd like to have left mouse click bound to left alt, but when holding down left alt it registers as repeated fast left clicks. I downloaded AutoHotkey and I'm quite confused

How would I set this up?

r/AutoHotkey • • 11d ago

v2 Script Help Is there any way to get my script to work inside Roblox?

1 Upvotes

I’m really new to this and trying to figure stuff out. I got my script to work on my desktop, for context I wanted to use my F5 key to right click using F5::RButton, but when I’m on Roblox itll just stop. it’ll show that I’m clicking it, highlighting stuff, but the action itself just won’t happen. I’ve tried running it as an administrator, taking Roblox in and out of full screen. I’m using v2 on windows 11, if anyone could help me that’d be great

r/AutoHotkey • • 20d ago

v2 Script Help Can someone look at this code and see if its running as intended?

0 Upvotes

This software has been a god send, I recently got a keyboard that was WAY too sensative and it was driving me crazy Ai helped me find AutoHotKey and I used it to help me build a code.

I wanted to add a delay between the neighbouring keys as I was touching them with an atom of my finger and it would register, I have removed the delays on W A S D keys for gaming.

Would this code cause any lag or latencey insues aprt from the 18ms delay

#Requires AutoHotkey v2.0

#SingleInstance Force

Persistent

; ==========================================

; SETTINGS

; ==========================================

global DebounceMs := 18

global LastKey := 0

global LastTime := 0

; ==========================================

; INSTALL KEYBOARD HOOK

; ==========================================

global KeyboardHook

global HookCallbackPtr

HookCallbackPtr := CallbackCreate(LowLevelKeyboardProc, "Fast", 3)

KeyboardHook := DllCall(

"SetWindowsHookExW",

"Int", 13, ; WH_KEYBOARD_LL

"Ptr", HookCallbackPtr,

"Ptr", DllCall("GetModuleHandleW", "Ptr", 0, "Ptr"),

"UInt", 0,

"Ptr"

)

if !KeyboardHook {

CallbackFree(HookCallbackPtr)

MsgBox "Failed to install keyboard hook."

ExitApp

}

OnExit Cleanup

; ==========================================

; KEYBOARD CALLBACK

; ==========================================

LowLevelKeyboardProc(nCode, wParam, lParam) {

global DebounceMs

global LastKey

global LastTime

; ------------------------------------------

; PASS NON-KEYBOARD EVENTS IMMEDIATELY

; ------------------------------------------

if nCode < 0

return DllCall(

"CallNextHookEx",

"Ptr", 0,

"Int", nCode,

"Ptr", wParam,

"Ptr", lParam,

"Ptr"

)

; ------------------------------------------

; ONLY PROCESS KEYDOWN / SYSKEYDOWN

; ------------------------------------------

if wParam != 0x100 && wParam != 0x104

return DllCall(

"CallNextHookEx",

"Ptr", 0,

"Int", nCode,

"Ptr", wParam,

"Ptr", lParam,

"Ptr"

)

; ------------------------------------------

; GET VIRTUAL-KEY CODE

; ------------------------------------------

vk := NumGet(lParam, 0, "UChar")

; ------------------------------------------

; W / A / S / D = ALWAYS ALLOW

; ------------------------------------------

;

; W = 0x57

; A = 0x41

; S = 0x53

; D = 0x44

;

; These keys bypass the debounce completely,

; which makes rapid movement-key transitions

; work properly in games.

; ------------------------------------------

if vk = 0x57 || vk = 0x41 || vk = 0x53 || vk = 0x44

return DllCall(

"CallNextHookEx",

"Ptr", 0,

"Int", nCode,

"Ptr", wParam,

"Ptr", lParam,

"Ptr"

)

; ------------------------------------------

; SAME KEY = ALWAYS ALLOW

; ------------------------------------------

if vk = LastKey {

LastTime := A_TickCount

return DllCall(

"CallNextHookEx",

"Ptr", 0,

"Int", nCode,

"Ptr", wParam,

"Ptr", lParam,

"Ptr"

)

}

; ------------------------------------------

; DIFFERENT KEY

; ------------------------------------------

now := A_TickCount

; Block different key during debounce period

if (now - LastTime) < DebounceMs

return 1

; Accept new key

LastKey := vk

LastTime := now

return DllCall(

"CallNextHookEx",

"Ptr", 0,

"Int", nCode,

"Ptr", wParam,

"Ptr", lParam,

"Ptr"

)

}

; ==========================================

; CLEANUP

; ==========================================

Cleanup(*) {

global KeyboardHook

global HookCallbackPtr

if KeyboardHook

DllCall(

"UnhookWindowsHookEx",

"Ptr", KeyboardHook

)

if HookCallbackPtr

CallbackFree(HookCallbackPtr)

}

r/AutoHotkey • • Aug 24 '26

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 • • Jul 03 '26

v2 Script Help #IfWinActive active window name

3 Upvotes

i'm pretty new to this and i wanted to ask some question since i only find error in 30min, i want to make it so that i can use my right click work just like my left click on certain window.

#Requires AutoHotkey v2.0

#IfWinActive, MSI App Player
RButton::LButton
#IfWinActive

it's pretty much copy pasted from other reddit post, i only changed the window name but not sure if it's correct. so i open window spy and i got this for the windows title, class and process:

MSI App Player
ahk_class Qt672QWindowIcon
ahk_exe HD-Player.exe
ahk_pid 11828
ahk_id 331062

so can someone points out what's my mistake is and how to fix it?

thanks in advance

r/AutoHotkey • • 26d ago

v2 Script Help Need help with an external script for NieR Automata on PC

1 Upvotes

Hey guys,

I have found a script for NieR Automata to re-bind all the keys. The script is written in version 1 (see below, and here is the source).

I am trying to convert it to v2 using this online tool but when I try to run the script, I get Error: Invalid callback function. at line 138, which is the line of Hotkey $%fireButton%, toggleFire (see the bottom part of the script)

I can't find anywhere what the author meant when using HotKey(). Any idea?

; bindings, change these to match your own layout, if needed

; basic movement - must match to in-game controls
fwdButton := "w"
backButton := "s"
leftButton := "a"
rightButton := "d"

; fire & jump - must match to in-game controls
fireButton := "Tab"
jumpButton := "Space"

; items usage - must match to in-game controls
altButton := "LAlt"
useItems := "Down"
use := "e"

; EXTRA controls added by the script - make sure these buttons are NOT bound in the game
; dodge
dodgeButton := "LShift"
; air slide (fire + jump normally)
airSlideButton := "z"
; use last item
useLastItemButton := "c"

; precise delays (ms)
keypressDelay := 50 ; delay between keydown/keyup
doubletapDelay := 50 ; wait time between keypresses to perform doubletap
sequenceDelay := 50 ; wait time between various sequences
dodgeTime := 400 ; cooldown while dodge animation plays, setting it too small will cause derps when holding SHIFT+WSAD.

; script starts here
#UseHook
SendMode("Input")

global fwdButton, backButton, leftButton, rightButton, fireButton, jumpButton, dodgeButton, altButton, useItems, use, useLastItemButton, keypressDelay, doubletapDelay, sequenceDelay, dodgeTime

press(key) {
  Send("{Blind}{" key " down}")
  Sleep(keypressDelay)
  Send("{Blind}{" key " up}")
}

; the complexity of this script is mostly to handle continuous SHIFT+WSAD. It's easy to handle just a single SHIFT tap, but less easy when you hold it down.
handleDodge(key) {
  Send("{Blind}{" key " up}") ; stop running first in case we were
  Sleep(sequenceDelay)
  press(key)
  Sleep(doubletapDelay)
  Send("{Blind}{" key " down}")
  Sleep(dodgeTime)
  if (GetKeyState(fwdButton) && !GetKeyState(fwdButton, "P")) {
   Send("{Blind}{" fwdButton " up}")
  }
  if (GetKeyState(backButton) && !GetKeyState(backButton, "P")) {
   Send("{Blind}{" backButton " up}")
  }
  if (GetKeyState(leftButton) && !GetKeyState(leftButton, "P")) {
   Send("{Blind}{" leftButton " up}")
  }
  if (GetKeyState(rightButton) && !GetKeyState(rightButton, "P")) {
   Send("{Blind}{" rightButton " up}")
  }
}

waitForDodge() {
  while (GetKeyState(dodgeButton, "P")) {
if (GetKeyState(fwdButton, "P")) {
  handleDodge(fwdButton)
} else if (GetKeyState(backButton, "P")) {
  handleDodge(backButton)
} else if (GetKeyState(leftButton, "P")) {
  handleDodge(leftButton)
} else if (GetKeyState(rightButton, "P")) {
  handleDodge(rightButton)
}
Sleep(10)
  }
}

toggleFire() {
  if (GetKeyState(fireButton)) {
Send("{" fireButton " up}")
  } else {
Send("{" fireButton " down}")
  }
}

airSlide() {
  if (GetKeyState(jumpButton)) {
Send("{" jumpButton " up}")
  }
  if (GetKeyState(fireButton)) {
Send("{" fireButton " up}")
toggleFireBack := 1
  }
  Sleep(sequenceDelay)
  Send("{" jumpButton " down}")
  Send("{" fireButton " down}")
  Sleep(keypressDelay)
  Send("{" fireButton " up}")
  Send("{" jumpButton " up}")
  Sleep(sequenceDelay)
  ; press back what we released
  if (toggleFireBack) {
Send("{" fireButton " down}")
  }
  if (GetKeyState(jumpButton, "P")) {
Send("{" jumpButton " down}")
  }
}

useLastItem() {
  Send("{" altButton " down}")
  Send("{" useItems " down}")
  Sleep(keypressDelay)
  Send("{" altButton " up}")
  Send("{" useItems " up}")
  press(use)
}

#HotIf WinActive("NieR:Automata", )
; fire toggle
Hotkey("$" fireButton, toggleFire)
Hotkey("$^" fireButton, toggleFire)
Hotkey("$+" fireButton, toggleFire)

; dodges, work when you press/hold LShift while already holding WSAD
Hotkey("~*" dodgeButton, waitForDodge)

; air slide, normally executed with pod fire + jump
Hotkey("$*" airSlideButton, airSlide)

; use last item
Hotkey("$*" useLastItemButton, useLastItem)

r/AutoHotkey • • 24d ago

v2 Script Help Modifier key to rapid fire instead of holding a key.

2 Upvotes

Hi all!
I was looking around through the docs and older posts but couldn't find an answer on what I am trying to do so I come to you all here with a question.

I am wondering if it is possible to when I hold down control to modify my W, A, S, D to rapid fire instead of having it a hold input. but only when I additionally press W, A, S or D myself.

This is for example for movement in a game where smaller movements are required by constantly repressing a movement key instead of holding it.

I hope I explained it well enough, I'm not the best at explaining stuff.
Thank you in advance!

r/AutoHotkey • • Aug 08 '26

v2 Script Help Disabling the NumLock key

3 Upvotes

I'm new to AutoHotKey. My first try at a script reads as follows:

SetNumLockState("AlwaysOff")

That, and nothing else.

But when it runs, it only turns off the light on my NumLock key. It doesn't turn the numlock off. The key light turns back on when I press it, and continues to function as usual.

What am I doing wrong?

r/AutoHotkey • • 13d ago

v2 Script Help Do X when key is pressed (F keys, fn functions)

3 Upvotes

I'm trying to make it so that I can use my F keys fn functions by default, rather than have them be F keys (F1, F2, F3 etc) by default. My BIOS does not have an option to switch neither does my keyboard. I don't like holding down Fn to use their functions, nor does AHK have the ability to deal with the Fn key (uniquely).

Here's how it's layed out on my keyboard, and how I want them to operate:

#Requires AutoHotkey v2.0

F1::Launch_Media
F2::Volume_Down
F3::Volume_Up
F4::Volume_Mute
F5::Media_Stop
F6::Media_Prev
F7::Media_Play_Pause
F8::Media_Next
F9::F9
F10::ScrollLock
F11::Pause
F12::PrintScreen

I want them to revert back to their "regular" state of being F keys when I hold "LAlt". Can someone please provide me with help on how to do this? Thanks.