I have a sequence of "move mouse to location", "left click", "delay" actions
I would like to start the sequence with a 'Set Value' action to establish a "DelayTime" variable. Then use that variable in the "delay" actions. So I can change them all by setting a different initial variable.
Hi there,
may be this will work for you...
define a numeric variable 'delaytime' and set to 7000 (ms)
call a java script...
like so:
.
java script by ChatGPT...
(async () => {
let result = await get_number_variable({ variable_name: 'delaytime' });
// Wait time in milliseconds
await new Promise(resolve => setTimeout(resolve, result));
returnToBTT(result);
})();
Thx,
Christian
I added something that might help with such stuff in 5.400 alpha. You can now transform any action sequence to a "Run Real Java Script" action by selecting the actions and choosing "Transform to Java Script:
To get a number variable you'd use
let variableValue = await get_number_variable("variableName")
wow great !
throw a bit of "formatting" in and it will be perfect...
like below by Gemini...
async function transformedActions() {
let result = undefined;
result = await trigger_action({
json: JSON.stringify({
BTTActionCategory: 0,
BTTIsPureAction: 1,
BTTPredefinedActionType: 292,
BTTPredefinedActionName: 'Assign or Set Value for Variable',
BTTVariablePersist: '0',
BTTVariableType: 0,
BTTVariableName: 'button_state',
BTTVariableValue: 'true',
BTTEnabled2: 1,
}),
wait_for_reply: true,
});
result = await trigger_action({
json: JSON.stringify({
BTTActionCategory: 0,
BTTIsPureAction: 1,
BTTPredefinedActionType: 292,
BTTPredefinedActionName: 'Assign or Set Value for Variable',
BTTVariableName: 'midi_velocity',
BTTVariableValue: '102',
BTTEnabled2: 1,
}),
wait_for_reply: true,
});
result = await trigger_action({
json: JSON.stringify({
BTTActionCategory: 0,
BTTIsPureAction: 1,
BTTPredefinedActionType: 292,
BTTPredefinedActionName: 'Assign or Set Value for Variable',
BTTVariableType: 1,
BTTVariableName: 'octave',
BTTVariableValue: '2',
BTTEnabled2: 1,
}),
wait_for_reply: true,
});
result = await trigger_action({
json: JSON.stringify({
BTTActionCategory: 0,
BTTIsPureAction: 1,
BTTPredefinedActionType: 292,
BTTPredefinedActionName: 'Assign or Set Value for Variable',
BTTVariableType: 0,
BTTVariableName: 'midi_note',
BTTVariableValue: '60',
BTTEnabled2: 1,
}),
wait_for_reply: true,
});
result = await trigger_action({
json: JSON.stringify({
BTTActionCategory: 0,
BTTIsPureAction: 1,
BTTPredefinedActionType: 254,
BTTPredefinedActionName: 'Show HUD Overlay',
BTTHUDActionConfiguration:
'{"BTTActionHUDBlur":true,"BTTActionHUDBackground":"66.431942, 66.433720, 66.432762, 255.000000","BTTIconConfigImageHeight":100,"BTTActionHUDPosition":0,"BTTActionHUDDetail":"","BTTActionHUDDuration":1.2000000476837158,"BTTActionHUDBorderColor":"213.541595, 213.546641, 213.543921, 255.000000","BTTActionHUDDisplayToUse":2,"BTTIconConfigImageWidth":100,"BTTActionHUDSlideDirection":2,"BTTActionHUDHideWhenOtherHUDAppears":false,"BTTActionHUDAttributedTitle":"{\\\\rtf1\\\\ansi\\\\ansicpg1252\\\\cocoartf2761\\n\\\\cocoatextscaling0\\\\cocoaplatform0{\\\\fonttbl\\\\f0\\\\fnil\\\\fcharset0 SFPro-Regular;}\\n{\\\\colortbl;\\\\red255\\\\green255\\\\blue255;\\\\red255\\\\green255\\\\blue255;}\\n{\\\\*\\\\expandedcolortbl;;\\\\csgray\\\\c100000;}\\n\\\\pard\\\\tx560\\\\tx1120\\\\tx1680\\\\tx2240\\\\tx2800\\\\tx3360\\\\tx3920\\\\tx4480\\\\tx5040\\\\tx5600\\\\tx6160\\\\tx6720\\\\sl0\\\\slmaximum500\\\\pardirnatural\\\\qc\\\\partightenfactor0\\n\\n\\\\f0\\\\fs32 \\\\cf2 On vars}","BTTActionHUDWidth":340,"BTTActionHUDBorderWidth":1,"BTTActionHUDTitle":"","BTTActionHUDHeight":70}',
BTTEnabled2: 1,
}),
wait_for_reply: true,
});
return true;
}
Getting back to this YEARS later!
I still didn't understand the answer. I was hoping to have a process where the first Action would be a Set Value action. It would create a variable called 'pause_length', set to .5
then in each "Delay next action" action I could use that variable as the value of the Delay by:.
