3年ぐらい前に書いてあった、Mac本体にペアリングして接続しているBluetoothのデバイス名を取得するAppleScriptです。
AppleScript名:Bluetoothに接続中のデバイス名を取得するv6.scptd |
— – Created by: Takaaki Naganoya – Created on: 2024/12/13 — – Copyright © 2024 Piyomaru Software, All Rights Reserved — use AppleScript version "2.8" use scripting additions use framework "Foundation" use framework "IOBluetooth" set pRes to getBluetoothPowerState() of me if pRes = false then return set dArray to current application’s IOBluetoothDevice’s pairedDevices() set dRes to my filterRecListByLabel1(dArray, "isConnected != 0") set dNameList to (dRes’s valueForKeyPath:"name") as list –> {"Logicool Z600", "Takaaki Naganoya のキーボード #1", "Takaaki Naganoya のマウス"} –> {"Logicool Z600", "AirPods Pro", "DUALSHOCK 4 Wireless Controller"} –リストに入れたレコードを、指定の属性ラベルの値で抽出 on filterRecListByLabel1(aRecList, aPredicate as string) set aArray to current application’s NSArray’s arrayWithArray:aRecList set aPredicate to current application’s NSPredicate’s predicateWithFormat:aPredicate set filteredArray to aArray’s filteredArrayUsingPredicate:aPredicate return filteredArray end filterRecListByLabel1 –Mac本体のBluetoothのパワー状態を取得 on getBluetoothPowerState() set aCon to current application’s IOBluetoothHostController’s alloc()’s init() set pRes to (aCon’s powerState()) as boolean end getBluetoothPowerState |
More from my site
(Visited 1 times, 1 visits today)