Re: control of "Desktop & Screen Saver"
Re: control of "Desktop & Screen Saver"
- Subject: Re: control of "Desktop & Screen Saver"
- From: Martin Orpen <email@hidden>
- Date: Fri, 02 Jul 2004 22:44:35 +0100
on 2/7/04 8:20 pm, Michael Cytrynowicz at email@hidden wrote:
>
tell application "System Preferences" to activate
>
-- may not need to activate application
>
>
tell application "System Events"
>
if (system attribute "sysv") < 4144 or UI elements enabled then
>
tell application process "System Preferences"
>
set the value of slider 1 of group 1 of tab group 1 of
>
window "Desktop & Screen Saver" to 120
>
end tell
>
else
>
tell application "System Preferences"
>
activate
>
set current pane to pane
>
"com.apple.preference.universalaccess"
>
beep
>
display dialog "GUI Scripting is not enabled." & return &
>
return & "Check \"Enable access for assistive devices\" in the Universal
>
Access preference pane (authentication is required), then run this
>
script again." with icon stop buttons {"OK"} default button "OK"
>
end tell
>
end if
>
end tell
>
>
>
Note:
>
>
left of scale has value (set the value of slider to): 1
>
3min -set to 60
>
15min -set to120
>
30min - set to 180
>
1h- set to 240
>
2h- set to 300
>
and "never" -set the value of slider to 361
Have you actually tested this script? By quitting System Preferences and
then opening it and checking the value?
On my Mac (1.25GHz powerbook on 10.3.4) *no* UI approach works.
The slider moves to where you specify, but as soon as you quit and reopen
the System Preferences the slider is back where it was before you ran the
script.
The only thing that makes the change permanent (on my Mac at least) is
editing the screensaver plist where you'll find that "off" is 0 and other
timings are in seconds:
set myValue to 0 -- 0 is off, or set time in seconds
set ssPlist to alias "Macintosh
HD:Users:martinorpen:Library:Preferences:ByHost:com.apple.screensaver.000a95
d04880.plist"
set myData to read ssPlist
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to "<key>idleTime</key>"
set p1 to (text item 1 of myData) as string
set AppleScript's text item delimiters to "<key>modulePath</key>"
set p2 to (text item 2 of myData) as string
set AppleScript's text item delimiters to oldTIDs
set newData to p1 & "<key>idleTime</key>" & return & "<integer>" &
myValue & "</integer>" & return & "<key>modulePath</key>" & p2
open for access ssPlist with write permission
write newData to ssPlist
close access ssPlist
Apologies for the inelegant hacking into the plist - feel free to suggest a
slicker method of changing the idleTime integer (I've got Late Night's XML
Tools.osax - but that would be cheating...).
I have no idea why this plist should be in the "ByHost" folder?
Regards
--
Martin Orpen
Idea Digital Imaging Ltd -- The Image Specialists
http://www.idea-digital.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.