Available Standard Variables
Using Variables in BetterTouchTool
Variables in BTT can be quite useful when using AppleScript / JavaScript and the like. There are three types of variables:
- Temporary Variables - will only be available until BTT quits
- Persistent Variables - will be persisted and be available all the time
- Dynamic Variables - they are calculated dynamically. BTT comes with a small set of helpful dynamic variables.
Dynamic Variables provided by BTT:
Important: ALL variables you can see in Conditional Activation Groups or in Advanced Trigger Conditions can also be queried via script!
-
selected_text - The currently selected text. Readonly.
-
BTTActiveWindowTitle - The title of the active window. Readonly.
-
ActiveSpace - The ID number of the active space.
-
OutputVolume - The current output volume of the system. Readable and writable.
-
BuiltInDisplayBrightness - The brightness of the built in display. Readable and writable.
-
BTTCurrentlyPlaying - This variable returns whether the system is currently playing music/video (1 or 0). When called it also starts to observe further details and will make the following variables available:
- BTTNowPlayingInfoArtist
- BTTNowPlayingInfoTitle
- BTTNowPlayingInfoAlbum
- BTTNowPlayingInfoDuration
- BTTNowPlayingInfoTrackNumber
-
BTTTouchBarVisible - Tells you whether the BTT custom Touch Bar is currently visible or not.
-
BTTCurrentlyPlayingApp - The app identifier of the app that is currently playing video or audio. Read only.
-
BTTInternalNightShiftState - Is the BTT night shift currently active or not? (Does not necessarily represent the system night shift state)
-
SystemDoNotDisturbState - The current state of "do not disturb". Readable & writable.
-
BluetoothConnectionState-MACADDRESS-OR-NAME - Returns whether a device is connected. Can contain wildcards (kind of dynamic-dynamic variable). E.g. BluetoothConnectionState-Airpod. Readable and writable.
-
BTTActiveAppBundleIdentifier - The bundle identifier of the currently active app. Readonly.
-
BTTActiveWindowNumber - The window number of the active window (to identify a window). Readonly.
-
BTTTouchBarHasPhysicalESCKey - Is 1 if the Touch Bar MacBook has a physical ESC key. Readonly.
-
BTTLastTriggeredAction - The ID of the last triggered BTT action. Readonly.
-
BTTLastTriggeredUUID - The UUID of the last triggered BTT action. Readonly.
-
BTTLastTriggerTime - The timestamp when the last BTT action was triggered.
You can always see your temporary and dynamic variables in the BetterTouchTool settings:

