Launch Application, or cycle windows if active


I'm looking for the ability to Launch an application, or, if it's currently active, cycle the windows.

I'm able to recreate it with AppleScript, but that adds a ~200ms delay, which is pretty noticeable, would be cool if there was a faster way included with BTT.

Here's my script if anyone is interested:

You'll need to run it with oscascript, since that's apparently the only way to pass arguments to AppleScript. I'm using "Execute Terminal command", but "Execute Shell task" should also work.

/usr/bin/osascript /Users/mike/Desktop/launch-or-cycle-windows.applescript


I think you could just execute both actions all the time. The Launch application action in BTT should only activate the app if it's not launched and not interfere with the shortcut:


Not sure if I've set the actions up correctly, but with this setup, it's switching to the app and immediately switching windows, where I'm looking for switch to the app if it's not focused, and if it is, then cycle windows.

(this is using the touchbar, not sure if you can configure things differently in another area)


Ah ok, then this might not work. Sorry!

I think your Apple Script could be faster if you'd make it static (i.e. without arguments) and use the dedicated Apple Script action in BTT. This is because when using osascript, it needs to recompile the script on every use, when using BTT it will cache the compiled scripts, also the BTT script runner processes are already loaded which will save a few more ms. I think I should add support for passing parameters :slight_smile:


Cool, I was wondering what the difference was with BTT's own Apple Script. I was surprised that even when using Script Editor to build a .app it was still slow. I don't mind copying the script between multiple for now. Let's see!


Yeah for some scripts it doesn't help, but it's definitely worth a try.


It's definitely faster now, thanks for the tip.