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


Click here to return to the 'Toggle Bluetooth using Quicksilver and AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Toggle Bluetooth using Quicksilver and AppleScript
Authored by: chally on Mar 30, '07 12:00:03PM
I've been doing it this way:
on TurnOnBluetooth()
	-- 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 menuExtras to value of attribute "AXDescription" of menu bar items
		repeat with mExtras from 1 to the length of menuExtras
			if item mExtras of menuExtras is "bluetooth menu extra" then exit repeat
		end repeat
		tell menu bar item mExtras
			click
			tell 2nd menu item of front menu
				if name ends with "Off" then
					-- Current status is on; it says "turn bluetooth off"
					set prevBluetoothState to "on"
				else if name ends with "On" then
					-- Current status is off; it says "turn bluetooth on"
					set prevBluetoothState to "off"
					click
				end if
			end tell
			-- Unclick if it was on (do nothing but make the menu disappear)
			if prevBluetoothState is "on" then
				click
			end if
		end tell
	end tell
	return prevBluetoothState
end TurnOnBluetooth


[ Reply to This | # ]
Toggle Bluetooth using Quicksilver and AppleScript
Authored by: berdan on Mar 30, '07 12:29:58PM

If I'm not mistaken, that script requires the BT icon to still be in the menu bar, right?



[ Reply to This | # ]
Toggle Bluetooth using Quicksilver and AppleScript
Authored by: chally on Mar 30, '07 01:38:59PM
This script does, but you could use applescript to change it in the Bluetooth system preference. There are similar scripts posted, including one that turns the clock on and off. This is what I use for that, if it gives you an idea where to start:
-- This script tells the "Date & Time" preference pane to do the following:
--
-- if the clock is not showing in any way
-- or the clock is showing in the menu bar, then
--  Show the clock in the window the way I like it
-- else if the clock is showing in the window then
--  Show the clock in the menu bar the way I like it

tell application "System Preferences"
	activate
	set the current pane to pane "Date & Time"
	delay 1
end tell

tell application "System Events"
	tell process "System Preferences"
		-- define stuff
		set tabGroup to the first tab group of the window "Date & Time"
		set mainGroup to the first group of tabGroup
		set viewInRadioGroup to the first radio group of mainGroup
		set viewAsRadioGroup to the second radio group of mainGroup
		set showClockCheckbox to the checkbox 
			"Show the date and time" of mainGroup
		set showSecondsCheckbox to the checkbox 
			"Display the time with seconds" of mainGroup
		set showAmPmCheckbox to the checkbox 
			"Show AM/PM" of mainGroup
		set showDOWCheckbox to the checkbox 
			"Show the day of the week" of mainGroup
		set flashColonsCheckbox to the checkbox 
			"Flash the time separators" of mainGroup
		set twentyFourHourCheckbox to the checkbox 
			"Use a 24-hour clock" of mainGroup
		--do stuff
		if the value of showClockCheckbox is 0 then
			click showClockCheckbox
			set clockWasShowing to false
		else
			set clockWasShowing to true
		end if
		if the value of radio button "Window" of viewInRadioGroup is 0 
			or not clockWasShowing then
			click radio button "Clock" of tabGroup
			if the value of showClockCheckbox is 0 then 
				click showClockCheckbox
			click radio button "Window" of viewInRadioGroup
			click radio button "Analog" of viewAsRadioGroup
			if the value of showSecondsCheckbox is 0 then 
				click showSecondsCheckbox
		else
			click radio button "Clock" of tabGroup
			if the value of showClockCheckbox is 0 then 
				click showClockCheckbox
			click radio button "Menu Bar" of viewInRadioGroup
			click radio button "Digital" of viewAsRadioGroup
			if the value of showSecondsCheckbox is 1 then 
				click showSecondsCheckbox
			if the value of showAmPmCheckbox is 0 then 
				click showAmPmCheckbox
			if the value of showDOWCheckbox is 0 then 
				click showDOWCheckbox
			if the value of flashColonsCheckbox is 1 then 
				click flashColonsCheckbox
			if the value of twentyFourHourCheckbox is 1 then 
				click twentyFourHourCheckbox
		end if
		set visible to false
	end tell
end tell


[ Reply to This | # ]
Toggle Bluetooth using Quicksilver and AppleScript
Authored by: MagicMike on Mar 30, '07 01:14:07PM

Sorry, I cannot use the script part for Growl. Maybe it is because of German system. Can you save it as a script ?



[ Reply to This | # ]