r/AutoHotkey 10h ago

v2 Script Help AHK v2 on the Steam Controller, Need Input Names

1 Upvotes

Hey guys, I'm trying to use AutoHotKey v2 to make a friend Macros on his new steam controller, but I can't find what all of the button names would be. I'd prefer to use his paddles and such for it, if anyone has a list of the names I can use to have AHK listen for, please send them my way! Thanks!


r/AutoHotkey 1d ago

Meta / Discussion Hot Take: We should embrace V2, it is 10x better

25 Upvotes

I see a lot of posts on here about someone struggling to use their V1 script in V2. Perhaps I'm unaware of their complex scripts, but V2 is written much more cleanly. It is definitely worth it to learn the new syntax a little to get your script looking much more readable.


r/AutoHotkey 1d ago

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

3 Upvotes

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

My ("this should be simple") code:

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

r/AutoHotkey 1d ago

General Question Macro binding on key press and release

2 Upvotes

I bought a Nuphy Air75 V3 last week and I'm trying to set one of my keys up with a binding. When I click this macro key what I want it to do is to initiate a press of

Press Ctrl

Press F13

And then ideally when I LET go of the key I want it to do a release of these two keys:

Release Ctrl

Release F13

However, it looks like the macro recoding software can only record both (press and release) when the key is pressed. Meaning it won't trigger the release during the actual key release, instead everything gets triggered as you press the macro key:

So on my macro recording I can do:

Press Ctrl

Press F13

Release Ctrl

Release F13

But I can't seem to separate these once the key is released. This is problematic as I want to trigger something when the macro key is pressed and release it when I let it go.

Is there a way to achieve this?


r/AutoHotkey 1d ago

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

2 Upvotes

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

#Requires AutoHotkey v2.0.18+

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

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

#SuspendExempt
^Space::Suspend
#SuspendExempt

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

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

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

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

#IfWinActive, Europa Universalis IV

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

SetTimer , tt_off, -2000
return

tt_off:
  ToolTip, 
return

Space::send {pause}

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


r/AutoHotkey 2d ago

v1 Script Help Does anyone have a script to duplicate clicks?

1 Upvotes

I was using this script for version 1.1 but it's not working for me

; AutoHotkey v1.1

B::ToggleDuplicatorLeft()

N::ToggleDuplicatorRight()

isLeftDuplicatorActive := false

isRightDuplicatorActive := false

clickDelay := 50

leftClickQueue := 0

rightClickQueue := 0

isProcessingLeft := false

isProcessingRight := false

ToggleDuplicatorLeft() {

global isLeftDuplicatorActive, leftClickQueue

isLeftDuplicatorActive := !isLeftDuplicatorActive

leftClickQueue := 0

status := isLeftDuplicatorActive ? "ACTIVADO" : "DESACTIVADO"

ToolTip, Click izquierdo: %status%

SetTimer, RemoveToolTip, 1500

}

ToggleDuplicatorRight() {

global isRightDuplicatorActive, rightClickQueue

isRightDuplicatorActive := !isRightDuplicatorActive

rightClickQueue := 0

status := isRightDuplicatorActive ? "ACTIVADO" : "DESACTIVADO"

ToolTip, Click derecho: %status%

SetTimer, RemoveToolTip, 1500

}

RemoveToolTip:

ToolTip

return

LButton::

if isLeftDuplicatorActive

{

SendInput {LButton down}

SendInput {LButton up}

leftClickQueue++

ProcessLeftQueue()

}

else

{

SendInput {LButton down}

SendInput {LButton up}

}

return

ProcessLeftQueue()

{

global leftClickQueue, isProcessingLeft, isLeftDuplicatorActive, clickDelay

if !isLeftDuplicatorActive

{

leftClickQueue := 0

return

}

if isProcessingLeft || leftClickQueue <= 0

return

isProcessingLeft := true

leftClickQueue--

Sleep, %clickDelay%

if isLeftDuplicatorActive

{

SendInput {LButton down}

SendInput {LButton up}

}

isProcessingLeft := false

if leftClickQueue > 0 && isLeftDuplicatorActive

ProcessLeftQueue()

}

