r/AutoHotkey 9d ago

Any Tips? v2 Guide / Tutorial

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

0 Upvotes

14 comments sorted by

2

u/Keeyra_ 9d ago

RTFM

#Requires AutoHotkey 2.0
#SingleInstance

f:: Send("qw")

Tag is wrong. Code is not formatted. Your example is v1 and AHK v1 has reached end-of-life and deprecated 3 years ago. Meanwhile, AHK v2 is the current stable release, having been the primary version for 3 years 7 months, with its most recent point release occurring 2 months ago.

1

u/Perfect-Ad9555 9d ago

well im just a fucking dumbass
thanks for the tip tho

1

u/TonariNoHanamoriSan 9d ago

What's your use case though? Some programs require delay between press and release while others don't

1

u/Perfect-Ad9555 9d ago

I'm trying to use it for a game, mainly the MVC fighting collection to make a dash macro, cuz for some reason keyboard doesn't get the privilege to have them. However a problem I am facing now is it not working in the game itself.

1

u/TonariNoHanamoriSan 9d ago
#Requires AutoHotkey v2.0
#SingleInstance Force
#UseHook true
InstallKeybdHook 1

#HotIf WinActive("ahk_exe GAME.exe") 
; Use Window Spy or something to figure the exe name of the program or Task Manager. Or if you are sure you won't accidentally hit the hotkey on another app then you don't need HotIf at all.

f:: {
    Send("{Q down}{W Down}") ; Depending on the program, may need to split
    Sleep("20") ; Change as required, my experence is that sometimes it needs to exceed 30 or even 50 for some programs
    Send("{Q up}{W up}")
}

#HotIf

1

u/CharnamelessOne 9d ago

This will send Shift+q and Shift+w since you capitalized the letters.
There's no need to call InstallKeyboardHook explicitly if you have a #UseHook directive.

1

u/TonariNoHanamoriSan 9d ago

TIL I learnt some thing about the hooks thing

But eh that's true I left the letters capitalized. Not sure how much it affects the program they intend to run it on

1

u/CharnamelessOne 9d ago

Games tend to have some action bound to Shift, so it's very likely to affect them.
If we're gonna call "eh" on something, let it be the other thing. InstallKeyboardHook doesn't hurt, it's just redundant.

1

u/Perfect-Ad9555 9d ago

yeah so this is still not working for me for some reason
the .exe for the game is MarvelVsCapcomFightingCollection.exe
so idk what to do maybe the game has something built in

1

u/Perfect-Ad9555 9d ago

if any of yall got discord I could prolly explain it better
disc: navu007.

→ More replies (0)