[Resolved] GU I scripting and Airport passwords
[Resolved] GU I scripting and Airport passwords
- Subject: [Resolved] GU I scripting and Airport passwords
- From: Donald Hall <email@hidden>
- Date: Fri, 17 Oct 2008 19:18:02 -0600
Title: [Resolved] GU I scripting and Airport
passwords
Thanks to everyone who replied.
It turns out that it was a timing problem. The script execution
blew past "if exists window 1" before the window could be
displayed. I added a delay (see *** essential statement *** in the
script). Now it behaves as expected.
Here is my whole test script:
--begin script -----------------------------------------
property netName : "2WIRE106" -- a local network that
need a password
property netPassword : "wxyz" -- a password for
it
set retMsg to ""
tell application "SystemUIServer" to activate
tell application "System Events"
-- find the Airport
menu
tell
application process "SystemUIServer"
tell menu bar 1
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
-- try to select your network
tell menu bar item the_menu
click
delay 1
try
click menu item netName of front menu
set retMsg to "Attempting to connect to " &
netName
on error errMsg number errNum -- your network is not
available
beep
set retMsg to retMsg & return & errMsg
end try
end tell
end tell
delay 1
-- *** essential statement ***
if exists window 1 then -- clicking on menu item
put a window on the screen
set retMsg to retMsg & space & "window
exists"
try
tell window 1
tell text field 1
set focused to true
end tell
end tell
keystroke netPassword
keystroke return
on error errMsg number errNum
set retMsg to retMsg & space & errMsg &
return & "Error Number=" & errNum
end try
end if
end tell
end tell
retMsg
-- end of script
--------------------------------------------------
Don
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
email@hidden
http://www.appsandmore.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden