Advanced Conditions: Calculations with variables

Hi there,

first off, I love BTT's functionality, especially with advanced conditions!

I have a question regarding those advanced conditions though:
Is there a way to create conditions containing simple calculations with variables? As an example I was thinking about something like this:

rightmost_touch_x_percent - leftmost_touch_x_percent >= 30
AND condition fingers_touching_trackpad == 2

This could be true if I use my index and little finger to touch the trackpad instead of index and middle finger.

This is just one example. In my opinion this could open up a lot of possibilities for interesting advanced conditions.

Your help would be much appreciated.

Best regards


Unfortunately the conditions editor (a standard macOS component) doesn't allow this.
However if you need such conditions I'd recommend to use the "Real Java Script" action. E.g.

(async ()=> {
const rightMostTouch = await callBTT('get_number_variable', {variable_name:'rightmost_touch_x_percent'} };
const leftMostTouch = await callBTT('get_number_variable', {variable_name:'lefttmost_touch_x_percent'} };
const touching = await callBTT('get_number_variable', {variable_name:'fingers_touching_trackpad'} };

if(rightMostTouch - leftMostTouch >= 30 && touching == 2) {
// named triggers can be configured in the "Automations, Named & Other Triggers" section
let result = await callBTT('trigger_named', {trigger_name: 'Action5'});


Thanks a lot for your quick reply!

I am a bit intimidated by the script but I will try to play around with it.

Best regards


Most of it is just getting the variable you need, and then checking your condition. If the condition is true, the script will trigger a named trigger which in this example is called "action5".

Much appreciated, thanks!

I am really sorry to bother you again, but after playing around a bit I feel pretty stuck:
It seems as if I can not get variables from the advanced conditions like finger_touching_trackpad or left_mouse_down with the get_number_variable function.

A simple example:

(async ()=> {

let result = await callBTT('get_number_variable', {variable_name:'fingers_touching_trackpad'});



This simply gives me an "undefined".

It is very well possible that I am missing something or that I am getting something wrong here since this is pretty much my first time using Java Script.

Any advice would again be much appreciated.

Best regards


Sorry, I forgot to mention that this requires the latest alpha version as there has been a bug retrieving number variables, which has been fixed recently.

Thanks for the clarification. Outstanding support!

Best regards


Hi Andreas,

thanks again for your suggestion to use the "Real Java Script" action. It works just as intended.

I have a follow-up question though since I realised that the only calculations that I need for my idea are the following three:

  1. Distance in x-direction: distance_x = rightmost_touch_x_percent – leftmost_touch_x_percent

  2. Distance in y-direction: distance_y = rightmost_touch_y_percent – leftmost_touch_y_percent

  3. Distance in the xy-plane: distance_xy = Sqrt(distance_x^2 + distance_y^2)

Would it be possible for you to provide those distance variables from your side to be used in advanced conditions? That would simplify the realization my idea a lot.

Thanks for your great support and best regards