Skip to content

Instantly share code, notes, and snippets.

@miguel-negrao
Created October 29, 2012 23:22
Show Gist options
  • Save miguel-negrao/3977188 to your computer and use it in GitHub Desktop.
Save miguel-negrao/3977188 to your computer and use it in GitHub Desktop.
automate ad-hoc network creation
-- 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).
property NetworkName : "helloworld"
property NetworkPassword : "77777"
property CreateMenuName : "Criar rede…"
try
do shell script "/usr/sbin/scselect " & "osc-iphone"
delay 2
end try
tell application "System Events"
tell process "SystemUIServer"
tell menu bar 1
set menu_extras to value of attribute "AXDescription" of menu bar items
tell menu bar item ((count of menu_extras) - 4)
perform action "AXPress"
delay 0.2
perform action "AXPress" of menu item CreateMenuName of menu 1
end tell
end tell
repeat until exists window 1
delay 0.5
end repeat
tell window 1
keystroke NetworkName
tell pop up button 2
click
click menu item "WEP 40 bits" of menu 1
end tell
delay 0.5
keystroke NetworkPassword
keystroke tab
keystroke NetworkPassword
click button 1
end tell
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment