Created Named Trigger variable but get_string_variable failed as trigger not active

I created a Named Trigger: emacsclient which consists very simply with the following settings:

tell application "BetterTouchTool"
trigger_action "{
  BTTActionCategory: 0,
  BTTPredefinedActionType: 292,
  BTTPredefinedActionName: 'Assign or Set Value for Variable',
  BTTVariablePersist: '1',
  BTTVariableOnlySetIfNotYetDefined: 0,
  BTTVariableName: 'emacsclient',
  BTTVariableValue: '/Applications/MacPorts/EmacsMac.app/Contents/MacOS/bin/emacsclient -nqe',
  BTTEnabled2: 1,
}"


end tell

But when I then try to get that value it fails

tell application "BetterTouchTool"
	try
    set EC to get_string_variable "emacsclient"
	end try
end tell
return EC

The result is missing value.

As I typed the above it occurred to me that I'd never executed the named trigger. And sure enough if I action it once it is then set.

Did I miss some documentation on this implementation?

Searching here I could not find this information, so sharing here as it might help someone else in the future.

Unfortunately you can't use named triggers like that. However you could use dynamic variables. Here is an example:


1 Like

Or if it's really just static variables, you could use the "After BetterTouchTool Did Launch" trigger and just assign your "set variable" actions:

1 Like

Thank you @Andreas_Hegenberg for both of these solutions. I was after a global static, its value would to be the same for all scripts whether in a Named Trigger or elsewhere and so the use of Dynamic Variables is the solution. I clearly missed where that was to be set.

The use of a static variable is interesting mind I was intending to create a trigger stack that first uses Set Value and then follows it with a Named Trigger that uses the value. Is that intended or should I just keep to using Dynamic variables in this instance?

Much appreciated.