MACSCRPT Archives

March 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bill Cheeseman <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 11 Mar 2006 06:07:36 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (48 lines)
on 2006-03-11 12:05 AM, David Freels at [log in to unmask] wrote:

> I would really like to activate/deactivate Bluetooth on the Mac via
> Applescript (hopefully) via the computer keyboard and/or phone keypad.

Here's a script that turns Bluetooth off. I'll leave it to you to figure out
how to run it from the keyboard.

Notice that the property identifying the location of the Bluetooth menu in
the menu bar has to be set according to the particular arrangement of menu
extras on your machine. You'll have to set it again if you install or remove
menu extras.

-- Set the bluetoothIndex to suit your setup
-- (for best stability, count from the end)

property bluetoothIndex : -6

activate application "SystemUIServer"
tell application "System Events"
    tell process "SystemUIServer"
        set bluetoothItem to menu bar item bluetoothIndex of menu bar 1
        click bluetoothItem
        tell menu 1 of bluetoothItem
            if title of menu item 1 does not start with "BlueTooth" then
                beep
                display dialog "This is not the BlueTooth menu extra."
buttons {"OK"} default button "OK"
                return
            end if
            if title of menu item 2 ends with "Off" then
                click menu item 2
            end if
        end tell
    end tell
end tell


--

Bill Cheeseman - [log in to unmask]
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes

ATOM RSS1 RSS2