Can BTT execute/run Swift scripts?

I haven't found a predefined action with that name.

Is this not suitable for you?

Hi @xidiot do you mean just copying the script in there? Unfortunately, that doesn't work.

Nope, use it like this:

/usr/bin/swift $path_to_script.swift

Please excuse my ignorance. Where should the script go, then?

You need to save the script somewhere (this is $path_to_script.swift) and in the action itself under "Script" section you put /usr/bin/swift $path_to_script.swift, e.g. /usr/bin/swift /Users/frank/scripts/myscript.swift

I have added an easier and more powerful way to run swift scripts in 6.755 - with the ability to use BTT's scripting functions from there as well:

The predefined action is called "Run Swift Script"

That sounds good, thanks. I can’t test it right now because I’m not at my computer. I asked because I received a set of swift scripts that do things which are otherwise not so easy to accomplish. For example, moving the mouse to the selected item in the Finder or another app.

However, people often point out a downside: Swift scripts are supposed to be much, much slower than others. Is that true? Or not with BTT?

With the new action they will only be slow the very first time you use them. Then BTT keeps the compiled version cached making them faster than any other option.

yes, sorry, you already answer the question in the manual. I only just saw that now.

But what does that mean compared to other scripts?

depends! :sweat_smile:
Probably faster for many things but this is not easy to answer for all cases. Some things might be slower or equal to other scripting types.

Depends … are you a lawyer? :joy:

I’ve found a speed comparison. These results are shocking.

image

Ah, but maybe that has to do with the fact that they only measured the first run.

yeah these measure the compile time, once compiled the swift result will be lower than AS and also lower then Shell for most/many scenarios

Andreas you just keep giving us gifts!!
Are you the only developer working on BTT? Your baby has grown to be one of the most sophisticated and functional applications of all time.

I remember when there was fear that Apple was planning on making MacOS more like iOS - locking down low levell APIs, 'foolproofing' the system by gatekeeping customization etc. Thankfully they didnt go in that direction, and I had a thought the other day that perhaps there are simply too many people at apple headquarters with dozens of bettertouchtool triggers they couldnt bear living without who put their foot down!!