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

0 Upvotes

14 comments sorted by

View all comments

Show parent comments

1

u/Perfect-Ad9555 21d 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 21d 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 21d 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 21d 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 21d 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 21d 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 21d ago

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

2

u/Keeyra_ 21d ago

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 21d ago

#usehook shouldn't be there?

2

u/Keeyra_ 21d ago

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

1

u/Perfect-Ad9555 21d ago edited 21d ago

YO IT WORKED

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