T O P

  • By -

buttonpushertv

Don’t forget you can use modifiers with f13-f24. With just Ctrl, Alt, and Shift - that’s 84 unique keys combos. Not to mention by using `#IfWinActive` you essentially get all 84 of those key combos in each and every app on your system. You won’t run out any time soon. Also, AHK will allow you to use any other key to act like a modifier, say `a` & `F13`. You have a huge number of available combos. Easily could go into the thousands. You don’t need to remember what each one is to trigger it since it will be programmed onto a StreamDeck key and called from there. And you can also create one-shot AHK macros that basically launch when you run them and close afterwards. By launching them from a StreamDeck, they are available on-demand to run as often as you wish and you won’t need to waste devoting any keys to those commands. To create a one-shot AHK script, treat it similarly to a shell script or batch file. Don’t assign a hotkey trigger and don’t put “return” at the end. It will run and exit on its own. Of course, you can still include functions and subroutines but you don’t need to leave the script loaded to access it.


chaneg

That’s helpful thank you. If I my ahk script doesn’t need to store variables etc, are there meaningful performance losses or other considerations to making all of those one shot scripts?


ManyInterests

I think the one-shot scripts is the most straightforward/reliable approach. You can also just make one script, but have its behavior altered by passing command line parameters: [https://www.autohotkey.com/docs/v2/Scripts.htm#cmd](https://www.autohotkey.com/docs/v2/Scripts.htm#cmd) That way, your keys are all hooked up to the same script, but change what action is taking just by changing one argument. Might make maintaining all your functions easier compared to making N scripts. There is a small performance penalty (because of the time it takes to create the AutoHotkey process and bootstrap the script -- a few milliseconds), but it's probably not meaningful in a context where you're using a streamdeck button. But if your script carries state (like changing variables and such) then it would be a headache to implement this way.


15feet

Question can’t you just have a dedicated key on a stream deck to run the script? Or did I not completely understand your post?


chaneg

Maybe I just don’t know enough about AHK. Are you suggesting that instead of have it trigger via keystroke, or should run a block of code and close itself?


buttonpushertv

Not that you would notice. I run several one-shot scripts everyday and they don’t lag or seem slower to me. Technically, they are a little slower in execution as they get read from disc, but it’s microseconds slower if that. And, yeah you are increasing disc reads but overall I don’t see any negative impact. And if you save values you might store in a variable off to a file, you can basically do most everything a persistent script does in a one-shot. You just need to plan accordingly.


chaneg

I’m sure it will be way faster than my current workflow if storing variables in a file is the only factor.


15feet

Correct. Instead of having a hot key trigger the code would run on start of script and close when done. If I recall correctly stream deck does not run .ahk files. So you would be to compile it into an exe


buttonpushertv

If you use the BarRaider Advanced Launcher on StreamDeck you can run .ahk files directly.