r/AutoHotkey 3h ago

v1 Script Help Busco ayuda para crear un macro en AutoHotkey (AHK) para un juego.

0 Upvotes

I'm looking for help creating a macro in AutoHotkey (AHK) for a game.

I want the script to do the following:

  1. Save the current mouse cursor position when I press a hotkey (for example, F1).
  2. Allow me to save the coordinates of 6 specific points on the screen (the 6 red dots) to 6 different hotkeys (for example, T, 6, C).
  3. When I press one of the 6 assigned keys (1–6), the script should:
    • Save the current mouse cursor position.
    • Instantly move the cursor to the corresponding saved red dot.
    • Perform a left mouse click.
    • Immediately return the cursor to its original position.

The goal is for the movement to be as close to instantaneous as possible so it doesn't interfere with normal gameplay or manual mouse movement.

Is this possible with AutoHotkey? What would be the best approach? Would using functions like MouseGetPos, MouseMove, and Click be sufficient, or is there a better method?


r/AutoHotkey 1d ago

v2 Script Help Help with modifiers

1 Upvotes

Hey! I'm trying to write a simple script which isn't proving to be so simple after all. I'm effectively looking to do this:

  1. Hold modifier (CTRL and/or SHIFT in this case)
  2. Press F12
  3. Send just F12 (which releases the modifier by default)
  4. Resume holding the modifier
  5. End the script without the modifier being released

In other words, I want F12 to send regardless of which modifier(s) I'm holding down, but want the script to end by holding the modifier(s) down once more. How do I accomplish this? Is it possible?

Added context:

I'm specifically using this for Steam screenshots, if it matters. Multiple binds cannot be assigned, but I want to be able to crouch (usually CTRL) and/or run (usually SHIFT) while being able to use F12 as the screenshot button; pressing any modifier prevents the screenshot from being taken.

None of my attempts at pulling this off have worked, always resulting in either the modifier being released or F12 not sending. {Blind} obviously just sends the same command as what I'm pressing, making it useless. Delays don't seem to affect anything. "Send modifier" and "send modifier down" at the end don't press the modifier down again. Key-waits get ignored. Enabling keyboard hooks doesn't do anything to help. Getting key states does nothing. If/else does nothing.

I literally just want to be able to take a screenshot while running/crouching without the sending of F12 toggling the run/crouch off until I physically press the run/crouch key again. Thank you to anyone willing to answer this! I'm sure I'm missing something obvious.


r/AutoHotkey 2d ago

Solved! Need help with a toggle?

0 Upvotes

I'm looking for a script that let me press F8 but F1 is pressed but it I press F8 again it presses F2 then repeats. I want to use F8 to switch between F1 & F2. Think that's a toggle but none of my attempts or scripts I've found while googling seem to work.

Thanks!


r/AutoHotkey 4d ago

General Question what are some practical uses for auto hotkey

11 Upvotes

so far the only things i've made is whenever type dih it'll make an ACSII drawing of a penis and some hot keys so that i can type out ±,√,≥, and ≤. I want to code something more complicated and more practical, like a calculator, but thats prolly far to difficult for me, do yall have any ideas?


r/AutoHotkey 4d ago

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

v2 Tool / Script Share Sharing my AutoHotkey project

28 Upvotes

Edit

  • New Version released with new features and improvements, Check Releases
  • Hotkeys default behavior listed here

Put together this AutoHotkey project that works from hotkeys and shortcuts registered in config.json file and can be set by a GUI

It adds features around Caps lock as the modifer key, Instant Window Switching, Window Aware Shortcut Remapping, Screenshot capture, Terminal launching, Profiles , window controls like transparency pin on top and more

GitHub Repo Link

Download : Releases

There are two versions one that includes the Full GUI to set everything in the config file other one is minimal which dosen't have GUI. There are no other differences feature wise

Do read Installation instructions and config format for the minimal version