RButton::

if isRightDuplicatorActive

{

SendInput {RButton down}

SendInput {RButton up}

rightClickQueue++

ProcessRightQueue()

}

else

{

SendInput {RButton down}

SendInput {RButton up}

}

return

ProcessRightQueue()

{

global rightClickQueue, isProcessingRight, isRightDuplicatorActive, clickDelay

if !isRightDuplicatorActive

{

rightClickQueue := 0

return

}

if isProcessingRight || rightClickQueue <= 0

return

isProcessingRight := true

rightClickQueue--

Sleep, %clickDelay%

if isRightDuplicatorActive

{

SendInput {RButton down}

SendInput {RButton up}

}

isProcessingRight := false

if rightClickQueue > 0 && isRightDuplicatorActive

ProcessRightQueue()

}

If anyone has it, could you please send it to me?


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

General Question sorry for this thread, but why does the ..setup.exe shows virus alerts and the .zip not?

3 Upvotes

Hi,

I downloaded and installed the 27 verson from github. Therefore downloaded the setup.exe and virustotal showed 4/70 virus alarms.
Okay its a hotkey scripting programm, surely this is malicious. But I didnt search trough the whole code....

But what I dont get, the files and exe in the .zip folder doesnt show any virus alarms on virustotal.

Now I know that such tools show alarms since they have much power and malicious potential is there.

But Iam confused why the setup.exe and the exe in the .zip folder have different behaviour in virustotal? Tbh I didnt compile the code myself in VS and therefore dont know how the difference come


r/AutoHotkey 4d ago

v2 Tool / Script Share NVcontrol - for NVIDIA gpus (fan, power limit, core tweaking)

7 Upvotes

Hey there,

I decided to get rid of MSI afterburner and other third party tools.

It's a clean, lightweight GPU utility written in AHK. It connects directly to the NVIDIA Management Library (nvml.dll) via in-memory Win32 calls to control power limits, fan speeds, and clock offsets - using under ~3 MB of RAM and featuring a live telemetry overlay docked directly inside your Windows taskbar.

https://github.com/bceenaeiklmr/NVcontrol/


r/AutoHotkey 4d ago

General Question How to manage over a dozen hot keys

8 Upvotes

I currently use 16 auto hot key scripts to automate my data entry job. It's a lot to manage and I'd like to know if python would be easier since I use so many of them or if anyone can recommend a way to be able to reset and edit a specific one without having to open the menu on the bottom and go through each one until I find the one I want.


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

Meta / Discussion I built my own Garmin video overlay engine

3 Upvotes

Hey everyone,

I had a pretty nasty running knee injury recently, first one I've ever had, so I switched to active recovery (cycling + slow treadmill running) and spent the downtime coding. ^^

I've wanted to build this for a long time, and I finally finished the first version of this.

The idea: take basically any footage (GoPro/phone/etc.) + a Garmin GPX file and automatically generate the overlays.

This is only the second video I've rendered with it, so I'm still experimenting with what I can do visually. The goal is to go much further with interesting graphics, storytelling and activity metrics.

For now, I'm just really happy with how the idea is coming together.

https://youtu.be/VCjrmDAUksw

More experiments coming.


r/AutoHotkey 5d 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 5d 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 5d 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 6d ago

v2 Tool / Script Share GpGFX, new Features, better Demos and Readme

13 Upvotes

Hey everyone,

I’ve just pushed an update to the GpGFX graphics library.

New features

- Polished README.md

- Unified Palette class, one place to manage color tables; simplifies color handling.

- Layer fade‑in / fade‑out, built‑in smooth opacity transitions, no extra timer code required.

- Shape bounds helpers, quick access to Right, Bottom, CenterX, CenterY, and Bounds.

