By Christian Scheuer @chrscheuer2019-07-29 01:20:14.032Z2019-07-29 01:34:49.022Z
Sometimes you want to do something advanced with Soundflow that our triggers don't support yet.
For example waiting on a specific window to become available, or something else.
In those cases you'll want to run a command in "background" mode, that is a command that's running indefinitely while allowing other commands to run (ie. don't block with a blue icon).
Here's some sample code to get you started with that:
//How often to check in milliseconds
var pollingIntervalMs = 100;
//sf.engine.runInBackground means: Run in background so other commands may run while we're running
sf.engine.runInBackground(function () {
//while(true) is an endless loop
while (true) {
//Check if anyone requested us to cancel all running commands every time we enter the loop
//The action will take care of aborting this command if necessary
sf.engine.checkForCancellation();
//Here you insert your code you want to execute every 100ms (or whatever you set the pollingIntervalMs to)
//Done with this iteration of the loop.
//To not eat up all the CPU, insert a 'wait' here so we wait until next time we want to check
sf.wait({
intervalMs: pollingIntervalMs,
executionMode: 'Background'
});
}
});
Linked from:
- In reply tochrscheuer⬆:Christian Scheuer @chrscheuer2019-07-29 01:27:02.150Z
Solution in the question
- Progress