Issue with BTT's API for applescript

I must be missing something here because each and every example function (or custom, for that is) which I tried in my BTT returns missing value.
I tried the scripting API here

I, for example, created a BTT Button which as action executes an AppleScript:

tell application "BetterTouchTool"

trigger_named "TriggerName" 

end tell

I have a trigger named TriggerName in "Other Triggers" section.

But whenever I run the script or press the BTT button that invokes the script, the result returned is simply missing value

It does not matter which of the script examples at I try, they all fail with the same issue.

My final goal is a BTT Button that (by script) sets a BTT User Variable to show, so in another widget, I can retrieve that BTT User Variable and if == show then return a value so to show this second button, otherwise hide it.
But I fail already at the basic scripting.

Anyone can provide me with a working example of how should be used?

it would only return a value if the named trigger itself would trigger a script that again has a return value.

If you just want to return something add

return "something"

to your script.

Possibly have a look at the goldenchaos or aquatouch preset, they contain loads of BTT apple scripts

Hey Andreas, thanks for helping.

Maybe I explained wrong - let's use the "Conditional activation groups" as an example.

As per this release note I understand we can:

Conditional activation groups now offer some variables as condition. The variables can be set using Apple Script (e.g. tell application "BetterTouchTool" set_string_variable "customVariable1" to "test" end tell)

So, I went and created a "Conditional activation group", I set the condition to only show if customVariable1 is equal yes.

I created in a specific App Group a Button, which triggers an AppleScript (blocking, but I also tried asynchronously). The script this button triggers when pressed in the touch bar:

tell application "BetterTouchTool"
    set_string_variable "customVariable1" to "yes"
end tell

When I now compile and test that script the result is "missing value".

When I test the button in the touch bar, my conditional group's contents do not show up (because the condition isn't met, I assume).

I took those examples from the release and doc of BTT; so I think I must be missing a specific detail.
I looked at GoldenChaos buttons which have a similar setup and their code gave me some ideas, however, I still cannot make it work.

The examples from the DOC give me the missing value (since customVariable1 never defined somehow) as result, and the code from golden chaos is not yet helping me (it's very widespread).

I am approaching this right, yes?

  1. create the button in an app group and with AppleScript action set the customVariable1 to "yes"
  2. Listen in a conditional group to that variable to show or not show the group.

Should be simple enough, seems I have to try harder :smiley:

1 Like