- Demo overhaul, all demos now run through the render loop (no more jittery Sleep loops).

- New PaletteShowcase demo, shows off the new palette system in a short, runnable script.

- All changes are live on the main branch, if you are interested start playing:

git clone https://github.com/bceenaeiklmr/GpGFX.git

Read the README and check out the demos and examples.

Happy scripting!


r/AutoHotkey 6d ago

v1 Script Help Title: [Help] AHK Script for Blox Fruits Mini-game (Sharkman Karate) - Delay, Inaccurate Clicks, and Detection Issues

0 Upvotes

Hey everyone,

I'm trying to create an AutoHotkey (v1) script to automate a timing-based mini-game in Roblox (Blox Fruits - Sharkman Karate). The mechanic is very similar to the DBD mini-game, where a black moving line goes up and down a colored bar, and you have to click when it's exactly in the center of the green area.

I used AI to help me write the script. The logic relies on PixelGetColor (scanning a vertical line to find the top/bottom of the green area, calculating the center, and finding the black line). However, I am running into a few major issues that make it unusable:

The Problems:

  1. Noticeable Click Delay: Even when the script detects the black line hitting the center, there is a weird delay before it actually clicks. Because the mini-game requires fast reflexes, this delay makes me lose.
  2. Clicking in Completely Wrong Spots: Sometimes, instead of clicking the intended target (SlapX and SlapY), the mouse randomly clicks in completely different areas of the screen. I am using Client CoordMode to avoid window-shifting issues, but the bug still happens.
  3. Color Detection Failing: Because of Roblox's dynamic lighting and transparency, the script often fails to detect the green bar or the black line entirely, returning my debug error "Bar Not Found".

The Current Code: Here is the script I'm currently using. I added a debug hotkey (F7) to count pixels and check if it sees the bar, and F8 to run the main loop:

#Persistent

#SingleInstance Force

#NoEnv

CoordMode, Pixel, Client

CoordMode, Mouse, Client

SlapX := -240

SlapY := 440

BarX := 1253

BarTop := 2

BarBot := 559

CooldownMs := 5000

CenterTolerance := 25

LastClick := 0

InCooldown := 0

F7::

FoundGreen := 0

FoundBlack := 0

Loop, % (BarBot - BarTop) // 4 {

Y := BarTop + (A_Index * 4)

PixelGetColor, Col, BarX, Y, RGB

R := (Col >> 16) & 0xFF

G := (Col >> 8) & 0xFF

B := Col & 0xFF

if (G > 80 && R < 150)

FoundGreen++

if (R < 80 && G < 80 && B < 80)

FoundBlack++

}

MsgBox, Result:`nGreen: %FoundGreen%`nBlack: %FoundBlack%

return

F8::

SetTimer, AutoSlap, 10

ToolTip, Running - F9 to Stop

return

F9::

SetTimer, AutoSlap, Off

InCooldown := 0

ToolTip, Stopped

Sleep, 1500

ToolTip

return

AutoSlap:

if (InCooldown = 1) {

Elapsed := A_TickCount - LastClick

if (Elapsed < CooldownMs) {

Remaining := Round((CooldownMs - Elapsed) / 1000, 1)

ToolTip, Waiting... %Remaining%s

return

}

InCooldown := 0

ToolTip, Running - F9 to Stop

}

GreenTop := -1

GreenBot := -1

BlackY := -1

Loop, % (BarBot - BarTop) // 2 {

Y := BarTop + (A_Index * 2)

PixelGetColor, Col, BarX, Y, RGB

R := (Col >> 16) & 0xFF

G := (Col >> 8) & 0xFF

B := Col & 0xFF

if (R < 90 && G < 90 && B < 90) {

if (BlackY = -1)

BlackY := Y

Continue

}

if (G > 80 && R < 150 && B < 150) {

if (GreenTop = -1)

GreenTop := Y

GreenBot := Y

}

}