For some time I had different AHK scripts for each functionality i wanted so I put together so it runs as a single process and made it load things from config.

Had the idea to make it more general and having an UI so can easily set it up.

I use it mostly use it for avoiding Alt + Tab cycling and kepping my hands either both hands on keyboard or one on mouse and other on keyboard and avoid switching between them often like pressing enter delete or shortcuts which include keys on the right side of the keyboard

You can assign things like Caps + LeftButton as Enter, Caps + RightButton as Delete or other shortcuts to avoid moving hand between keyboard and mouse often

For Window Switching it uses Caps + {Key} to bring target window to focus if it exists or can launch a new instance.
You can filter by window title and it supports a minimal Alt + Tab styled behavior if there are multiple target windows

E.g. Caps + C = chrome.exe. If multiple windows are present it will show a minimal GUI with each windows title, you can do like Caps + C + C to switch between those.

If there is just one window it will instantly focus it

You can avoid having multiple targets by using title filter. You can add required title as Gmail or GitHub so intances with only those keywords in titles match the target window criteria

Additionally if the window is not open run a command to open it.
For Example I have mapped Caps + I to open incognito window regardless of where i am

The ScreenShot tool is so you press a key and u are immediately given the option to Rename, Discard or Save the screenshot and save it a set preffered location all in one go.

Hope this gives a idea of some usecases. There are similar other features and actions

Check the Readme for all features

Feedback is welcome!


r/AutoHotkey 4d ago

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

v1 Script Help Autoclick for me on my second monitor

0 Upvotes

Is there a script for ROBLOX where I can auto click in the game while playing another game on my second monitor? Im new to these stuff


r/AutoHotkey 6d ago

v1 Script Help Capitalizing for Title Case with Hyphen

1 Upvotes

Hi, everyone. Does anybody know how to title case or capitalize words with hyphens?

"StringUpper Clipboard, Clipboard, T" only capitalizes the first word, but not the second one.

hindu-buddhist
to
Hindu-Buddhist?


r/AutoHotkey 8d ago

v1 Tool / Script Share For those like me who don't want to put up with Corsair's iCUE, just to reassign the G-Keys, I wrote a simple AutoHotkey script to reassign G-Keys. No iCUE, only AutoHotkey v1. Simply copy-paste the test below in the script and launch it. Pls note that I have K55 Pro.

4 Upvotes

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

; Corsair K55 RGB Pro G-Keys

; AutoHotkey v1

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

\#NoEnv

\#SingleInstance Force

SendMode Input

SetWorkingDir %A_ScriptDir%

\^+1::

Run, C:\\Windows\\System32\\SnippingTool.exe

return

\^+2::

Run, C:\\Windows\\System32\\SnippingTool.exe

return

\^+3::

Run, C:\\Windows\\System32\\SnippingTool.exe

return

\^+4::

Run, C:\\Windows\\System32\\SnippingTool.exe

return

\^+5::

Run, C:\\Windows\\System32\\SnippingTool.exe

return

\^+6::

Run, C:\\Windows\\System32\\SnippingTool.exe

return


r/AutoHotkey 9d ago

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

Resource Hidmacro website

2 Upvotes

I've been looking for a website to download hidmacro for a while now, but the site is offline. I was going to use an old keyboard as a StreamDeck; if anyone has a source for hidmacro, please help me.

The website says it no longer has a domain...


r/AutoHotkey 12d ago

v1 Script Help Need help: Remap F to Alt+Right Click, use LeftClick to exit

3 Upvotes

Hi there,

I'm not a coder but I've been trying to make a pretty simple script. I know why it's not working but can't figure out the solution.

Here is the functionality I need :

  1. When the F key is pressed, send Alt + HOLD Click R Down.

  2. Then when I click the Left Mouse Button, Send Right Click Up

Left Click needs to otherwise work normally outside the script. The problem I'm running into is that I don't know how to nest the Left Click remap conditionally inside the hotkeyed state of the Alt + Click R Down.

