Set connectionNotifObj to IOBluetoothDevice's registerForConnectNotifications:me selector:"didConnectNotif:forDevice:" Property disconnectionNotifObj : missing value
![used runonly applescripts to avoid detection used runonly applescripts to avoid detection](https://i.stack.imgur.com/NamS8.jpg)
Property connectionNotifObj : missing value Property IOBluetoothDevice : class "IOBluetoothDevice" Copy the following script into Script Editor: use AppleScript version "2.4" - Yosemite 10.10 or later That way your app will sleep quietly in the background until it gets a notification that a device has been connected or disconnected. That would look like this: property lastStatus : trueīut set all that aside, because I think the best solution is to use the IOBluetoothDevice methods for registering observers. I'll add that it's far better to use an idle loop than an endless repeat loop. I suspect the problem is that you didn't add parentheses to some of your objC methods, specifically: nameOrAddress() and isConnected().
![used runonly applescripts to avoid detection used runonly applescripts to avoid detection](https://rollbar.com/wp-content/uploads/2021/07/types-of-java-memory-leaks-static-fields.png)
When it fails to detect the reconnect, it is still matching my keyboard name in the pairedDevices() list, just not as connected. If (device's nameOrAddress as string) contains substring thenĮdit: I have inserted lots of debug log messages in various places. Repeat with device in (current application's IOBluetoothDevice's pairedDevices() as list) If kbStatus is not equal to lastStatus thenĭo shell script "/usr/local/bin/ddcctl -d 1 -i 27"ĭo shell script "/usr/local/bin/ddcctl -d 1 -i 17" Set kbStatus to isDeviceConnected(myKeyboard) If it matters, I'm on Catalina (10.15.7) on a 2019 MacBook Pro. However once the keyboard has disconnected and later reconnects it never detects the connected state again.
![used runonly applescripts to avoid detection used runonly applescripts to avoid detection](https://www.42gears.com/wp-content/uploads/2015/03/surefox_motion_detection_on12.png)
When I export it as an App (with Run-only) and run it, it starts out detecting the correct state. When I run it in Script Editor it detects both connected and disconnected states as I switch back and forth. Based on I am using the IOBluetooth framework to detect disconnect/reconnect of my keyboard, such that switching it to a second host triggers changing the display input to that host as well.