In the above formula, once a particular Criteria is found to be true, the corresponding Action is executed and the formula stops. If none of the Criteria are true, the formula sends a backtick ("`").
Note: I am a quadriplegic with paralyzed hands. As a result, I have AHK scripts written for almost every conceivable action and generally have several hundred of them, each with its own hotkey, running at the same time. That creates the problem of having and remembering a large number of hotkeys.
What I would like to do is, for a given Hotkey, set up multiple Actions with the Action being executed dependent on which window is active.
So for example, let's say the Hotkey is F2, the script would look something like this (I know the following is not a real script but hopefully it conveys what I am after):
In this way, and assuming I can get a given Hotkey's script to stop once it finds the active window, I could have a single hotkey trigger multiple different macros depending simply on which window is currently active.
First, let me say I am not an AHK person, so can only speak a little hypothetically. However, another conceptual approach would be to drive the decision matrix you are descripting with data, rather than a bunch of IF statements.
So, what I'm imagining is a "table" (array) of data in AHK that has three columns, KEY, WINDOW, ACTION. Then when a key is pressed the handler for that keypress is activated in AHK and it looks up the key and current window in this table, and then invokes the specified action. Seems like it might be easier to implement and maintain, but again, I can't propose actual AHK code and can't speak to any limitations that would make this difficult.
I'm sure Joe can add some thoughts.
»bp
Joe Winograd
Hi Bill,
That's an interesting idea and doable in AutoHotkey. That said, the so-called #IfWin directives are in the language specifically to make it easy to create context-sensitive hotkeys (hotstrings, too). I'd be inclined to go that way, but your idea certainly has merit. Regards, Joe
So, what I'm imagining is a "table" (array) of data in AHK that has three columns, KEY, WINDOW, ACTION. Then when a key is pressed the handler for that keypress is activated in AHK and it looks up the key and current window in this table, and then invokes the specified action. Seems like it might be easier to implement and maintain, but again, I can't propose actual AHK code and can't speak to any limitations that would make this difficult.
I'm sure Joe can add some thoughts.
»bp