Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Workaround for Leopard' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Workaround for Leopard
Authored by: KuroRai on Apr 30, '08 10:08:59PM

you are actually correct about the menu being renamed. A still trial and error has revealed to me that the menu is now called "Bluetooth" no "menu extra" and a capital (may or may not make a difference, the capital).

Nonetheless there are some other bugs that still don't get it to work, It's already 1:07 AM, so I'll try tomorrow to get it working.

Thanks for the start of the script by the way! Total script n00b here. XD.



[ Reply to This | # ]
Workaround for Leopard
Authored by: KuroRai on Apr 30, '08 10:13:01PM

-- Before you use this script, launch /Applications/AppleScript/AppleScript Utility.app and check "Enable GUI Scripting."
-- The Bluetooth menu item must be turned on in the Bluetooth system preferences pane.

-- Check the current bluetooth status and turn it on if necessary.
tell application "System Events" to tell the front menu bar of process "SystemUIServer"
set menu_extras to value of attribute "AXDescription" of menu bar items
repeat with x from 1 to the length of menu_extras
if item x of menu_extras is "Bluetooth" then exit repeat
end repeat
tell menu bar item x
click
tell 2nd menu item of front menu
if name ends with "Off" then
-- If option allows for turning off; then turn off by clicking
set last_bluetooth_setting to "off"
click
end if
end tell
end tell
end tell

That's what I have. I don't need it to turn on, but rather off, so my script is different. Please note that the change is that the button says the action (if it's on it says "turn off" and vice versa) as such the code needs to be changed, modify and add to your needs! didn't think it would be this fast. XD.



[ Reply to This | # ]
Workaround for Leopard
Authored by: KuroRai on Apr 30, '08 10:19:01PM

Yet a final comment. Thanks to OS X: Leopard's new "record" ability in Automator, you can record yourself clicking on something, stop recording, and find out what the menu is called right then and there! Found that out now. XD.



[ Reply to This | # ]
Workaround for Leopard
Authored by: ccjensen on Nov 26, '08 12:59:31PM
figured I would throw in my solution which was based upon the original post.
on run argv
if length of argv is not 1 then
return
end if

set switch to item 1 of argv as string

tell application "System Events" to tell the front menu bar of process "SystemUIServer"
set menu_extras to value of attribute "AXDescription" of menu bar items
repeat with x from 1 to the length of menu_extras
if item x of menu_extras is "bluetooth" then exit repeat
end repeat
tell menu bar item x
click
tell 2nd menu item of front menu
if name ends with switch then
set clicked to true
click
else
set clicked to false
end if
end tell
if not clicked then
click
end if
end tell
end tell
end run
This code takes a single argument: the desired action (ie On or Off)

It would be run from the terminal:
osascript /path/to/script/name_of_script_file.scpt On
osascript /path/to/script/name_of_script_file.scpt Off


[ Reply to This | # ]