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


Click here to return to the 'Script to create an ad-hoc network to sync iPhone' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Script to create an ad-hoc network to sync iPhone
Authored by: KBoda on Oct 14, '09 03:40:56AM

Had to modify it, somehow:

keystroke tab
keystroke tab

was not required in my configuration.
Thanks for the script anyways.
Suggested feature: check whether Airport is on and turn it on if not ;)



[ Reply to This | # ]
Script to create an ad-hoc network to sync iPhone
Authored by: channui on Jan 29, '10 11:56:09AM
I have "Full Keyboard Access" turned on in System Preferences->Keyboard->Keyboard Shortcuts. That changes how many keystrokes are needed. Here's a version that shouldn't require that, and turns on the airport to boot.

-- This script creates an ad-hoc network with a password and changes your
-- network location.
--
-- This script mostly comes from StefanK:
--    http://bbs.macscripter.net/viewtopic.php?pid=99243

-- I just added network locations, passwords, bringup script, turning on the airport
-- and moved to directly addressing elements instead of using keystrokes.

-- Set NetworkName to be the name of the wireless network you wish
-- to create.  This will also attempt to set the network location
-- to that name as well.
-- Set NetworkPassword to be your wireless network password.  It MUST BE
-- 13 characters long (or 26 hex digits).
-- If Desired, Set BringupScript to be the name of a script to invoke
-- in a terminal after the network is created.

property NetworkName : "MyAdHocNetwork"
property NetworkPassword : "thirteenchars"
property BringupScript : ""

try
	do shell script "/usr/sbin/scselect " & NetworkName
end try

tell application "System Events"
	tell process "SystemUIServer"
		tell menu bar 1
			-- Find Airport Menu
			set menu_extras to value of attribute "AXDescription" of menu bar items
			repeat with the_menu from 1 to the count of menu_extras
				if item the_menu of menu_extras is "Airport Menu Extra" then exit repeat
			end repeat
			
			-- Turn on airport and start create network
			tell menu bar item the_menu
				perform action "AXPress"
				-- If Airport is off, turn it on
				if title of menu item 2 of menu 1 is "Turn Airport On" then
					perform action "AXPress" of menu item "Turn Airport On" of menu 1
					perform action "AXPress"
				end if
				perform action "AXPress" of menu item "Create Network…" of menu 1
			end tell
		end tell
		
		-- Enter information into Create Network Dialog
		tell window 1
			-- Require Password
			click checkbox 1
			
			-- Set to 128 bit WEP
			click pop up button 2
			click menu item 2 of menu 1 of pop up button 2
			
			-- Fill in information
			set value of text field 2 to NetworkPassword
			set value of text field 3 to NetworkPassword
			
			-- Set name last so OK button will be enabled (password field loses focus)
			set value of text field 1 to NetworkName
			
			-- Click OK
			click button 1
		end tell
	end tell
end tell

if BringupScript is not "" then
	tell application "Terminal"
		do script BringupScript
	end tell
end if


[ Reply to This | # ]