Schedule a "Sync Now" command for .Mac Sync preference panel?

Hi all,
I really need a script that will allow me to specify a “specific time of day” in which to initiate a “Sync Now” command for my .Mac Sync preference panel. Only problem is, I really don’t have a clue where to begin. I’ve messed around with applescripting a bit before in the past but with this one I think I’m a bit in over my head. Can this even be done? Anyone out there have a moment to lend a hand? Any advice would be truly and greatly appreciated.

Thanks, -Rob
a newbie

Hi Rob,

the sync menu in the menu bar is badly scriptable, because it couldn’t be reliably identified,
this does it with GUI scripting

tell application "System Preferences"
	activate
	reveal anchor "sync" of pane id "com.apple.preference.internet"
end tell

tell application "System Events"
	tell process "System Preferences"
		repeat until exists window ".Mac"
			delay 0.5
		end repeat
		tell button 1 of tab group 1 of window ".Mac"
			repeat until enabled
				delay 0.5
			end repeat
			perform action "AXPress"
		end tell
		delay 0.5
	end tell
end tell
quit application "System Preferences"

Works like a champ!!!
Thank you! Thank you! Thank you! Thank you!

Just for fun, here’s a SystemUIServer solution.
Enable “Show status in menu bar” in iSync’s preferences and drag the sync menu “leftmost”

tell application "System Events"
	tell process "SystemUIServer"
		repeat with mni in (get menu bar items of menu bar 1)
			if (value of attribute "AXDescription" of mni as string) is "" then
				perform action "AXPress" of mni
				set NameList to name of menu items of menu of mni
				if item 1 of item 1 of NameList begins with "Last .Mac" then
					perform action "AXPress" of menu item "Sync Now" of menu of mni
					exit repeat
				end if
			end if
		end repeat
	end tell
end tell

Hi StefanK,

Both works very well … ell … How can I modify your script to have executed when the computer as been idle for a specific amount of time ?

Thanks in advance.

Robert

Model: iMac G5 - 1.6 mgz
AppleScript: 2.1.1
Browser: Safari 525.18
Operating System: Mac OS X (10.4)