Sluggish Bluetooth Connection

Hi all, it’s good to be back in Keyboard Maestro Land. I stopped using KM seriously when I retired four years ago and have mostly been using previously created macros since then, but now I’ve run into a couple of problems I haven’t been able to solve on my own and so am looking for help. Having typed the title “Sluggish Bluetooth Connection” (of MacBook Pro to iPhone 5S, for Personal Hotspot) I got a message, “Your topic is similar to… How can I connect my MacBook to a bluetooth speaker using KM?” I followed the answer to https://stackoverflow.com/questions/17519804/connect-to-bluetooth-device-iphone-via-command-line-on-macosx and read everything there, but aside from being rusty on AppleScript and AS macros, I didn’t see exactly what I was looking for and so am taking the risk of maybe posting an already-answered question. If so I apologize, but here are my considerations.

In Andrew Burns’ reply of Apr 11 '14, I don’t understand “Just save it in a file and call osascript path/to/file.applescript”. I’m sorry about that, but like I said I’m rusty (and was never an expert scripter anyway). Furthermore, I would not want to receive a message like “Connect menu was not found, are you already connected?”. If the laptop was already connected to the phone, I would want the macro/script simply to do nothing, since being connected is exactly what I want. A main problem for me is that the connection is sluggish: it’s slow to kick in, and then sometimes when it’s finally kicked in – after I’ve clicked two or three times on iPhone > Connect to Network in the menubar Bluetooth menu (it never works after only one click) – it kicks back out and I have to click on Connect to Network again. So I don’t want the macro/script to suggest that I’m already connected when I am.

In Wolph’s script of Feb 19 '14, I confess to not understanding what exactly is being clicked on. It looks like it’s clicking on Connect to Network twice (though I’m unsure about that because it looks like it’s clicking on the name of the phone and not Connect to Network), which is good except sometimes it takes me three clicks, as I said before, and also sometimes the connection fails immediately after having been made and so I have to click again. So I suspect I need something that isn’t in Wolph’s script.

Regarding Arius Kahn’s comment of Jul 8 '15, I have never used Automator and it’s never seemed to me to be necessary. If it’s actually necessary to use Automator, however, I would be willing to do that.

lawsome’s revised script of Jan 8 ‘17 seems to share the same problem as Andrew Burns’ (and Dougal’s), that of throwing up a message if the phone is already connected. Or maybe that isn’t really a problem?

In any event I’ve been supposing that it’s somehow possible to program the connection so that the attempt to connect persists until the connection is made and is being maintained. I’ll presumably want to combine this step with the wifi menu connection to iPhone, which I can probably handle myself. A script rather than a manual menu selection might still be welcome on this, however.

Thanks,

Roy McCoy
writing from Taipei New City, Taiwan