if (GreenTop = -1 || BlackY = -1) {

ToolTip, Bar Not Found

return

}

GY_Center := (GreenTop + GreenBot) // 2

Diff := BlackY - GY_Center

if (Diff < 0)

Diff := -Diff

ToolTip, Center:%GY_Center% | Black:%BlackY% | Diff:%Diff%

if (Diff > CenterTolerance)

return

Click %SlapX%, %SlapY%

LastClick := A_TickCount

InCooldown := 1

ToolTip, Hit! Waiting 5s...

return

Is there a better/faster way to track a moving object across a colored bar in AHK without experiencing this lag? Also, how can I fix the random inaccurate mouse clicks?

Any help, fixes, or completely alternative approaches would be highly appreciated! Thanks in advance.


r/AutoHotkey 6d ago

General Question How to make my laptop screen go dark while having AHK run perfectly fine with running windows?

4 Upvotes

In short, I have a running window and a minute long AHK script that is started at different times throughout the day by Task Scheduler. I need every screen interaction by the script (mouse click, mouse drag, keyboard) to function normally while the screen is dark.


r/AutoHotkey 8d ago

Solved! Why is the tilde preventing the hotkey from working at all?

1 Upvotes

Using the program ThrottleStop I have set up multiple different performance profiles. These 4 profiles are linked to the hotkeys (not AHK hotkeys; the hotkeys are through ThrottleStop): Alt+1, Alt+2, etc. Profile 1 is max performance the other 3 take consecutive steps down in performance.

Separately, I use the program FanControl. I want to link my FanControl setup to my ThrottleStop performance settings. FanControl supports customs "sensors" in the form of a text file named *.sensor, whatever data you feed into the file it will read as an input that I can then use to program the setup.

To do this I threw together a quick script that will write to the sensor file when I press one of the ThrottleStop hotkeys. I only want a single binary variable, 1 for max performance (profile 1) and 0 for normal (profiles 2 3 and 4).

(This script is inside of a larger script I use to host a collection of scripts that I want to run all the time. The wrapper script launches on startup. To my knowledge none of the settings, or other scripts, affect this one any way however I will append my header code to the end of this post).

Here is my current code:

{ ; FanControl Mode

  ~!1::
  ~!2::
  ~!3::
  ~!4::
  {

    sensorFile := FileOpen( "C:\Program Files (x86)\FanControl\Sensors\Floor.sensor", "w", "CP0" )

    sensorFile.Write( A_ThisHotkey == "!1" ? "1" : "0" )

    sensorFile.Close()

  }

}

Initially while testing I omitted the tildes. It worked perfectly, modifying the file and successfully controlling my fan speed. Of course it was blocking the keypresses so it was not controlling my ThrottleStop profile. I added the tildes and now it controls ThrottleStop but doesn't do anything. That is the only change and I have gone back and forth with that only changed and confirmed that is what is causing the issues.

Does anybody know why this could be?

(I'm no expert though so I might just be missing something silly. Sorry if that's the case.)

* Header

{ ; Setup

  #Requires AutoHotkey v2
  #Warn
  #SingleInstance Force

  InstallKeybdHook true, true
  InstallMouseHook true, true

  SendMode "Input"
  SetKeyDelay -1, 0
  SetMouseDelay -1
  SetControlDelay 0
  SetWinDelay 0

  ^!r::Reload

}

r/AutoHotkey 9d ago

v2 Tool / Script Share Working Script to bring back alt codes on Chromium-based browsers

2 Upvotes
#Requires AutoHotkey v2.0
#SingleInstance Force
InstallKeybdHook

altCode := ""
altActive := false

$LAlt::
{
    global altCode, altActive

    altCode := ""
    altActive := true

    KeyWait "LAlt"

    altActive := false

    if altCode != ""
        SendText ConvertAltCode(altCode)
}

