Hello!
I am VERY new to applescripting and my first one won’t work:
tell application "System Preferences"
reveal anchor "DateTime" of pane id ¬
"com.apple.preference.datetime"
end tell
tell application "System Events"
tell process "System Preferences"
click checkbox "Set date & time automatically:" of group 1 of tab group 1 of window 1
tell UI element 5 of group 1 of tab group 1 of window 1
--this part doesn't set the date at all
set value to "2006-11-5 12:00:00 -0600"
end tell
end tell
--and because that earlier part didn't change anything, this doesn't work either
click button "Save" of group 1 of tab group 1 of window 1
end tell
Any help is greatly appreciated.
Thanks in advance!
Model: 1.42 Mac Mini (OCd to 1.5)
AppleScript: 2.0
Browser: Safari 523.10.6
Operating System: Mac OS X (10.5)
Welcome.
Try something like this:
do shell script "/bin/date -f '%Y-%m-%e %T' " & quoted form of "2006-11-5 16:18:05" with administrator privileges
Thank You!
That solved about 6 hours of mild frustration
I eventually got it to this:
display dialog "Set the time:" buttons {"Cancel", "Current", "Old"} default button 1
copy the result as list to {buttonpressed}
if the buttonpressed is "Old" then
try
do shell script "/bin/date -f '%Y-%m-%e %T' " & quoted form of "2006-3-31 12:00:00" with administrator privileges
delay 1
end try
else if the buttonpressed is "Current" then
try
tell application "System Preferences"
reveal anchor "DateTime" of pane id ¬
"com.apple.preference.datetime"
end tell
tell application "System Events"
tell process "System Preferences"
click checkbox "Set date & time automatically:" of group 1 of tab group 1 of window 1
click checkbox "Set date & time automatically:" of group 1 of tab group 1 of window 1
end tell
end tell
end try
end if
I should be able to apply this to a lot of new applescripts later on…
Again, Thank You!