On Monday, July 8, 2013 4:42:56 AM UTC+2, Afshin wrote: > > In the mean time I'll be casually searching for ways to make this script > neater and hopefully connect to bluetooth devices via the command line just > like the blueutil utility. >
Check this one — you don't need blueutil but MouseTools<http://www.hamsoftengineering.com/codeSharing/MouseTools/MouseTools.html>or Cliclick <http://www.bluem.net/en/mac/cliclick/> to move (or move and click) and the bluetooth menubar item enabled. It saves the mouse position, does the clicking to turn bt on *and* connect OR turn bt off and puts your cursor back to where it was. *tell* *application* "System Events" *to* *tell* *process* "SystemUIServer" *set* {x, y} *to* *paragraphs* *of* (*do shell script* "MouseTools -location") *tell* (*first* *menu bar item* *of* *menu bar* 1 *whose* value *of* * attribute* "AXDescription" *is* "bluetooth") *click* *if* *exists* *menu item* "Bluetooth: Off" *of* *first* *menu* *then* *click* *menu item* "Turn Bluetooth On" *of* *first* *menu* *delay* 0.5 *click* *set* {m, n} *to* position *of* *menu item* "MyPhone" *of* *first* *menu* *do shell script* "MouseTools -x " & (m + 10) & " -y " & (n + 10) *delay* 0.1 *do shell script* "MouseTools -x " & (m - 10) & " -y " & (n + 10) *click* *menu item* "Connect to Network" *of* *first* *menu* *of* *menu item * "db" *of* *first* *menu* --do shell script "MouseTools -x " & (m - 10) & " -y " & (n + 10) & " -leftClick" *else* *click* *menu item* "Turn Bluetooth Off" *of* *first* *menu* *end* *if* *end* *tell* *do shell script* "MouseTools -x " & x & " -y " & y *end* *tell* Just change MyPhone to the name of your device. This is GUI scripting so tweak the *delay*s as needed. Clicking certain menus with MouseTools is somewhat unreliable for me — that's why I used *click* instead. I probably could have nested the *first* *menu* if I got clicking the parent element working. Maybe an AS guru chimes in. -- You received this message because you are subscribed to the Google Groups "Quicksilver" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/blacktree-quicksilver. For more options, visit https://groups.google.com/groups/opt_out.
