• 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: kai <email@hidden>
  • Date: Fri, 07 Nov 2003 03:40:38 +0000

on Wed, 5 Nov 2003 14:43:34 -0500, Deivy Petrescu wrote:

> 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!

Knocking out scripts at discounted prices again, Deivy? ;-)

> 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.

I believe it should work more consistently if the row is selected first.
Here's a variation of your fine script which hopefully demonstrates this:

-------------------------------------------------------
(Any wrapped lines abutting the left edge of the window
should be reconnected to the end of the previous line)
-------------------------------------------------------

--=============================================

property p : {"on", "off", "Stop", "Start"}
tell application "System Preferences" to run
tell application "System Events" to tell process "System Preferences"'s
window 1
set n to name
if n is not "Sharing" then
if n is not "System Preferences" then
click tool bar 1's button "Show all"
repeat until n is "System Preferences"
set n to name
end repeat
end if
click scroll area 1's button "Sharing"
end if
tell tab group 1
repeat until exists radio button "Services"
end repeat
tell radio button "Services" to if value is 0 then
click
repeat while value is 0
end repeat
end if
tell scroll area 1's table 1's row 1
select
repeat until selected
end repeat
tell check box 1
tell value + 1
set o to p's item it
set s to p's item (it + 2)
end tell
click
end tell
end tell
repeat until exists button s
end repeat
end tell
end tell
say "Personal file sharing is now " & o

--=============================================

(I feel a slight irony here in that, after a considerable period of trying
to find ways to speed up my scripts, I'm now introducing all those delaying
tactics - to make sure clicks register in the right places!)

Looking back at Tuckerman's original message (Wed, 5 Nov 2003 16:20:14
+0000), I'm not sure whether he was trying to toggle the status of <System
Preferences/Sharing/Services/Personal File Sharing> or that of <System
Preferences/Sharing/Internet/Internet Sharing>. Just in case it was the
latter, here's a modified version which may do the trick:

--============================================

property p : {"Stop", "Start", "off", "on"}
property x : "Internet Sharing is not available"
tell application "System Preferences" to run
tell application "System Events" to tell process "System Preferences"'s
window 1
set n to name
if n is not "Sharing" then
if n is not "System Preferences" then
click tool bar 1's button "Show all"
repeat until n is "System Preferences"
set n to name
end repeat
end if
click scroll area 1's button "Sharing"
end if
tell tab group 1
repeat until exists radio button "Internet"
end repeat
tell radio button "Internet" to if value is 0 then
click
repeat while value is 0
end repeat
end if
if static text 3's name starts with x then return say x
tell button 1
tell name to repeat with i from 1 to 2
if it is p's item i then exit repeat
end repeat
set o to p's item (i + 2)
set s to p's item (3 - i)
click
end tell
repeat until exists button s
end repeat
end tell
end tell
say "Internet sharing is now " & o

--============================================

---
kai
_______________________________________________
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.

  • Follow-Ups:
    • Re: Newbie Stumbles
      • From: Deivy Petrescu <email@hidden>
  • Prev by Date: Re: Safari/Entourage question
  • Next by Date: applescript-users digest, Vol 3 #2136 - 17 msgs ( -Reply)
  • Previous by thread: Re: Newbie Stumbles
  • Next by thread: Re: Newbie Stumbles
  • Index(es):
    • Date
    • Thread