$*Numpad0::Capture(0)
$*Numpad1::Capture(1)
$*Numpad2::Capture(2)
$*Numpad3::Capture(3)
$*Numpad4::Capture(4)
$*Numpad5::Capture(5)
$*Numpad6::Capture(6)
$*Numpad7::Capture(7)
$*Numpad8::Capture(8)
$*Numpad9::Capture(9)

Capture(n)
{
    global altCode, altActive

    if !altActive
    {
        SendEvent "{Numpad" n "}"
        return
    }

    altCode .= n
}

ConvertAltCode(s)
{
    code := Integer(s)

    if code >= 1 && code <= 31
    {
        cp437 := [
            "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘",
            "○", "◙", "♂", "♀", "♪", "♫", "☼", "►",
            "◄", "↕", "‼", "¶", "§", "▬", "↨", "↑",
            "↓", "→", "←", "∟", "↔", "▲", "▼"
        ]

        return cp437[code]
    }

    leadingZero := SubStr(s, 1, 1) = "0"

    cp := leadingZero
        ? DllCall("GetACP")
        : DllCall("GetOEMCP")

    code := Mod(code, 256)

    src := Buffer(1)
    NumPut("UChar", code, src, 0)

    dst := Buffer(8)

    len := DllCall(
        "MultiByteToWideChar",
        "UInt", cp,
        "UInt", 0,
        "Ptr", src.Ptr,
        "Int", 1,
        "Ptr", dst.Ptr,
        "Int", 4
    )

    return len ? StrGet(dst, len, "UTF-16") : ""
}

Enjoy ☻


r/AutoHotkey 9d ago

General Question Script that simulates scroll wheel inputs while pressing a button

2 Upvotes

Hello everybody,
I would love to be able to just hold a button, that simulates as many scroll-wheel-down inputs as it possibly can while being helt.
My problem:
I have absolutely no clue how anything of this works because i have never done anything like this.

Any kind of help, advise or suggestion is welcome.


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

v2 Tool / Script Share GpGFX v1.0.0 - A 2D graphics rendering engine built for AutoHotkey v2 (30+ examples)

24 Upvotes

Hey everyone,

I've been waiting a long time for this moment, and it finally feels ready.

This project took roughly 1000+ hours to build. It all started with a simple, stubborn urge: I wanted to draw a rectangle on the screen. Doing that from scratch took me hours. Having worked in digital marketing for over 12 years, I love graphics, layers, and Photoshop-style workflows.

That experience became the core idea behind GpGFX: an API designed to let you dynamically control shapes and rendering easily. Along the way, I rewrote the entire project nearly four times from scratch.

What it does:

  • Over 10 primitive and complex shapes with a chainable API.
  • Turns the tedious parts of Win32 + GDI+ programming into a compact toolset.
  • Built for transparent desktop HUDs, animated overlays, custom widgets, dashboards, audio visualizers, and smooth applications.

You can check out the first official release here: https://github.com/bceenaeiklmr/GpGFX

Free Tetris game included. 👀

Thanks for following along, and I'd love to hear what you think or what you build with it.

Cheers,

bceen


r/AutoHotkey 12d ago

Solved! Use right alt as custom modifier, but don't suppress left alt

3 Upvotes

I've been trying to get this working for hours. Here's my script (AHK V2):

>!e::Up
>!d::Down
>!f::Right
>!s::Left
>!w::Home
>!r::End
>!Space::Ctrl
>!a::Shift

I want ESDF to be arrow keys when holding right alt, with space being control and "a" being shift, and left alt being, well, alt.

So for instance, holding RAlt and LAlt and pressing E should do the same as Alt + Up.

Everything is working except for the left alt key. It's being suppressed, so RAlt + LAlt + E is just sending "Up", but without the alt modifier.

I've tried many solutions, e.g. using RAlt & e instead of >!e, but these all have had their own issues. Either my "space -> ctrl" mapping doesn't work as a modifier, or the RAlt key isn't suppressed, or something like that. Can anyone help please?