The goal of this example is to demonstrate how to use generic buttons to trigger the OS X Application Switcher. This assumes that the reader is familiar with the basics of creating Building Blocks as shown in the Detailed Tutorial.
The Application Switcher requires some interesting logic because of the unusual way that it reacts to the keyboard. The Application Switcher is initiated by pressing Command-Tab or Command-Shift-Tab on the keyboard to change to the next or previous application. While the Command key is held, the Application Switcher remains active. Pressing Tab or Shift-Tab while the Command key remains held will cause the Application Switcher to keep changing applications. When the Command key is finally released, the Application Switcher disappears and the new application becomes active.
ControllerMate's building blocks can trigger the "Next Application" and "Previous Application" functions using the Application Switcher based on activity from generic buttons.
The above set of building blocks will activate the Application Switcher when Button #21 or Button #24 on the X-keys XK-24 is pressed. As long as one button or the other is being pressed, the Application Switcher will remain active. When neither button has been pressed for one second, the Application Switcher will disappear and the new application will become active.
Taking these blocks one group at a time, the center group controls the Command key.
The Single Key building block is configured to press the Command key when its input turns ON and hold it until its input turns OFF.
The Dwell building block is configured to turn ON when its input turns ON, and to remain ON until its input stays OFF for 1.00s.
The OR building block allows either button to turn ON the Command key.
Taken together, these three blocks allow either button to press the Command key. If a button is held, then the Command key will remain pressed. If the buttons are repeatedly pushed, then the Command key will remain pressed as long as there is not more than a one second gap between button presses. When neither button has been pressed for one second, then the Command key will be released.
The bottom-left group controls the Shift-Tab keystroke.
The Single Key building block is configured to generate the Shift-Tab keystroke.
The AND building block is used to turn on the Keystrokes block after the left button has been pressed AND after the Command key has turned ON. Using an AND block like this guarantees that the Shift-Tab occurs only after the Command key has been pressed.
The bottom-right group is identical to the bottom-left group except that it generates a Tab keystroke instead of a Shift-Tab.
When taken all together, Button #24 on the X-keys XK-24 will press the Command key then press Tab. This will activate the Application Switcher. Pressing Button #24 again will cause the Application Switcher to change to the next application, pressing Button #21 will cause the Application Switcher to change to the previous application. After both Button #21 and #24 have remain released for one second, the Application Switcher will disappear and the selected application will become active.
To change the amount of time that the Application Switcher remains active before disappearing, change the time setting in the Dwell building block.
A less obvious variation of this configuration is to exchange the Dwell building block for a Pulse Count building block. The Pulse Count can be configured to detect a double-click.
When configured as is shown to the right, the Pulse Count building block will turn its output ON only if it detects two input pulses within one second. This requires a double-click of either Button #21 or #24 to activate the Application Switcher.
After the Application Switcher has been activated, a single-click will select the next or previous application.