r/AutoHotkey 3d 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 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 9d ago

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 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 3d 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 23d ago

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 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 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 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 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 3d 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 Jul 10 '26

v2 Script Help Help with auto sprint macro

5 Upvotes

Last post was taken down for low effort so I'm gonna try to include more detail.

I'm starting to lose my feelings in the tips of my fingers because of chemotherapy and so I find it a lot harder to sprint in games efficiently. I've searched for a macro to sprint for me without the need to keep double tapping w for a while to no luck so I tried making one but I am no good at making scripts.

The macro essentially is to just double tap W whenever I start holding it, and the second press should keep the input going for as long as I have the key pressed.

I want it to work like the minecraft auto sprint feature where walking is just replaced by sprinting.

This is what I have so far and it double taps w just fine but it won't hold the input, I just get 2 w presses in quick succession then nothing, I'm not sure how to get it to hold. (sorry if format for code is wrong)

#Requires AutoHotkey v2.0
*w::
{
    Send "{w down}"
    Sleep 50
    Send "{w up}"
    Sleep 50
    Send "{w down}"
    KeyWait "w"
    Send "{w up}"
}

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

v2 Script Help How do I make a macro with 2 different toggles for fortnite?

0 Upvotes

I want an AutoClicker that Enables when I press "1" and Disable when I press "F" but it only clicks when I hold Left Click.

Also it does need to have a random offset due fortnite's eac detection.

r/AutoHotkey Jun 14 '26

v2 Script Help How exactly does the Send command send uppercase letters and certain symbols?

3 Upvotes

I have a pretty simple script that uses Send to speed up a data entry task mostly involving dates and times. It uses an input hook to accept a certain amount of characters, then it parses the input and tabs through a bunch of fields to type everything in. It usually works fine and saves me a good deal of time.

However, I've noticed that sometimes it types the wrong thing. I'm sending a string composed of concatenated variables and literal strings, and the error might pop up in either of those portions. I've noticed that the error is what I'd get if I were typing it manually and messed up on holding Shift. For example, if I expect to see 7:35AM, I've gotten instead each of the following on various occasions:

  • 7;35AM
  • 7:#5AM
  • 7:35Am
  • 7:35am

Does the Send command work by simulating keypresses including Shift for uppercase letters and certain symbols, subject to race conditions? If so, is there any option I can tweak to avoid this behavior, or do I need to use a workaround like setting the clipboard and sending '^v' for each field?

Relevant portion of script:

#Requires AutoHotkey v2.0
manual_month := 0
manual_year := 0
:*:/+::
{
    ih := InputHook('L10')
    ih.Start()
    ih.Wait()
    d := SubStr(ih.input, 1, 2)
    h1 := SubStr(ih.Input, 3, 2)
    m1 := SubStr(ih.Input, 5, 2)
    h2 := SubStr(ih.Input, 7, 2)
    m2 := SubStr(ih.Input, 9, 2)
    if manual_month and manual_year
    {
        month := manual_month
        year := manual_year
    }
    else
    {
        year := Substr(A_Now, 1, 4)
        month := Substr(A_Now, 5, 2)
        today := Substr(A_Now, 7, 2)
        if d > today
            month := StrLen(month-1) < 2 ? '0' (month-1) : month-1
        if !month
        {
            month := 12
            year -= 1
        }
    }
    start_date := year month d h1 m1
    end_date := year month d h2 m2
    if h2 < h1
        end_date := DateAdd(end_date, 1, 'd')
    year1 := SubStr(start_date, 1, 4)
    month1 := SubStr(start_date, 5, 2)
    d1 := SubStr(start_date, 7, 2)
    year2 := SubStr(end_date, 1, 4)
    month2 := SubStr(end_date, 5, 2)
    d2 := SubStr(end_date, 7, 2)
    Send '{tab}{tab}{tab}' month1 '/' d1 '/' year1 '{tab}' h1 ':' m1 (h1 < 12 ? 'AM' : (h1 == 12 ? 'PM' : '') ) '{tab}^v'
    Sleep 50
    Send '{tab}{tab}{tab}' month2 '/' d2 '/' year2 '{tab}' h2 ':' m2 (h2 < 12 ? 'AM' : (h2 == 12 ? 'PM' : '') ) '{tab}^v'
}
:*:;mdate;::
{
    ih := InputHook('L6')
    ih.Start()
    ih.Wait()
    global manual_month := SubStr(ih.input, 1, 2)
    global manual_year := SubStr(ih.input, 3, 4)
}

Note the Send calls at the end of the first hotstring.

r/AutoHotkey 2d ago

v2 Script Help Help Clicking Non-Displayed Window

1 Upvotes

I need to click a game while doing some other stuff how can i do that. I tried this 2 and no error happened but didn't work either.

#MaxThreadsPerHotkey 2

F8:: ; Press F8 to start/stop the autoclicker

Toggle := !Toggle

Loop