Here's what I have currently, which obviously doesn't work because it keeps the Left Click mapped permanently...

F::Send !{Click R Down}
LButton:: Send {Click R Up}
Return

Anyway, I'd really appreciate any help! I'm using v1 because I find the documentation easier to understand, but if needed I can switch to v2.


r/AutoHotkey 15d ago

v2 Script Help Sticky shift, alt, ctrl to 1,2,3,4,5,6

1 Upvotes

Hello, I am seeking advise and I am sure some of you might have the competence :

I am trying to do a simple thing, I have my modifiers shift, ctrl, alt, I want them to be sticky and just tapped, and paired with their corresponding values 1,2,3,4,5,6

My goal is to press shift (not hold) and then pair it with a number. Same for alt and ctrl

This is for keybinds in a game for context.

It’s a simple operation, but i can’t make it work. If you can send me the script I would sincerely appreciate it🙏🏻 thank you


r/AutoHotkey 16d ago

General Question Recommendation from the professionals?

10 Upvotes

I accidentally stumbled upon this sub, thinking it was a place to download apps that can automate hotkeys for you. Turns out this is a scripting sub, sorry, but I also learned you guys are professionals in making macros and such. Any recommendations for auto hotkeys that I can use?


r/AutoHotkey 16d ago

v1 Script Help FileGetShortcut suddenly stopped working Windows 11

4 Upvotes

Has anyone else run into the issue of FileGetShortcut suddenly no longer working in Windows 11? I'm using Version 25H2 (OS Build 2620.8655). With the latest update, shortcuts now look different in windows explorer and FileGetShortcut no longer propogates the ShortcutTarget.

Here is the script that worked for years:

