AppleScript名:Bluetoothに接続中のデバイス名を取得するv4 |
— Created 2017-07-24 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" 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 aRes to my filterRecListByLabel1(dArray, "mIONotification != 0") set dNames to (aRes’s mName) as list –> {"Piyomaru AirPods", "Takaaki Naganoya のマウス"} –リストに入れたレコードを、指定の属性ラベルの値で抽出 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 63 times, 1 visits today)