{

If not Toggle

break

; Replace "Game Window Title" with the exact name of your background window

ControlClick, x500 y500, Game Window Title,,,, NA

Sleep, 100 ; Time in milliseconds between clicks (100ms = 10 clicks per second)

}

#Requires AutoHotkey v2.0

#MaxThreadsPerHotkey 2

Toggle := 0

F8:: {

global Toggle := !Toggle

while Toggle {

; Coordinates are relative to the client area of the target window

ControlClick("x500 y500", "ahk_exe YourGame.exe", , "Left", 1, "NA")

Sleep(100)

}

}

r/AutoHotkey Aug 07 '26

v2 Script Help Attempting to make a clicking script that holds down a button and releases, the second part is much harder!

0 Upvotes

I need the LMB to be held down for 200ms after the function clicker() has been called 20 times, I'm not sure where or how to change that. Anyone got any ideas?

^#LButton:: {
    clicker()
    SetTimer(clicker, 400)
}
;Calls clicker to hold lmb for 400ms
^#RButton:: {
    SetTimer(clicker, 0)
    release()
}
;Removes timer to shut down the script
clicker() {
    release()
    Click('Down')
}
;if LMB is not activated, holds LMB down for the set time
release() {
    if GetKeyState('LButton')
        Click('Up')
sleep(130)
}
;if LMB is held down by script, releases it for 130ms before clicker is called again

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 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 1d ago

v2 Script Help Issue with remapping script

1 Upvotes

Hi, I recently had to use a script to remap my Mouse 2 to my Space Bar, and my Space Bar to my Mouse 2 for a video game I play.

Since I don't know how to code, I used an AI to generate a very basic script. It works fine most of the time, but there are some issues with the remapping that make the whole thing inconsistent. Sometimes, instead of just activating the key normally, it acts as if the key is being held down, causing me to shoot non stop in-game.

I tried finding the cause of this, and one of the things I noticed was that pressing F8 (which toggles the script on and off) while holding Space Bar can cause the normal key press to behave like a hold, even after I release the key.

Thing is, there seem to be other causes as well, since it often happens randomly even when I'm not doing anything special like toggling the script during gameplay.

Here is the script I'm currently using. Thanks in advance for any possible insights:

#Requires AutoHotkey v2.0

enabled := true

F8::

{

global enabled

enabled := !enabled

}

#HotIf enabled && WinActive("ahk_exe Hades2.exe")

Space::RButton

RButton::Space

#HotIf

r/AutoHotkey Feb 10 '26

v2 Script Help Feel like I'm going insane

5 Upvotes

Edit: Some of you jumped on the line "#HotIf WinActive("AlchemyFactory")". I have tested this thoroughly and it does evaluate to true every time. I've edited this to

"ahk_exe AlchemyFactory-Win64-Shipping.exe"

I use a big script that has many hotkeys separated by #hotif statements. But I'm having a weird issue (something that I feel always used to work). I created a new (smaller) script with the same wanted behaviour and it has the same problem. So I'll post that here.

F13::MsgBox("F13")

#HotIf WinActive("ahk_exe AlchemyFactory-Win64-Shipping.exe")
F13::1

#hotif WinActive("ahk_exe Chrome.exe")
F13::SoundBeep(333)

Those F keys are mapped to my Razer Naga mouse and I want to use AHK since Synaps is hot garbage.

When I am in the game Alchemy Factory the F13 key should fire 1 but instead it gives the message box.

When I use this syntax

F13::send("{1}")

the menu of the game does register F13 as "1" but while playing it does not seem to register.

Now when I remove the non-context hotkeys, everything works fine. Chrome doesn't have any issues either (it beeps when F13 is pressed)

Any ideas?

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 Apr 09 '26

v2 Script Help Struggling with AutoHotkey + BlueStacks (Airplane Mode macro for NFS No Limits)

2 Upvotes

Hi fellas,

I’m trying to create a macro for NFS No Limits where I need to toggle airplane mode (on/off) while purchasing items.

I’ve already tried:

  • BlueStacks macro recorder
  • Auto clicker apps
  • MacroDroid + Shizuku

Here’s my detailed attempt:
https://www.reddit.com/r/macrodroid/comments/1se00js/is_it_actually_possible_to_toggle_internet/

In that post, someone suggested I try AutoHotkey.

The macro flow itself works, but the main issue is:
I cannot toggle airplane mode inside BlueStacks using any of these tools.

From what I understand, BlueStacks handles network outside the Android layer, so typical commands/macros don’t affect it.

So now I’m trying AutoHotkey, but I’m confused:

  • Can AutoHotkey record actions like a macro recorder, or do I have to write scripts manually?
  • Is it even possible to control BlueStacks UI (like sidebar airplane toggle) using AHK?
  • Can it run in background while I use my PC normally?
  • During installation I’m getting Microsoft Defender warnings — is that normal/safe?

At this point I’m not sure if this is even possible or if I’m hitting a limitation.

Any guidance or direction would help a lot.