Hotkeys for special Autohotkey applications

I'm new to Autohotkey, and I can't figure it out despite reading this site and official documentation.

I just want some keyboard shortcuts to work only with certain applications. So, for example, if I press the spacebar in a certain game, I want it to send `(the grave), but if I'm not in this game, I want the spacebar to function normally. All I try to do is make the space bar do nothing when I'm not in the game. I can try using the else statement to send a space, but this seems like an infinite loop. Help!

EDIT: Thanks, NbdNnm. That's exactly what worked for me:

#IfWinActive League of Legends (TM) Client
Space :: `
#IfWinActive

+4
source share
1 answer

Try this and make sure you have the latest version of AutoHotkey installed. Put the application process name in the strYourAppExeName variable and put your hotkey definitions in the #if block.

 strYourAppExeName := "notepad.exe" strYourMessage := "``(grave)" #If WinActive("ahk_exe " strYourAppExeName) Space::SendInput, % strYourMessage #if 
+4
source

Source: https://habr.com/ru/post/1447605/


All Articles