I’d like to use the “Activate Specific Window” action (or some equivalent of it) but instead of targeting the window by title/app I want to use the window id. BTT exposes a global variable BTTActiveWindowNumber, and in the documentation (Action JSON Definitions | BetterTouchTool Documentation) of the above mentioned action it states that the BTTGenericActionConfig can take in the “Window title or identifier” but I can’t make it work with the identifier. Tried passing it both as a number or string without success. Is there any other way to accomplish this task? I would like to avoid potential ambiguity if an app happens to have to identically named windows (such as two Finder windows in the same folder)
I don't have an answer for your question, but I'm just curious how would you know the window number to which you would like to switch? How would you know that number 680 is the Finder window you need to open instead of 681 for example?
while there is no documented action that allows to do this, you can use a internal BTT function via BTT's scripting via the "Run Real JavaScript" action:
async function activateWin() {
let windowNumber = 12345;
BTTActions.activateWindowWithNumberRaiseAppID(windowNumber, true,-1)
}
you can store it in a global variable at prior point (reading from BTTActiveWindowNumber)
also these IDs are global to the system (not specific to BTT) so other apps also know them. In my use case in particular I want to bridge a gap in aerospace functionality when focusing certain windows, and I can do it by having aerospace remotely invoke a BTT action providing the id (obtained internally from aerospace) as a parameter
Amazing, it works! thank you Andreas!!!
Even though it’s not documented, is there any source or other alternative material where I could find this and other internal functions? obviously at my own risk and knowing that any update could potentially remove or break internal functions.
Not really, you can access the BTTAction properties via javascript, but many of them are only useful within BTT
BTTActions Prototype
activateBTT()
activatePresetWithDictionaryString()
activateWindowWithNumberRaiseAppID()
addNewSpaceToMissionControl()
altClick()
applicationExpose()
applicationSwitcher()
applicationSwitcherSpecial()
applicationSwitcherSpecialDisableWarning()
axSelectedTextWithClipboardFallback()
backgroundTerminalCommand()
beginGesture()
bl
brightnessDown()
brightnessDownOnExternal()
brightnessForBuiltInDisplay()
brightnessForKeyboard()
brightnessUp()
brightnessUpOnExternal()
bringToFrontWindowUnderCursor()
bttToggleOnOff()
cancelChatGPTRequest()
changeFormattingOfClipboardText()
changeFormattingOfSelectedText()
changeSliderValueBy()
characterForKey()
chatGPTWithIdentifierSystemPromptUserRequestInputTextMaxHistoryModelApiKeyCustomURLOptionsWithJSCallback()
chatGPTWithIdentifierSystemPromptUserRequestInputTextMaxHistoryModelOptionsWithJSCallback()
checkAndActivateDockItem()
checkMenuItemStatus()
checkMenuItemStatusForPID()
clickDialogButtonWithTitle()
clickMenuItem()
clickMenuItemForPID()
clickTime()
clicked()
clipboardDump
clipboardLock
clipboardString
closeAllNotifications()
closeWindowUnderCursor()
cmdClick()
cmdClickDouble()
cmdShiftClick()
colorAtPosition()
constructor: BTTActionsConstructor {prototype: BTTActionsPrototype}
copyLaunchedApplicationsInFrontToBackOrder()
copyTextStyle()
createNewFile()
ctrlClick()
currentClipboardPasteString
currentClipboardPasteStrings
currentInputVolume()
currentOutputVolume()
currentShortcutsMenu
customResizeAndMove()
customTypePaste()
dataProvided
disableAppleGestureWithNames()
disableBTTButKeepTouchBarOn()
disableCMD()
disableCtrl()
disableFN()
disableFlags()
disableOpt()
disableShift()
disableSiriRemoteTouchpadMode()
doubleClick()
eject()
elcapitanSplitscreenLeft()
elcapitanSplitscreenRight()
emptyTrash()
emptyTrashWithoutAsking()
enableAccessibility()
enableAirplayMirroring()
enableAppleGestureWithNames()
enableCMD()
enableCtrl()
enableFN()
enableOpt()
enableShift()
enableSiriRemoteTouchpadMode()
endGesture()
endGestureImmediately()
endScroll()
esc()
executeAfterLaunchActions()
expose()
exposeAndSort()
findMenuItemForPID()
findPidForApp()
findPositionOfImageOnScreenImageData()
freeMenubar()
freeMenubarBlink()
getAllStandardWindows()
getCurrentFocusMode()
getHoveredLinks()
getListOfShortcuts()
getTrackpadSettings()
goBackScript
goForwardScript
goToSpace1()
goToSpace2()
goToSpace3()
goToSpace4()
goToSpace5()
goToSpace6()
goToSpace7()
goToSpace8()
goToSpace9()
goToSpace10()
goToSpace11()
goToSpace12()
goToSpace13()
goToSpace14()
goToSpace15()
goToSpace16()
hideAllButActive()
hideAllScript
hideAllWindows()
hideCursor()
installProcessPriorityHelper()
isTrueToneEnabled()
keyCodeForCharacter()
keyboardIlluminationDown()
keyboardIlluminationUp()
lastBlockAction
lastCopiedRTFData
lastPastedText
lastPerformedAction
launchSiri()
launchpad()
leapApplicationSwitcher()
leapBackwardApplicationSwitcher()
leftclick()
leftclickAtLocation()
leftclickAtLocationDontMoveToPovidedLocation()
leftclickRemote()
leftclickRemoteOnlyDown()
leftclickRemoteOnlyUp()
listOfAppleShortcuts()
loadAndCompareSymbolicHotkeys()
loadShortcutIcons()
lockScreen()
logout()
lookup()
makeFullScreen()
maximizeWindow()
maximizeWindowLeft()
maximizeWindowRight()
maximizeWindowToNextMonitor()
menuWithItems()
middleclick()
minimizeWindowUnderCursor()
missionControlAndShowDesktopPreview()
moveLeftThird()
moveLeftTwoThird()
moveMiddleThird()
moveMouseALittle()
moveMouseALittleWithMouseDown()
moveMouseRelativeXAndY()
moveMouseToPoint()
moveMouseToPositionRelativeToActiveWindow()
moveMouseToPositionRelativeToActiveWindowDrag()
moveMouseWithAccelerationAndWithDeltaXDeltaY()
moveMouseWithDescriptionDict()
moveRightThird()
moveRightTwoThird()
moveToPreviousMonitor()
moveWindow()
moveWindowBottomHalf()
moveWindowBottomLeft()
moveWindowBottomRight()
moveWindowCenter()
moveWindowCenterNext()
moveWindowLeft()
moveWindowRight()
moveWindowToLeftSpace()
moveWindowToRightSpace()
moveWindowToSpace()
moveWindowTopHalf()
moveWindowTopLeft()
moveWindowTopRight()
mute()
next()
notificationCenter()
ocrWithOptions()
oneFingerSearch()
openBTTPrefsWindow()
openFileWithApplication()
openFinderSelectionWithApplication()
openFinderSelectionWithApplicationFolderOnly()
openPreferences()
openSpecificBTTSettings()
openURL()
pasteString()
pasteTextStyle()
performCustomClickClickTypeBitMaskClickAmount()
performCustomClickClickTypeBitMaskClickAmountIncludePressedModifiers()
performIOKitShortcutWithBinding()
performShortcut()
play()
postDistributedNotification()
postDistributedNotificationObjUserInfo()
postKeyCodeEventIsKeyDownIsRepeat()
postKeyCodeXTimes()
postModifierKeyCodeEventWithFlags()
postNormalKeyCodeDown()
postScrollWheelEventWithOffset()
pressKey()
previous()
previousChatGPTRequests
quitBTT()
resetLeftClick()
resetModifierState()
resetPinch()
resetState()
resetStateNow()
restartBTT()
restoreAppWithPID()
restoreLayout()
restoreLayoutLaunchIfNeeded()
restoreSavedMousePosition()
restoreWindowSizeAndPosition()
rightMouseDown()
rightMouseUp()
rightclick()
rotateCCW()
rotateCW()
rotateLeft()
rotateRight()
runAppleScript()
runJAX()
runloopDelay()
runloopDelayExtraFine()
saveCurrentMousePosition()
screencaptureConfigWC
screenshotDateFormat()
screenshotRegionToClipboard()
selectedText()
selectionToClipBoard()
selectionToClipBoardIgnoreChangeCountInputFormat()
sendAppleShortcut()
sendIOHIDShortcutCompleteKeyCode()
sendIOHIDShortcutCompleteKeyCodeIncludeCurrentModifiers()
sendKeyboardShortcutToAppBringToFrontSwitchBack()
setBrightnessTo()
setCmdState()
setCmdStateOldWithFlags()
setCmdStateOldWithFlagsAndKeyCode()
setCmdStateWithFlags()
setCmdStateWithFlagsAndKeyCode()
setControlState()
setControlStateOldWithFlags()
setControlStateOldWithFlagsAndKeyCode()
setControlStateWithFlags()
setControlStateWithFlagsAndKeyCode()
setCurrentMouseDisplayBrightnessTo()
setCursorSize()
setCustomIconForFilePath()
setFunctionState()
setFunctionStateOldWithFlags()
setFunctionStateWithFlags()
setInputVolume()
setKeyboardBrightness()
setMoving()
setMovingWithToggle()
setOptState()
setOptStateOldWithFlags()
setOptStateOldWithFlagsAndKeyCode()
setOptStateWithFlags()
setOptStateWithFlagsAndKeyCode()
setOutputVolume()
setPowerModeFromSourceWithCompletion()
setResizing()
setResizingWithToggle()
setShiftState()
setShiftStateOldWithFlags()
setShiftStateOldWithFlagsAndKeyCode()
setShiftStateWithFlags()
setShiftStateWithFlagsAndKeyCode()
shiftClick()
showBluetoothMIDIAutoConnectWithName()
showCharacterPalette()
showClipboard()
showColorPicker()
showContextMenuForCurrentSelection()
showContextMenuWithItems()
showControlCenter()
showCursor()
showDashboard()
showDesktop()
showFinder()
showFloatingWebViewWithConfig()
showFloatingWebViewWithDictionary()
showFocusedUIElementViewer()
showHideAppWithBundleIdentifierAndTrigger()
showHoveredUIElementViewer()
showMenubarInContextMenu()
showMenubarInContextMenuWithSubItemPath()
showScreenshotWindow()
showShortcutsInContextMenu()
showSpaces()
showVisibleWindowsViewer()
siriRemotepostScrollWheelEventWithOffset()
sleep()
sleepDisplay()
smallBrightnessDown()
smallBrightnessDownOnExternal()
smallBrightnessUp()
smallBrightnessUpOnExternal()
smallSoundDown()
smallSoundUp()
smartZoom()
smoothMoveMouse()
snowLeopardmoveMouseRelativeXAndY()
snowLeopardmoveMouseWithAccelerationAndWithDeltaXDeltaY()
soundDown()
soundUp()
startAutomatorWorkflowInput()
startDrag()
startDragAtLocation()
startDragWithDoubleClick()
startRecordingMouseGesture()
startRecordingMouseGestureImmediatelyHighlight()
startScreensaver()
stopDrag()
stopRecordingMouseGesture()
swipeDown()
swipeLeft()
swipeRight()
swipeUp()
switchSpaceLeft()
switchSpaceLeftWithoutAnimation()
switchSpaceRight()
switchSpaceRightWithoutAnimation()
switchToLoginScreen()
tabletMoveToXAndY()
takeScreenshotAndEdit()
takeScreenshotAndEditInMacOS()
terminalCommand()
terminateImmediately()
toggleCapsLock()
toggleCursorSize()
toggleCursorSizeBig()
toggleDarkMode()
toggleDisplayMirroring()
toggleDoNotDisturb()
toggleHidden()
toggleMouseCursorHidden()
toggleMoving()
toggleNightShift()
togglePresetWithJSON()
toggleResizing()
toggleTouchpadMode()
toggleTouchpadModeSiriRemote()
toggleTrueTone()
triggerContextMenuAction()
triggerContextMenuActionUseCurrentSelection()
triggerSnapAreaWithGesture()
typeString()
typeStringWithDelayDontWaitForUpping()
uaZoomIn()
uaZoomOut()
uninstallProcessPriorityHelper()
unlockScreen()
uploadClipboardToImgur()
userDefaultsChanged()
wakeDisplay()
wiSwiWin
windowMovingA
windowResizingA
windowSwitcher()
windowSwitcherActivateHoveredItem()
windowSwitcherDidClose()
windowSwitcherTrigger()
windowToNextMonitor()
zoomIn()
zoomOut()
zoomWindowUnderCursor()