r/AutoHotkey

Shift key getting stuck pressed

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

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

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

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

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

<

#MaxHotkeysPerInterval 10000
#UseHook

#IfWinActive, ahk_exe Fallout4.exe

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

>

reddit.com
u/2balCain — 1 day ago

I wanted Linux-style workspace workflows on Windows without replacing the Windows shell, so I built Spacr

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

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

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

Phase 1 currently handles:

Workspace switching

Automatic desktop creation

Move + follow

Previous workspace

Explorer integration

VirtualDesktopAccessor integration

I'm deliberately keeping the project small for now.

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

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

v0.1.1-alpha is now available:

https://github.com/timburman/spacr

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

u/timberman69 — 3 days ago

Clicking one of three randomized buttons by colour

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

reddit.com
u/Lechtom — 4 days ago

Why wont my script type a forwards dash? /

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

It is also keybinded to /

Heres what I have so far.

------

/::

Send /

sleep 1000

send @@

return

------

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

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

reddit.com
u/Broke_CollegeStud3nt — 5 days ago

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

Hello,

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

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

reddit.com
u/Lurking_in_shadow — 6 days ago

Problems with basic Send and SendEvent

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

#SingleInstance Force

Persistent

$`::{

Send "j"

Sleep 300

Send "j"

Sleep 300

SendEvent "{w down}"

Sleep 600

SendEvent "{w up}"

MsgBox "1"

Sleep 50

SendEvent "{w down}"

Sleep 600

SendEvent "{w up}"

}

reddit.com
u/Financial-Ad3486 — 6 days ago

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

Hi everyone,

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

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

The Problem:

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

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

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

What I Want to Achieve:

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

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

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

Question:

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

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

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

reddit.com
u/sikyungbin — 7 days ago

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

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!

reddit.com
u/Evid3nce — 6 days ago

AHK gone from Microsoft Store

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

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

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

reddit.com
u/klirre1 — 9 days ago

What made you pay for a productivity tool instead of using a free one?

Hey everyone!

I've been using AutoHotkey and PowerToys for years and they do almost everything I need. So the other day I was looking at my bank statement and realized I had actually paid for three different Windows utilities last year — and I couldn't even remember what problem made me pull the trigger on the first one.

That got me thinking. With so many solid free tools out there — PowerShell scripts, open-source utilities, the whole PowerToys suite — what actually makes someone decide this one is worth money?

Was it a specific feature the free stuff couldn't do? Was it better design and less friction? Or did you just get fed up with maintaining a bunch of scripts and wanted something that worked out of the box?

How important is reliability when deciding whether a productivity tool is worth paying for? For example, if something goes wrong, would being able to recover easily or clearly see what the tool is about to do make a difference?

And what about privacy? If a tool uses your microphone or handles sensitive information, how important is it to know when it's active and what, if anything, leaves your computer?

If you've ever been in that spot — staring at a paid tool while knowing you could probably rig up a free alternative — what tipped you over? And was it actually worth it in the end, or did you end up going back to the free stuff anyway?

reddit.com
u/keyboard_ninja_20 — 8 days ago

Stand alone AHK, AHKv2 projects?

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

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

reddit.com
u/buzzkilt — 9 days ago

What's the line for having a script run only when Microsoft Edge is the active window?

I know the basic line (#HotIf WinActive("[x]", )), but I'm not sure what I should put to have Microsoft Edge be that window.

reddit.com
u/Queenofdragons6 — 10 days ago

I Don't Know How to Code

Hi all, I've been trying to create a code for my OBS streaming using Autohotkey and could use some help. I know basically nothing about coding but I want to have to output the F10 key on the down and up stroke of the Tab key. For context I want to be able to hide certain parts of my stream when the tab key is held down and reshow them when its released.

Is this something someone might be able to help me with?

reddit.com
u/Secret_Salsa — 9 days ago

Duplicate file finder - fileman ( host-workers example )

Over years of taking manual backups across external drives, my storage became bloated with redundant folder trees and nested duplicates.

The first prototype of this script was single-threaded and took almost 2 hours to scan through my drive collection. After rewriting the core class to leverage worker processes and hashing calls, the full scan time dropped to under 10 minutes, reclaiming nearly 60 GB of wasted space.

It is not an all-in-one file manager, it focuses specifically on finding and isolating exact duplicate files safely and quickly.

GitHub: https://github.com/bceenaeiklmr/fileman

If nothing else, it was great practice working with Lexikos's RegisterObjectActive for COM IPC.

/e

Aug 9 2026 - I updated the headless mode, unfortunately it deleted every file. Now it works as intended.

I've successfully restored the files using Windows File Recovery

u/bceen13 — 12 days ago

Built a game launcher that's not an app but an overlay. Summon your entire library over your desktop with one key.

I saw the script they share in this sub, my tool doesnt look like its made on ahk at all. Every launcher is a window you alt-tab to. I wanted a superpower — press F7 or controller Guide button, your library overlay appears over whatever you're doing, pick a game, it melts into the launch. Open source- https://github.com/hotshot221/Ludoria

LUDORIA:

Auto-discovers Steam, Epic, local games — zero setup

Fetches official cover/hero/logo art automatically

Full controller support (stick, d-pad, A/B/X/Y, Guide to summon)

One script, no account, no telemetry, no background process, <2MB RAM when hidden.

Zero Bloat. zero dependencies - no Electron, no .NET, no web wrap.

Compiles to a single .exe

  • The interesting bits-
  • Full GDI+ canvas — rounded-rect fills, multi-layer stroke glows, PathGradient sigma-blend radials, clip paths, ImageAttributes alpha matrices. No game engine, no DirectX.
  • DWM acrylic — SetWindowCompositionAttributeHostBackdrop on a transparent GUI, real Windows 11 wallpaper blur shows through. Tint re-blended per game from hero art pixel sampling.
  • XInput — xinput1_4.dll loaded dynamically, polled at 40 Hz, full stick/d-pad/button nav with repeat-delay.
  • Frame loop — SetTimer(Frame, 8) ~120fps while animating, drops to 14fps idle. timeBeginPeriod(1), exponential-damped easing.
  • Night watch — InstallKeybdHook + OnMessage(0x218, OnPowerBroadcast)so it never goes deaf after sleep.
u/Live-Attorney7972 — 13 days ago

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

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
reddit.com
u/Jesus_Christ_Reborn — 13 days ago

Flooding invalid deauth frames still kicks PMF clients, tested on 3 Android phones

Enabled PMF on my AP, expected my deauth tool to fail. It didn’t.

Even though every frame gets rejected by the crypto, flooding enough of them in aggressive mode still disconnected all three Android phones I tested (latest security patch). Took around 9 seconds on average.

Has anyone else seen this on iOS, Windows, or IoT? Curious how widespread it is.

For anyone asking; the tool scans and deauths in parallel so there’s no breathing room and the agressive mode is what let me discover this.

https://github.com/Ymsniper/KTO

u/Trick-Resolve-6085 — 14 days ago

How to keep the entire keyboard active while the monitor is off, but ONLY allow the mouse to wake the display?

I am looking for a way to turn off my monitor (display power off only, my PC must stay fully awake and running) so that the entire keyboard remains 100% functional in the background (multimedia keys included), but completely ignored by Windows as a wake source.

While the screen is black, I want to be able to type, use macro keys, and use multimedia shortcuts. Windows should process all these keyboard inputs normally, but the monitor must stay black. ONLY moving the mouse should wake the monitor up.

What I have already tried that did NOT work:

  1. Unchecking "Allow this device to wake the computer" in Device Manager for all keyboards. (This doesn't work because when the display is powered off via code, Windows wakes it up on any hardware event anyway).
  2. Standard AutoHotkey (v1) scripts using SendMessage, 0x112, 0xF170, 2 combined with loops. If I press a key, Windows intercepts the hardware signal at a deep level and forces the monitor back on instantly.
  3. Disabling keyboard wake via powercfg /devicedisablewake.

User Account Control (UAC) is already disabled on my system. I am running AutoHotkey v1.

Is there a way (via low-level Windows API, registry tweaks, or advanced AHK hooks) to make Windows completely ignore all keyboard inputs specifically and only for the monitor-wake trigger, while still letting those inputs pass through to background apps?

reddit.com
u/gougluinn — 14 days ago

Caps lock key pressing multiple keys at once. Please help.

I restarted my computer (windows 11) for an update. After I had updated my computer, now every time I press Caps lock, it presses the characters: ‘ X D \\

The ‘\\’ continues until I press caps lock again. I don’t know how this problem even occurred, but if anyone knows, please help.

reddit.com
u/Slight-Custard-8072 — 14 days ago

Is it possible to have smooth movement hold input in an unfocused window?

So I have two game instances and want to broadcast WASD input to the unfocused instance. Example: unfocused instance - driver, drives the vehicle, focused instance - gunner, my main game window with native input to shoot the enemies.

I've tried other existing scripts, but they are either "hold key for 500 ms when triggered" or "do single press", and if I loop one, "window fighting" occurs, when window is being repeatedly focused and unfocused, which makes the game unplayable

(I've asked AI for help, but it couldn't write a correctly working script either)

reddit.com
u/Krasapan — 14 days ago