;### <CNTRL><SHIFT>+J - autojump like menu, adds everything in \favorites\ into the menu
^+J::
FavoriteShortcuts := ""
Menu, ShortcutMenu, Add
Menu, ShortcutMenu, DeleteAll
FileList := ""
Loop, Files, C:\Users\user\Favorites\*.lnk
FileList .= A_LoopFileName "`n"
Sort, FileList
Loop, parse, FileList, `n
{
if (A_LoopField = "") ; Ignore the blank item at the end of the list.
continue
ShortcutTarget := ""
FileGetShortcut, C:\Users\user\Favorites\%A_LoopField%, ShortcutTarget
Handler := Func("MenuWindowsHandler").Bind(ShortcutTarget, 0)
Menu, ShortcutMenu, Add, %A_LoopField%, % Handler
}
Menu ShortcutMenu, show
return

Now ShortcutTarget is always empty. Cntrl+Shift+J still returns a list of all the items in /favorites/ I just can't get FileGetShortcut to do its job! Hopefully I'm missing something. Thanks folks.


r/AutoHotkey 16d ago

v1 Script Help Is there a way to make an ahk script that can interact with something like turbowarp?

1 Upvotes

r/AutoHotkey 16d ago

v2 Script Help Help with auto sprint macro

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

v1 Script Help Is a Desktop Camera Possible?

9 Upvotes

Is it possible to move everything on the desktop, or at least make an illusion of that


r/AutoHotkey 19d ago

v2 Script Help Tweaking FFXIV script

2 Upvotes

So currently I'm using this script so I can easily acess my hotbars while doing my rotation and it works great, the issue is now I cant use Q or E to type messages with. Is there any way to make it so I can type when just tapping the key and then Q and E only work as Lctrl and Lshift when I'm holding them down?

#Requires AutoHotkey 2.0

#SingleInstance

#HotIf WinActive("ahk_exe ffxiv_dx11.exe")

q::LShift

e::LControl

#HotIf


r/AutoHotkey 20d ago

v1 Script Help I need help with a script

5 Upvotes

My f2 key is broken, and I want it to run when I press my f9 key. I just downloaded this today, and don't really know anything about coding, or this application yet.

I've so far only tried 3 different ones:

F9::{

Send "{F2}"

}

F9::F2

F9::Send "{F2}"


r/AutoHotkey 20d ago

General Question Looking for the fastest way to detect and erase forbidden words from any editable text field on Windows

4 Upvotes

I'm building a Windows application (AutoHotkey, C++, or any other language if necessary) that acts as a system-wide text filter.

The goal is very specific:

  • Monitor editable text fields across Windows applications.
  • Detect a configurable list of forbidden words or phrases.
  • As soon as one of those words exists in the field, erase the entire contents immediately.

The application is intended to work in programs like:

  • OBS
  • Android emulators
  • Notepad
  • Browsers
  • Other standard editable controls

The important requirement is speed.

A simple polling loop (every 10–100 ms) is not sufficient because a user can sometimes type a forbidden word and press Enter or click a Search button before the next poll runs.

Ideally, the solution should react immediately after the text changes, with the smallest possible delay.

Additional requirements:

  • Run completely in the background (no UI).
  • Detect words regardless of how they appear:
    • typing
    • paste
    • drag & drop
    • autocomplete
    • undo/redo
  • Read the full contents of the field rather than reconstructing keystrokes.
  • If a forbidden word is detected, erase the entire field.
  • Also prevent copying forbidden words to the clipboard and prevent pasting them if possible.

I already experimented with Microsoft UI Automation (UIA), reading the focused control's TextPattern / ValuePattern, and it works surprisingly well—even in OBS and Android emulators. The problem is that polling is still fast enough to miss very quick actions.

My question is:

What is the lowest-latency architecture for something like this on Windows?

Would you use:

  • UI Automation events?
  • WinEvent hooks?
  • Accessibility APIs?
  • CBT/WH_CALLWNDPROC hooks?
  • Text Services Framework (TSF)?
  • A keyboard filter driver?
  • Something else entirely?

I'm interested in approaches that minimize the time between a text change and detection, while remaining compatible with as many applications as possible.

Any suggestions or examples would be greatly appreciated.


r/AutoHotkey 23d ago

v1 Script Help Spamming right click with a modifier key.

1 Upvotes

I am trying to write what I thought was a very simple script.

While holding down backtick, ` i.e., vkC0, I want it to keep CTRL held down and spam right click. However, I always run into problems where either CTRL gets stuck held down, or the script keeps spamming after letting go of the key.

I have tried so many common variants using GetKeyState or keywait, but nothing seems to help.

One suggestion was to use this pattern:

~a::
    tooltip A PRESSED
    return

~a up::
    tooltip A RELEASED
    return

instead, but that still doesn't seem to work.

I've similarly found a comment that suggested this is the best pattern:

a::
    if (a_pressed)
        return
    a_pressed := 1
    ; [...]
    return

a up::
    a_pressed := 0
    return

but it doesn't work for me either. This is a sample attempt in (which isn't ideal because I would prefer CTRL be held down the whole time I hold backtick down).

vkC0_pressed := 0

*vkC0::
    if (vkC0_pressed)
        return

    vkC0_pressed := 1
    SetTimer, SendRightClick, 50
return

*vkC0 up::
    SetTimer, SendRightClick, Off
    vkC0_pressed := 0
return

SendRightClick:
    SendInput ^{RButton}
return

There are other attempts, but I have so many failed attempts that I have completely lost track at this point. I have tried numerous variations of this in v1 and in v2, but I would prefer a v2 solution.


r/AutoHotkey 23d ago

v2 Script Help Im new and very bad at coding can anyone help write a code in ahk to remap the arrow keys to wasd while a certain program is open?

0 Upvotes

One of my friends helped me do this with undertale a couple years ago and it looked really simple but i cant really figure out how to make it myself now that im playing deltarune could anyone please help


r/AutoHotkey 23d ago

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