Script precedence in loading definitions

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
roysubs
Posts: 428
Joined: 29 Sep 2018, 16:37

Script precedence in loading definitions

Post by roysubs » 29 Mar 2024, 02:42

I have multiple .ahk scripts, but I have a master script that has all of my main definitions, master.ahk. In the other scripts, they could be partially working or testing, and I might have keybindings that conflict with the master.ahk

If there is a keybinding in the second that is not in the first, I want that to load, but if there is a keybinding in the second file that was already loaded by the first, I do not want that definition to load as if master.ahk is loaded, I want that to ake precedence (if I want to test alternative keybindings in the other scripts, I will manually unload master.ahk and then load the subscript and test it). Is that possible?

Further, what if I want the other way around, and I want my otherstuff.ahk script to take precedence over master.ahk, so that it takes over keybindings, and then when I unload otherstuff.ahk, it reverts to the bindings in master.ahk. Is that possible?

Rohwedder
Posts: 7656
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script precedence in loading definitions

Post by Rohwedder » 29 Mar 2024, 03:56

Hallo,
I have not tested it, but it should work.
Switch all scripts to DetectHiddenWindows true and group the hotkeys by #HotIf WinExist( resp. #HotIf !WinExist( according to the hidden script's main window https://www.autohotkey.com/docs/v2/Program.htm#main-window
So each script controls the activity of its hotkeys according to the existence of other running scripts.

Post Reply

Return to “Ask for Help (v2)”