Control Flow Actions
Starting with BetterTouchTool 4.245, some actions to control the action flow are included in BTT:
- If Condition (based on variables)
- If Image Visible On Sceen
- Loop / Repeat
- Cycle through multiple actions (on repeated trigger)
- Delay (blocking & async)
If conditions always need at least 4 actions in BTT:
- The condition (which can either be based on variables, or whether a specific image can be found on your screen)
- An action that is executed if the if condition is true
- The "End If Condition"
In case you want to execute different actions when the condition is false you need to add the following before the End If:
- The "Else" branch action
- The actions that shall be executed in case the condition is false
In the screenshot above you see an example that begins by asking the user for input. That input is saved to the variable var1. This is follwed by an if condition that checks whether the var1 variable is 1 and does execute a "Show HUD" action if thats the case. This is followed by another if that executes different actions depending on whether the var1 variable is equal to 0 or not.
Wait For Condition To Become True
This is a helpful action if you want to wait for something before triggering other actions. For example if you want to create a keyboard shortcut that automatically maximizes a window once the app has fully launched, you could do it like in this screenshot:
If you want to repeat the same actions multiple times, use the "Start Repeat / For Loop" action.
The following screenshot contains an example that first asks the user how many times the loop shall repeat, then executes a "Show HUD" action multiple times.
You can access the current counter of a loop (e.g. via scripts) using the variable loop_loopname variable, which will automatically be populated.
Cycle Through Mutliple Actions
Sometimes you might want to use one trigger to execute multiple different actions when it is triggered repeatedly. For example a keyboard shortcut you press multiple times to cycle through different window positions. You can achieve this using the "Cycle Through Multiple Actions" action. One such action can contain multiple action sequences that will be triggered step by step, one action sequence per time the trigger is executed.