Advanced Trigger Condition Variables
Every variable that can be used inside of advanced trigger conditions or conditional activation groups can also be used anywhere else where variables can be used. As of version 4.865 these advanced trigger condition variables are available:
color_under_cursorfocused_element_rolefocused_element_subroleselected_textconnected_wifi_nameactive_website_urlfocused_window_titlefocused_window_app_nameactive_app_nameactive_app_bundle_identifierleft_mouse_downmiddle_mouse_downright_mouse_downcurrently_pressed_mouse_buttonscurrently_pressed_keyboard_keystrackpad_idfingers_touching_trackpadtrackpad_touch_durationthumb_recognizedthumb_x_percentthumb_y_percentleftmost_touch_xleftmost_touch_yrightmost_touch_xrightmost_touch_yleftmost_rightmost_touch_distance_percentfingers_touching_magic_mousemagic_mouse_touch_durationleftmost_mouse_touch_xleftmost_mouse_touch_yrightmost_mouse_touch_xrightmost_mouse_touch_yleftmost_rightmost_mouse_touch_distance_percentmouse_position_xmouse_position_ymouse_pos_percent_xmouse_pos_percent_ywindow_titlebar_hovereddist_x_active_win_top_leftdist_y_active_win_top_leftdist_x_active_win_top_rightdist_y_active_win_top_rightdist_x_active_win_bottom_leftdist_y_active_win_bottom_leftdist_x_active_win_bottom_rightdist_y_active_win_bottom_rightpercent_x_active_win_btm_leftpercent_y_active_win_btm_leftpercent_x_hovered_win_btm_leftpercent_y_hovered_win_btm_leftmouse_screen_xmouse_screen_ymouse_screen_widthmouse_screen_heightfocused_screen_xfocused_screen_yfocused_screen_widthfocused_screen_heightfocused_window_xfocused_window_yfocused_window_widthfocused_window_heighthovered_floating_menu_identifiervisible_floating_menu_identifiershovered_app_bundle_identifierhovered_app_namefullscreen_activeactive_screen_resolutionsmissioncontrol_activecurrently_blocking_keyboardpower_sourcebattery_levelactive_spacedarkmode_activeignore_builtin_trackpad_active(state of the macOS "Ignore built-in trackpad when mouse or wireless trackpad is present" accessibility setting)current_minutecurrent_hourcurrent_daycurrent_weekday (SUN = 1)
And these are available via the Conditional Activation Groups:
bundleIdentifierprocessNamerunningProcessesappNameappExecutablePathwindowNameconnectedWifiNameactiveWebsiteURLactiveTouchBarGroupfocusedElementRolefocusedElementSubrolecustomVariable1customVariable2customVariable3customVariable4customVariable5activeScreenResolutionscurrentlyPressedStreamDeckButtonIdentifiershovered_floating_menu_identifiervisible_floating_menu_identifiershovered_app_bundle_identifier(bundle id of the app whose window is under the mouse cursor)hovered_app_name(name of that app)BTTCurrentlyPlayingAppBTTCurrentlyPlayingmouseBehindNotchcurrentlyBlockingKeyboard
Hovered app
hovered_app_bundle_identifier / hovered_app_name report the application owning the
frontmost ordinary window under the mouse cursor. They are empty while the cursor is
over the desktop or the menu bar, and while no condition uses them.
Hovering an icon in the Dock reports that app, even when it isn't running — the same
app hovered_dock_app_bundleidentifier would report. Dock items that aren't apps
(folders, the Trash, minimized windows) report their name with an empty bundle id.
Observation only runs while at least one activated conditional activation group actually references one of these two variables — if you don't use them, nothing is sampled and there is no cost. In trigger conditions they are resolved on demand, so using them there starts no background observation either.
Because a hovered app changes far more often than the active app does, the value only updates once the cursor has settled on one app for a moment. These hidden defaults can be used to tune the behavior:
| Default | Meaning |
|---|---|
BTTHoveredAppCheckInterval | How often the cursor position is sampled (default 0.1 seconds) |
BTTHoveredAppDwellTime | How long one app must stay hovered before the value changes (default 0.15 seconds). Total update latency is roughly this plus one check interval — lower both for a snappier response, raise BTTHoveredAppDwellTime if fast cursor sweeps trigger groups you didn't intend |
BTTHoveredAppMaxWindowLayer | Highest window layer considered (default 0 = ordinary app windows only). Set to 20 to also match the Dock as a whole, 24 to also match the menu bar |
BTTHoveredAppIncludeDockItems | Set to 0 to stop resolving individual Dock icons (default on) |
BTTHoveredAppExcludeOwnWindows | Set to 1 so BetterTouchTool's own windows never count as the hovered app |
BTTAlwaysObserveHoveredApp | Set to 1 to keep the variables updated even when no condition uses them (for scripts) |
Some other variables that might be available depending on the context:
mouse_screen_xmouse_screen_ymouse_screen_widthmouse_screen_heightfocused_screen_xfocused_screen_yfocused_screen_widthfocused_screen_heightpinned_window_idsBTTActiveWindowTitleBTTActiveWindowNumbercurrentlyBlockingKeyboardBTTLastTerminalCommandResultBTTMagicMouseTouchpadModeActiveBTTSiriRemoteMouseModeActiveBTTFinderContextMenuTriggeredUUIDBTTFinderContextMenuTargetPathBTTFinderContextMenuSelectedItemPathsCurrentKeyboardInputSource