Multiple scripts trying to set same hotkey?

Get help with using AutoHotkey and its commands and hotkeys
jesseleite
Posts: 3
Joined: 13 Jul 2018, 12:46

Multiple scripts trying to set same hotkey?

13 Jul 2018, 13:03

So I have these two scripts caps-hjkl.ahk, and game-specific-caps-mappings.ahk. The first script there works as expected:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



In the second script, want to override CapsLock mappings for very specific active windows:

Code: [Select all] [Download] GeSHi © Codebox Plus

#IfWinActive ahk_class Starcraft
CapsLock::Send {Insert}
#IfWinActive ahk_class AOE2
CapsLock::Send {Pause}


However, I can't get the two scripts to play together nicely. It seems whichever order they are executed/opened in, affects precedence. I know I could do this if I combined the scripts into one, but I'm trying to keep functionality separate so that I can share the first script on github, but still have my custom window specific overrides locally. Any idea if this is possible?
Qysh
Posts: 139
Joined: 24 Apr 2018, 09:16

Re: Multiple scripts trying to set same hotkey?

13 Jul 2018, 13:38

Try those


Or this
jesseleite
Posts: 3
Joined: 13 Jul 2018, 12:46

Re: Multiple scripts trying to set same hotkey?

13 Jul 2018, 14:45

Thanks for reply! Yeah I see what you are doing in the second example, but trying to keep them separate files if I can so that I can share the hjkl functionality on github, and have my game overrides a more local/personal thing. The first example doesn't seem to work. If I reload the first caps+hjkl script, the second override script stops working still.
jesseleite
Posts: 3
Joined: 13 Jul 2018, 12:46

Re: Multiple scripts trying to set same hotkey?

Yesterday, 16:34

Figured it out! Now I have this in my main autohotkey script:

Code: [Select all] [Download] GeSHi © Codebox Plus

#include includes/caps-hjkl-or-esc.ahk

OverrideCapsLock()
{
If WinActive("Brood War")
return "."
If WinActive("Age of Empires")
return "."
}


And this is my caps-hjkl-or-esc.ahk script:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Now I can share that caps+hjkl script on github for other vim users, but still completely override it locally in another script for specific games, etc. The dynamic function call there fails silently if the user doesn't define an OverrideCapsLock() function. If anyone is interested, https://github.com/JesseLeite/dotfiles/ ... or-esc.ahk

Return to “Ask For Help”

Who is online

Users browsing this forum: simonk and 53 guests