|Purpose:||Monitor when a Bluetooth device is connected or disconnected.|
|Format:||BTMONITOR [/C [action]]|
BTMONITOR name [Connected | Disconnected] [n | FOREVER] command
The Bluetooth name can include wildcards.
The command line will be parsed and expanded before BTMONITOR is executed, so if you want to pass redirection characters or variables to command you will need to protect them (by enclosing in single back quotes, doubling the %'s, or using command grouping).
If the last argument on the line is a single (, it is interpreted as the beginning of a command group. BTMONITOR will append the following lines (in a batch file) or prompt you for more input (at the command line) until it gets a closing ).
If you don't enter any arguments, BTMONITOR will display the Bluetooth devices it is currently monitoring.
The monitoring runs asynchronously in a separate thread. When the condition is triggered, the command will be executed immediately. This may cause problems if you try to write to the display or access files while the main TCC thread is also performing I/O. You may need to use START or DETACH in command to avoid conflicts.
BTMONITOR creates several environment variables when a Bluetooth device is connected or disconnected that can be queried by command. The variables are deleted after command is executed.
_btindex - The index of the Bluetooth device being connected or disconnected (for the @btdevice... functions)
_btaddress - The address of the Bluetooth device being connected or disconnected
_btname - The name of the Bluetooth device being connected or disconnected