Re: Scripting the Location
Re: Scripting the Location
- Subject: Re: Scripting the Location
- From: Craig Sutherland <email@hidden>
- Date: Fri, 29 Aug 2003 19:53:19 -0500
Begin forwarded message:
>
From: Craig Sutherland <email@hidden>
>
Date: Fri Aug 29, 2003 4:08:40 PM America/Chicago
>
To: Irwin Poche <email@hidden>
>
Subject: Re: Scripting the Location
>
>
Irwin,
>
>
You said to "assume that Sys Prefs is running with Network pane
>
already selected". The System Preferences window needs to be frontmost
>
for UI scripting to access it. You may have it open but if you are
>
testing the script, then the Script Editor's script window with your
>
script in it is receiving the script's actions. The reason the "click"
>
in your script errors is that you are sending the click event to an
>
object that is currently inaccessible to the script. So, add back the
>
first line of the script I sent to you which activates the System
>
Preferences window. I would not recommend making the assumption that
>
the Network pane has been previously selected and would suggest
>
keeping those 2 lines in, but I'm following your instructions.
>
>
Lines added have events in red.
>
>
tell application "System Preferences" to activate
>
tell application "System Events"
>
tell process "System Preferences"
>
tell pop up button 1 of window "Network" --Location popup
>
click -- you need to bring focus to the popup button, otherwise
>
menu 1 in the next statement has no meaning. Which menu 1?
>
tell menu 1
>
delay 1
>
click menu item "Office"
>
end tell --menu 1
>
end tell --pop up button 1
>
delay 2
>
click button "Apply Now" of window "Network" --you need to add this
>
to change your location selection
>
end tell --System Preferences
>
end tell --System Events
>
>
The error you received reflects that there was an event sent and there
>
was no object to receive it.
>
Craig
>
On Friday, August 29, 2003, at 12:23 PM, Irwin Poche wrote:
>
> Thanks Craig,
>
> What I now realize is that when the Finder is not active (had been
>
> previously Quit) the time it takes to activate has to be allowed for
>
> in a delay. That is why UI scripting the Location menu was
>
> problematic. My scripting the Apple>Location menu is reliable when a
>
> delay is added.
>
>
>
> But I prefer your method which I have been unable to completely
>
> understand. What I have not yet figured out from your script is how
>
> you tell the popup what to select. That does not appear to be doable
>
> explicitly in UI scripting, at least accord to what the UI Browser
>
> will generate. I've tried to whittle your script down to an
>
> illustrative example with no luck. This gets an
>
> NSReceiverEvaluationScriptError: 4 error on the "click" line
>
>
>
> -- Assume that Sys Pref is running with Network pane already selected
>
> tell application "System Events"
>
> tell process "System Preferences"
>
> tell pop up button 1 of window "Network"
>
> tell menu 1
>
> delay 1
>
> click menu item "Office"
>
> end tell
>
> end tell
>
> end tell
>
> end tell
>
> If you could distill your script down to a simple example, I would
>
> benefit. I'm guessing the rest of the list would too
>
>snip<
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.