HUD display {variables}


I have noticed that custom variables are updated with a considerable delay
is perhaps the HUD display the issue and not displaying them properly ?

here is what I do.

cmd click to trigger the following actions:
1 - trigger a named trigger
which sets the {mouse_in_area} variable to true or false
depending on the mouse cursor is IN or OUT of a defined screen area
2 - then a delay of 1.2 seconds (- only to debug -)
3 - then a HUD display, which 'sometimes' shows not the correct {mouse_in_area} value,

but when checking in BTT settings the {mouse_in_area} variable is actually correct (and is sometimes not the same as displayed before in the HUD….)

This is quite annoying, as I never know whether the display is actually correct or not.

What could caused this? I don’t want avoid to use delay actions to attempt ‘fix’ this…


BTT 3.9993 (2193) / Mac M1 Max OS 13.2 (22D49)
BTT plugin Stream Deck option
Stream Deck Mobile (on iPad Air)

how exactly are you setting the variable? Using the predefined action "assign value to variable"? Or via a script?

Hallo Andreas,

The HUD is displayed after the mouse click and then I have a keyboard shortcut (to debug) which calls up a HUD (same layout/text) and that one shows "sometimes' a different value...
so it looks to me that it took some time to update that variable...

I use a script ..

let MouseInArea1 = await callBTT('set_string_variable', {variable_name: 'mouse_in_area', to: "true" });

here is the full script....

// ----- IsMouseInArea -----
(async ()=> {

// define screen area example 100,-1  to 200,-1440 
// Mouse Position from Top Left Corner
// --- play button Ableton ---
const leftTop_x = 532;
const leftTop_y = -72;
const rightBottom_x = 552;
const rightBottom_y = -92;

let x1 = await callBTT('set_string_variable', {variable_name: 'leftTop_x', to: leftTop_x });
let x2 = await callBTT('set_string_variable', {variable_name: 'leftTop_y', to: leftTop_y });

let y1 = await callBTT('set_string_variable', {variable_name: 'rightBottom_x', to: rightBottom_x });
let y2 = await callBTT('set_string_variable', {variable_name: 'rightBottom_y', to: rightBottom_y });

// -----------------

const mouse_x = await callBTT('get_number_variable', {variable_name:'mouse_position_x'});
const mouse_y = await callBTT('get_number_variable', {variable_name:'mouse_position_y'});

let xy1 = await callBTT('set_string_variable', {variable_name: 'mouse_x', to: mouse_x });
let xy2 = await callBTT('set_string_variable', {variable_name: 'mouse_y', to: mouse_y });

// if((leftTop_x <= mouse_x && rightBottom_x >= mouse_x) && (leftTop_y <= mouse_y && rightBottom_y >= mouse_y))

// if(leftTop_x <= mouse_x && rightBottom_x >= mouse_x)
// if(leftTop_y >= mouse_y && rightBottom_y <= mouse_y)

if((leftTop_x <= mouse_x && rightBottom_x >= mouse_x) && (leftTop_y >= mouse_y && rightBottom_y <= mouse_y))

    // --- mouse in screen area --- 
    let MouseInArea1 = await callBTT('set_string_variable', {variable_name: 'mouse_in_area', to: "true" });
    // --- mouse NOT in screen area ---
    let MouseInArea2 = await callBTT('set_string_variable', {variable_name: 'mouse_in_area', to: "false" });





The script is run asynchronously, that means the next action in your sequence won't wait for it to finish. Right now there is no way to make it wait for the return (but I'll add that soon).

The easiest way to solve this is to add a little delay (0.1s should be enough). However you probably need to use the async delay action for this to work.

Alternatively you can setup a separate hud trigger and call it from your Java Script via (after you have set the variables)

 await callBTT('trigger_named', {trigger_name: 'YourHUDTrigger'});

I never thought of the "separate hud trigger and call it from within that Java Script..." - that will do the debugging a bit easier, for the rest I use the 'delay' approach.

if I use Apple script/blocking (instead of Java script) would the next action in sequence wait for it to finish ?

Update: It works fine...
Thanks GPT for 'translated' the Javascript in a brise to Apple Script, only one small adjustment...and it works...


yep I have also used chatGPT to convert some JS to Apple script today :grinning:

1 Like