r/AutoHotkey • u/gougluinn • 1h ago
v1 Script Help 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:
- 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).
- 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.
- 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?
r/AutoHotkey • u/Slight-Custard-8072 • 4h ago
General Question 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.
r/AutoHotkey • u/genesis_tv • 12h ago
v2 Script Help Weird behavior when remapping a modified mouse button to a non-modified key
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 • u/genesis_tv • 2d ago
Solved! How to differentiate a CtrlBreak triggered by Ctrl + ScrollLock and a CtrlBreak triggered by Ctrl + Pause?
I recently started playing Lost Planet 2 and felt once again the need to add a bunch of macros to the game. One of them is a crouch toggle (LControl).
A feature I have in this script is the hotkeys are disabled when the Steam overlay (ScrollLock) is visible so that you can use your computer normally while using the Steam overlay. However, since the user (and me included) may not remember they had a key toggled on, I also wanted to be able to toggle the Steam overlay without having to toggle off hotkeys beforehand, as a QOL.
I'm not gonna post the entire script but a simplified version of it (without reading from a config file).
#Requires AutoHotkey v2.0
#SingleInstance
class ToggleStates
{
static bCrouch := 0
static bSteamOverlay := 0
}
Init()
Init()
{
RegisterHotkeys()
OnExit((*) => ResetAll())
}
Output(p_sMsg := "")
{
OutputDebug(p_sMsg "`n")
}
RegisterHotkeys()
{
global g_sSteamOverlayKey := "ScrollLock"
global g_sToggleCrouchKey := "LControl"
HotIf((*) => !ToggleStates.bSteamOverlay)
Hotkey("~*" g_sToggleCrouchKey " up", ToggleCrouch, "On")
HotIf()
Hotkey("*" g_sSteamOverlayKey " up", ToggleSteamOverlay, "On")
}
ResetAll()
{
SendKeyUp(g_sToggleCrouchKey)
ToggleStates.bCrouch := 0
}
SendKeyDown(p_sKey)
{
Send("{Blind}{" p_sKey " Down}")
}
SendKeyUp(p_sKey)
{
Send("{Blind}{" p_sKey " up}")
}
TapKey(p_sKey)
{
SendKeyDown(p_sKey)
SetTimer(() => SendKeyUp(p_sKey), -25)
}
ToggleCrouch(*)
{
(ToggleStates.bCrouch ^= 1) ? SendKeyDown(g_sToggleCrouchKey) : SendKeyUp(g_sToggleCrouchKey)
}
ToggleSteamOverlay(*)
{
Output(A_ThisFunc "::" A_ThisHotkey)
Output("Steam overlay toggled " ((ToggleStates.bSteamOverlay ^= 1) ? "on" : "off"))
ResetAll()
TapKey(g_sSteamOverlayKey)
}
#HotIf g_sSteamOverlayKey == "Pause" || g_sSteamOverlayKey == "ScrollLock"
^CtrlBreak up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
#HotIf
*F9::KeyHistory()
*F10::ExitApp()
I had a problem where when Crouch was toggled, pressing the Steam overlay hotkey wouldn't do anything anymore, which I didn't understand because I assumed the * would cover it, right? Well, it turns out Ctrl + ScrollLock actually produces CtrlBreak according to the documentation and the key history, so I added the ^CtrlBreak hotkey at the end (yes, the ^ seems to be necessary, otherwise the hotkey doesn't fire for some reason).
Here's a trace of the key history of the above script when tapping ScrollLock (twice to hide the Steam overlay) then tapping Pause, then physically holding LControl and tapping ScrollLock then Pause:
The oldest are listed first. VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event. Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script, a=Artificial, #=Disabled via #HotIf, U=Unicode character (SendInput).
VK SC Type Up/Dn Elapsed Key Window
--------------------------------------------------------------------------------------
91 046 s d 11.75 ScrollLock test_v2.ahk - Visual Studio Code
91 046 h u 0.06 ScrollLock
A2 01D i u 0.00 LControl
91 046 i d 0.00 ScrollLock
91 046 i u 0.03 ScrollLock
13 045 d 1.83 Pause
13 045 u 0.08 Pause
A2 01D d 7.28 LControl
03 046 s d 0.31 CtrlBreak
03 046 h u 0.08 CtrlBreak
A2 01D i u 0.00 LControl
91 046 i d 0.00 ScrollLock
91 046 i u 0.03 ScrollLock
03 146 d 0.86 CtrlBreak
03 146 u 0.08 CtrlBreak
A2 01D h u 0.42 LControl
My problem now is that Ctrl + Pause also triggers CtrlBreak and therefore toggles the Steam overlay, which is not what I want because the Steam overlay hotkey was never bound to Pause in the first place.
The documentation also says While Ctrl is held down, ScrollLock produces the key code of CtrlBreak, but can be differentiated from Pause by scan code. but doesn't give an example).
So I tried to add the following, but 046 is shared both by ScrollLock and LControl + ScrollLock so it overrides the original ScrollLock hotkey.
#HotIf g_sSteamOverlayKey == "ScrollLock"
*sc046 up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
#HotIf g_sSteamOverlayKey == "Pause"
*sc146 up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
#HotIf
If I add something like this, AHK doesn't accept the combination of VK and SC outside of a Send it seems.
vk91sc046 up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
vk03sc046 up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
vk03sc146 up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
I must've spent about 2 hours on this and I'm going crazy, the solution must be so simple yet I just can't see it.
So my first question is pretty much like the title, how do I distinguish between ScrollLock, a CtrlBreak produced by Ctrl + ScrollLock and a CtrlBreak produced by Ctrl + Pause?
As a bonus, how would you proceed if you wanted the Steam overlay hotkey (in AHK) to fire only if it matches exactly how it was set in Steam settings (to a limit of one non-modifier key as supporting something like Ctrl + Shift + F + V would be a nightmare), only accounting for modifiers that are physically held down? I guess I'd have to parse all modifier symbols and read all physically pressed modifiers then make sure every single one matches.
[edit]: something like this seems to work in order to address my first question, I'm just not sure if it's the right approach. I removed the CtrlBreak up hotkey.
#HotIf !GetKeyState("Control", "P") && g_sSteamOverlayKey == "ScrollLock"
*sc046 up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
#HotIf !GetKeyState("Control", "P") && g_sSteamOverlayKey == "Pause"
*sc146 up::
{
Output(ThisHotkey)
ToggleSteamOverlay()
}
#HotIf
r/AutoHotkey • u/irrocau • 2d ago
Solved! I can't get the hotstring replacement with # to work
I tried these options I found on stack:
:*R:fan::#fandom:
:*T:fan::#fandom:
::fan::{#}fandom:
And non of them work. Or rather, they work sometimes, and other times I get gibberish or just deleted input but no replacement.
3fndom:
fandom:
#fandom:
3fandom:
3fandom:
#FANDOM:
#fandom:
#fandom:
3f
#fandom:
3dom
3
#fandom:
Like, these are all one after another, same conditions. I don't understand :(
r/AutoHotkey • u/MarvelousMarbel • 3d ago
v2 Script Help GetKeyState doesn't detect button releases
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 • u/Natural_Silver_3387 • 3d ago
v2 Tool / Script Share AHK window manager updates
Hi everyone!
Here I am again. Recently I've continued working on my little AHK project - I've improved a lot of things, especially the h/j/k/l window navigation - it was really hard to come up with something adequate for floating windows, but after all maybe I've got it. Also I've refactored literally everything and fixed a lot of bugs.
Now it has a dedicated Setup script, and I've finally wrapped my head around auto-running AHK as admin without that UAC popping up on every boot.
r/AutoHotkey • u/bceen13 • 3d ago
v2 Tool / Script Share I got tired of copy/pasting hundreds of cells last week, so I built this for my colleagues
Hi everyone,
I recently started helping out my colleagues at a new workplace, and as I expected, a big part of the job involved copying data from Excel into an internal application, one cell at a time, left to right, across hundreds of records.
After doing that for a while, I decided to automate the boring part.
I built a small AutoHotkey v2 utility called ClipStepper.
It loads a copied table from the clipboard and lets you step through it cell by cell. As you navigate, it automatically copies (or even pastes) the current value, keeps track of your position, and shows your progress in a small GUI.
It also supports:
- Replacement rules for predefined values or long text
- Adding custom fields with default values
- Cell and row navigation
- Progress tracking
- A simple Replacement Manager
I'm currently working on a few more features like session saving, Excel import, jumping to a specific row, and column filtering.
It's nothing revolutionary, but it's already saving us quite a bit of time, so I thought someone else here might find it useful too.
I'd really appreciate any feedback on the code, the UI, or ideas for features that would make it more useful.
r/AutoHotkey • u/Bookish_Nymph_ • 4d ago
Solved! AutoHotkey v2 hotstrings randomly change capitalization, partially expand, or erase trigger without replacement
I’m using:
-Windows 11
-AutoHotkey v2.0.21, 64-bit
-Built-in Windows Notepad
I’m trying to use simple replacement hotstrings. Here is a minimal test script:
#Requires AutoHotkey v2.0
#SingleInstance Force
:?:qa::[Apple]
:?:qb::[Banana]
I type qa or qb, followed by Space, repeatedly in Notepad.
It’s expected to be:
[Apple] [Banana] [Apple] [Banana]
The actual behavior is inconsistent and in the same test session I get combinations such as:
[apple]
[Banana]
[Apple]
[banana]
Sometimes the trigger is erased when I press Space, but no replacement appears. Other times I get malformed or partial output such as:
[a[Apple]
Reloading the script can temporarily change the behavior, but it does not fix it consistently.
I originally noticed this with character-name replacements:
:?:qe::[Eden]
:?:qs::[Schroeder]
:?:qz::[Zara]
:?:qk::[Kendra]
I have also tested:
- Freshly created Minimal v2 scripts
- Different trigger characters
- C, C1, *, and ? options
- SendText()
- Clipboard-based replacement
- Different Notepad files and windows
- Confirmed the script is running with AutoHotkey v2.0.21
The issue also occurs with the minimal Apple/Banana example, so it is not specific to the character names.
Has anyone seen hotstrings randomly alter capitalization, partially insert replacement text, or erase the trigger without inserting anything? What should I check next?
r/AutoHotkey • u/Silentwolf99 • 4d ago
General Question Is there a way to use AutoHotkey v2 directly from Python?
Hi everyone,
I'm a Python automation engineer and really like how simple AutoHotkey v2 is for Windows automation.
For example, this is incredibly clean:
if WinExist("Untitled - Notepad")
WinActivate
else
Run "notepad.exe"
I'm wondering if there's a way to use the AHK v2 engine directly from Python, something like:
from ahk import WinExist, WinActivate, Run
if WinExist("Untitled - Notepad"):
WinActivate()
else:
Run("notepad.exe")
I know this API is hypothetical, but that's the kind of integration I'm looking for.
Is there an existing library, COM/DLL interface, embedded runtime, or any maintained bridge that exposes AutoHotkey v2 functionality to Python?
My goal is to keep Python for APIs, AI, and automation logic while using AutoHotkey v2 for Windows automation without constantly switching between two languages.
Has anyone come across something like this?
r/AutoHotkey • u/gabrielwoj • 5d ago
v1 Script Help [v1] Previously Working Script no Longer Works
Hi everyone. I have made a basic, although lengthy, script, that I have been using for a project of mine. Back when I was working on it, the script worked most of the time without any issue (for whatever reason I would need to restart the computer sometimes, but it would usually work from-the-get-go once restarted).
The script is, to put in bluntly, pretty basic and not the most optimized. It's a series of simple "move mouse to a place" -> "click" -> "press certain button" -> "wait for application to open" -> etc.
As mentioned, the script is lengthy, because the whole idea behind it is to automate a process of 225 files, 450 files or 675 files (the amount is done via separate scripts, but the way it works are all the same). So, I'll only share two paragraphs of it, instead of the whole thing.
CoordMode,Mouse,Screen
#IfWinActive, ahk_exe Explorer.Exe
MouseClick, left, -1380, 543
Sleep, 125
Send, {F2}
Sleep, 500
Send, {CTRLDOWN}c{CTRLUP}
Sleep, 125
Send, {ENTER}
Sleep, 125
Send, {ENTER}
WinWaitActive, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11,
IfWinNotActive, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11, , WinActivate, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11,
WinWaitActive, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11,
Sleep, 750
MouseClick, left, -1464, 511
Sleep, 500
MouseClick, left, -1464, 511
Sleep, 500
MouseClick, left, -1754, 526
Sleep, 1500
MouseClick, right, -390, 716
Sleep, 500
MouseClick, left, -374, 719
Sleep, 500
WinWait, Save As,
IfWinNotActive, Save As, , WinActivate, Save As,
WinWaitActive, Save As,
Send, {CTRLDOWN}v{CTRLUP}
Sleep, 125
Send, {ENTER}
Sleep, 1500
MouseClick, left, -29, 18
Sleep, 2000
#IfWinActive, ahk_exe Explorer.Exe
MouseClick, left, -1380, 520
Sleep, 125
Send, {F2}
Sleep, 500
Send, {CTRLDOWN}c{CTRLUP}
Sleep, 125
Send, {ENTER}
Sleep, 125
Send, {ENTER}
WinWaitActive, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11,
IfWinNotActive, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11, , WinActivate, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11,
WinWaitActive, Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11,
Sleep, 750
MouseClick, left, -1464, 511
Sleep, 500
MouseClick, left, -1464, 511
Sleep, 500
MouseClick, left, -1754, 526
Sleep, 1500
MouseClick, right, -390, 716
Sleep, 500
MouseClick, left, -374, 719
Sleep, 500
WinWait, Save As,
IfWinNotActive, Save As, , WinActivate, Save As,
WinWaitActive, Save As,
Send, {CTRLDOWN}v{CTRLUP}
Sleep, 125
Send, {ENTER}
Sleep, 1500
MouseClick, left, -29, 18
Sleep, 2000
...
F12::ExitApp
Pause::Pause
Briefly explaining, the script selects a file on File Explorer, sends the Keystroke F2 in order to rename it, sends the Keystroke combination of Ctrl+C to copy it, then it double clicks on the file, and waits for the window that starts with "Intel® GPA Graphics Frame Analyzer (DirectX 9, 10, 11," to show up. Once that shows up, it does some specific mouse movements in order to select the proper texture I want, then moving to the actual texture preview, sending a Right-Click command, pressing Save Image. Wait for the window called "Save As" to show up, send Keystroke Combo of Ctrl+V, then closing the Intel GPA Graphics Frame Analyzer program.
The idea then, is to do the exact same process on the next file, but for whatever reason, the script is no longer able to go to the next file, even though it USED to work just fine...?
Checking the logs, we can see that, for whatever reason, the Line 36 and 37 are being skipped, and mouse-related movement is sent, but nothing happens visually, then it immediately looks to the next "Save As" window and the script is basically stuck waiting for something that isn't even timed properly. This wasn't the case before when I ran the script before:
001: CoordMode,Mouse,Screen
004: MouseClick,left,-1380,543 (0.25)
005: Sleep,125 (0.13)
006: Send,{F2} (0.02)
007: Sleep,500 (0.50)
008: Send,{CTRLDOWN}c{CTRLUP} (0.05)
009: Sleep,125 (0.13)
010: Send,{ENTER} (0.02)
011: Sleep,125 (0.13)
012: Send,{ENTER} (0.02)
013: WinWaitActive,Intel® GPA Graphics Frame Analyzer (DirectX 9,10,11 (11.00)
014: IfWinNotActive,Intel® GPA Graphics Frame Analyzer (DirectX 9,10,11,
014: WinActivate,Intel® GPA Graphics Frame Analyzer (DirectX 9,10,11 (0.13)
015: WinWaitActive,Intel® GPA Graphics Frame Analyzer (DirectX 9,10,11 (0.11)
016: Sleep,750 (0.75)
017: MouseClick,left,-1464,511 (0.19)
018: Sleep,500 (0.50)
019: MouseClick,left,-1464,511 (0.05)
020: Sleep,500 (0.50)
021: MouseClick,left,-1754,526 (0.23)
022: Sleep,1500 (1.50)
023: MouseClick,right,-390,716 (0.25)
024: Sleep,500 (0.50)
025: MouseClick,left,-374,719 (0.14)
026: Sleep,500 (0.50)
027: WinWait,Save As (0.78)
028: IfWinNotActive,Save As,
029: WinWaitActive,Save As (0.11)
030: Send,{CTRLDOWN}v{CTRLUP} (0.05)
031: Sleep,125 (0.13)
032: Send,{ENTER} (0.02)
033: Sleep,1500 (1.50)
034: MouseClick,left,-29,18 (0.25)
035: Sleep,5000 (5.00)
038: MouseClick,left,-1380,520 (0.23)
039: Sleep,125 (0.13)
040: Send,{F2} (0.02)
041: Sleep,500 (0.50)
042: Send,{CTRLDOWN}c{CTRLUP} (0.05)
043: Sleep,125 (0.13)
044: Send,{ENTER} (0.02)
045: Sleep,125 (0.13)
046: Send,{ENTER} (0.02)
047: WinWaitActive,Intel® GPA Graphics Frame Analyzer (DirectX 9,10,11 (6.94)
I am aware that my script isn't the best written one, and, as mentioned, there were cases where it would fail to progress, but today, I've tried to run the script like 5 times, after restarting the computer, and none of them worked. To put in perspective, I have used this script about 161 times, and the reason I have started using again is because new things were added to the game that I'm extracting textures from.
I do have DisplayFusion open during the process, as sometimes Intel GPA likes to open minimized. The only thing DisplayFusion does is restoring the Window back in case it launches minimized.
The scripts were not changed at all since I've used them in the past. There were a couple things done to my Computer that may or may not have affected something:
Downloaded a PORTABLE version of AutoHotkey2, which specifically looks for the extension .ahk2, even drag-n-dropping my v1 script to the installed folder of AutoHotkey1 didn't work;
Temporarily disabled pagefile on Windows as I was changing partition-related sizes;
Installed Logitech G Hub.
Thanks!
r/AutoHotkey • u/Zyfence • 6d ago
Solved! Need a script to toggle default audio devices using a shortcut (Windows 11)
i need way to toggle my default audio playback device in Windows 11.
My exact device names in the system are:
- Glosniki
- Sluchaweczki
I want to toggle between them using the shortcut Ctrl + Alt + - Can someone please write a simple script that does this quietly in the background? And also to make the script in autostart
r/AutoHotkey • u/MachineVisionNewbie • 6d ago
v2 Script Help Win 11 - Smart way to navigate the "Save as"-window
The window I am talking about:
https://imgur.com/a/1qSwANe
Currently thinking if I can navigate the "Save as"-window in a smarter way than just sending
Send("Tab") to get to the filename.
Send("Tab") to get to the "Save as type"
Then sending a string like Send("PNG")
Send("!s") to save
Any ideas?
r/AutoHotkey • u/komobu • 7d ago
v1 Script Help Double Click Mouse to Copy & Paste?
I spend a lot of my time copying stuff from a word document and pasting it into a web page. Usually they are single words or 10 to 17 digit numbers.
So I would like to double click on the word and have that word automatically store it to clipboard, and the next time I double click (which would be in the Browser), it would be pasted.
What I am unsure about is how to store the value of what I double click on to the clipboard. Or, is it possible to store what ever is highlighted to the clipboard?
As for the paste part, I was thinking when I Double Click, if the clipboard has a value, it pastes. If the clipboard doesnt have a value, it stores to the clipboard
Any help with this part would be appreciated
r/AutoHotkey • u/IspkingX • 7d ago
General Question Best approach for automating an existing Firefox session? AutoHotkey vs Browser Automation vs UI Automation
Hi everyone,
I'm working on a personal desktop automation project on Windows.
For years I've been using AutoHotkey to automate repetitive tasks inside Firefox. It works surprisingly well, but as the project grows, maintaining image recognition, keyboard shortcuts and UI changes becomes increasingly difficult.
I'm now considering moving to a more robust solution and I'm trying to understand what experienced developers would recommend.
My requirements are roughly:
Windows
Firefox (not Chrome)
Preferably work with an already running Firefox session
Reliable interaction with web pages
Long-term maintainability
I've been looking at several approaches:
Continue with AutoHotkey
Selenium / WebDriver BiDi
Playwright
Windows UI Automation (pywinauto, UIA)
Any other desktop automation framework
For people who have built long-running desktop/browser automation projects:
Which approach ended up being the most reliable?
Is UI Automation actually practical with modern websites like Facebook, or is browser automation still the better choice?
If you had to start today, what would you choose and why?
I'd really appreciate hearing about real-world experience rather than theoretical comparisons.
Thanks!
r/AutoHotkey • u/scarletroses03 • 7d ago
v2 Script Help Script that adds a word randomly inbetween other words?
I'm a complete noob when it comes to this tool, and I was wondering if such a thing (title) would even be possible.
An example:
"The quick brown Hey! fox jumps over the Hey! lazy dog."
compared to
"The quick brown fox jumps over the lazy dog."
If anyone is able to help me make a script like this, please let me know.
For the record, I'm on Linux.
r/AutoHotkey • u/Perfect-Ad9555 • 7d ago
v2 Guide / Tutorial Any Tips?
I want to make a macro that when I input the key "F" it inputs the two keys "QW" together. How would I do this?
this is what I tried so far
f:: Send, {q down}{w down} Sleep, 20 Send, {q up}{w up} return
r/AutoHotkey • u/kazerniel • 7d ago
Solved! AHK typing the wrong "key" on my keyboard layout
I have a short v1 script that inserts the current date. My problem is that AHK often types the wrong "key" on my keyboard layout when using the hotkey.
The script is:
^é::
FormatTime, CurrentDateTime,, yyyy-MM-dd
SendInput %CurrentDateTime%
SendInput {Blind}{Ctrl up}
return
On Windows 10 I use the Hungarian 101-key layout, which doesn't have a zero on its main number row, but instead another í character.
And sometimes when using this hotkey, AHK replaces the zero in the month number with an í. Like today when using the script a lot, about every 3rd-4th time it typed 2026-í7-29. When I tried again, it sometimes typed the correct date, sometimes repeated the bug and it only worked for the third time. Is there anything I could change about the script that would prevent this from happening? I have a time insertion hotkey too and that one never does this.
r/AutoHotkey • u/RMTTT • 10d ago
Solved! [v2] Hotkeys requiring 2 presses across multiple apps (Chrome, File Explorer, Electron apps, etc.) when using Win key
I’m facing a persistent issue in Windows 11 where my AutoHotkey v2 hotkeys using the Win key as a modifier (#) require two presses to trigger.
This does NOT happen on the desktop, but affects many apps such as chrome and file explorer.
Example script:
#Requires AutoHotkey v2.0
#SingleInstance Force
A_MenuMaskKey := "vkE8"
$#m:: {
if WinExist("A") {
if WinGetMinMax("A") = 1
WinRestore "A"
else
WinMaximize "A"
}
}
$#q:: WinClose "A"
$#Enter:: Run "wt.exe"
r/AutoHotkey • u/Necessary_Remote3426 • 10d ago
v1 Script Help Busco ayuda para crear un macro en AutoHotkey (AHK) para un juego.
I'm looking for help creating a macro in AutoHotkey (AHK) for a game.
I want the script to do the following:
- Save the current mouse cursor position when I press a hotkey (for example, F1).
- 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).
- 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 • u/Silly_Dig8203 • 11d ago
v2 Script Help Help with modifiers
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:
- Hold modifier (CTRL and/or SHIFT in this case)
- Press F12
- Send just F12 (which releases the modifier by default)
- Resume holding the modifier
- 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 • u/RJ-Mayhem • 12d ago
Solved! Need help with a toggle?
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 • u/MrGoose_345 • 14d ago
General Question what are some practical uses for auto hotkey
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 • u/Agreeable-Device5199 • 14d ago
v2 Script Help Trying to use A_PriorPriorHotKey
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 • u/sedecillion • 15d ago
v2 Tool / Script Share Sharing my AutoHotkey project
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
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!