Jump to content

iPhone bluetooth tethering switch


Recommended Posts

I made a simple bluetooth-tethering-switch.

 

https://www.dropbox.com/s/ovuftqkjgt7gcbl/iPhone%20bluetooth%20tethering.alfredworkflow?dl=0

 

You have to change the code a little bit for your own localisation, and your own iPhone name.

 

the keywoard I used is just "iphone".

on alfred_script(q)
activate application "SystemUIServer"
tell application "System Events"
	tell process "SystemUIServer"
		set btMenu to (menu bar item 1 of menu bar 1 where description is "bluetooth")
		tell btMenu
			click
			tell (menu item "iPhone of XXXXXX" of menu 1)
				click
				if exists menu item "Connect to Network" of menu 1 then
					click menu item "Connect to Network" of menu 1
				else
					click menu item "Disconnect from Network" of menu 1
				end if
			end tell
		end tell
	end tell
end tell
end alfred_script
Link to comment
  • 2 weeks later...

Nice,

 

here a script for the hotspot connection. 

You have to change the device name and translate the strings.

on alfred_script(q)
	set device to "iPhone"
	set waiting to 10
	
	activate application "SystemUIServer"
	tell application "System Events"
		tell process "SystemUIServer"
			set btMenu to (menu bar item 1 of menu bar 1 where description contains "WLAN")
			tell btMenu
				click
				set thisTime to current date
				set dropDeadTime to thisTime + waiting
				repeat
					if exists menu item ("Verbindung zu „" & device & "“ trennen") of menu 1 then
						click menu item ("Verbindung zu „" & device & "“ trennen") of menu 1
						exit repeat
					else if exists menu item device of menu 1 then
						click menu item device of menu 1
						exit repeat
					else if (current date) > dropDeadTime then
						display alert "Hotspot „" & device & "“ nicht gefunden!"
						exit repeat
					end if
					delay 0.5
				end repeat
			end tell
		end tell
	end tell
end alfred_script
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...