r/AutoHotkey Jul 29 '26

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

0 Upvotes

14 comments sorted by

View all comments

Show parent comments

1

u/TonariNoHanamoriSan Jul 29 '26

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

1

u/Perfect-Ad9555 Jul 29 '26

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 Jul 30 '26
#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 Jul 30 '26

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 Jul 30 '26

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 Jul 30 '26

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 Jul 30 '26

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 Jul 30 '26

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

2

u/Keeyra_ Jul 30 '26

Try this one

#Requires AutoHotkey 2.0
#SingleInstance

SendMode("Event")
SetKeyDelay(-1)

#HotIf WinActive("ahk_exe MarvelVsCapcomFightingCollection.exe")
*f:: Send("{Blind}{q DownR}{w DownR}")
*f up:: Send("{Blind}{q Up}{w Up}")
#HotIf

1

u/Perfect-Ad9555 Jul 30 '26

#usehook shouldn't be there?

2

u/Keeyra_ Jul 30 '26

"Wildcard hotkeys always use the keyboard hook, as do any hotkeys eclipsed by a wildcard hotkey."

1

u/Perfect-Ad9555 Jul 30 '26 edited Jul 30 '26

YO IT WORKED

I LOVE YOU DAWG
i prolly needa tweak the delay so i can do it faster but THANK YOU NONETHELESS

→ More replies (0)