• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie Stumbles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Stumbles


  • Subject: Re: Newbie Stumbles
  • From: Deivy Petrescu <email@hidden>
  • Date: Wed, 5 Nov 2003 14:43:34 -0500

On Nov 5, 2003, at 11:20 AM, Tuckerman Moss wrote:

I'm somewhat embarrassed to be asking what I know must be a trivial
scripting question.

Don't be, just send the 1000 pounds my way!

I would like to make a little script application
that turns on Internet Sharing in the Sharing preferences. I would
have thought the following would work (and does if the Sharing pane is
open). But it doesn't work from the Log In folder. What part of the
(simple) concept am I missing?

You are missing either trial and error or a simple if statement.
I wrote the following script which actually toggles on-off for FS.
One thing I came across smells like a bug. I'll point it out to you.
But first some comments on your script:


tell application "Finder"
activate
end tell

You do not need the finder. Why not activate System Events

tell application "System Events"
get properties
tell (click button "Sharing" of scroll area 1 of window "System
Preferences" of application process "System Preferences")
end tell
get properties
tell (click button "Start" of tab group 1 of window "Sharing" of
application process "System Preferences")
end tell
say "Sharing is turned on you old twit."
end tell

Properties of what?
Why did you need to get them if you never used them?

Here is my script:

tell application "System Preferences" to activate

tell application "System Events"
set frontmost of process "System Preferences" to true

tell process "System Preferences"
if name of window 1 is not "Sharing" then
click button 1 of tool bar 1 of window 1
delay 5
click button "Sharing" of scroll area 1 of window 1
end if
delay 2

tell row 1 of table 1 of scroll area 1 of tab group 1 in window 1
if the value of checkbox 1 is 1 then
set thetext to "Sharing is turned off, you old twit!"
else
set thetext to "Sharing is turned on, you old twit!"
end if
if value of text field 1 contains "File" then click checkbox 1 --Problem here
end tell

delay 2
say thetext
--click button 1 of window 1 --if you want to quit SE

end tell

end tell

____
The script should, I repeat, should work flawlessly every time, but it does not, I repeat, it does not!
The problem is in clicking the checkbox. For whatever reason, click checkbox 1 does not click on the right checkbox, even with the if statement, I repeat, even with the if statement.
If you have clicked on the second text field (Windows Sharing), for example, it is the corresponding checkbox (second in this example) that gets clicked. And I have no clue as to why.
I believe there is a bug in there.


--
Tuckerman Moss  The Old Vicarage  West Anstey  Devon  England
--

HTH


Regards

Deivy Petrescu
http://www.dicas.com/
_______________________________________________
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.

References: 
 >Newbie Stumbles (From: Tuckerman Moss <email@hidden>)

  • Prev by Date: Re: Reading file containing UTF-8
  • Next by Date: Re: multiple overlapping executions of a script
  • Previous by thread: Newbie Stumbles
  • Next by thread: Re: Newbie Stumbles
  • Index(es):
    • Date
    • Thread