FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

auto sync

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Salling Software Forums Forum Index -> MobileSync (retired)
View previous topic :: View next topic  
Author Message
tom.evans
Newbie


Joined: 28 Apr 2006
Posts: 9

PostPosted: Fri Apr 28, 2006 6:16 pm    Post subject: auto sync Reply with quote

is it possible to set up schedule for Mobile sync to run automatically everyday? with applescript or something? has anyone done this?
Back to top
View user's profile Send private message
Mytzlscript
Newbie


Joined: 29 Mar 2006
Posts: 9
Location: St. Paul, MN

PostPosted: Wed May 03, 2006 9:01 pm    Post subject: Reply with quote

Instead of a set schedule, I thought it would be nice if MobileSync activated every time my phone entered proximity. So, if I add a new appointment when I am gone - it is syncronized when I return.

I tested the following, and it worked great.

However, I'm not entirely sure on how to tell when MobileSync is done so the app is left open. If anyone has a suggestion for how to tell when the sync has completed it could also quit MobileSync. That would round this script out nicely.

To use, create a new Phone Event Script, and paste this code in. Don't forget to "Apply Now" like I frequently do and end up scratching my head...

Enjoy.
[quote]
[color=blue][b]property[/b][/color] [color=green]lastSyncStamp[/color] : [color=blue]missing value[/color] --[color=olive]the last time we had a sync[/color]
[color=blue][b]property[/b][/color] [color=green]intMaxSecs[/color] : 1800 --[color=olive]( half an hour )[/color]
[color=blue][b]property[/b][/color] [color=green]maxChecks[/color] : 100 --[color=olive]maximum number of times to check if MobileSync is running - alter as you wish[/color]

[color=blue][b]using terms from[/b][/color] [color=blue]application[/color] "SEC Helper"
     
     [color=blue][b]on[/b][/color] [color=blue]process entering proximity[/color] [color=green]a_terminal[/color]
          --[color=olive]- Remember, this is just an example…[/color]
          [color=blue][b]tell[/b][/color] [color=blue]application[/color] "SEC Helper"
               [color=blue][b]if[/b][/color] [color=green]lastSyncStamp[/color] = [color=blue]missing value[/color] [color=blue][b]then[/b][/color]
                    [color=blue][b]set[/b][/color] [color=green]lastSyncStamp[/color] [color=blue][b]to[/b][/color] [color=blue]current date[/color]
               [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
               
               [color=blue][b]if[/b][/color] [color=green]lastSyncStamp[/color] [color=blue][b]is not[/b][/color] [color=blue][b]equal to[/b][/color] [color=blue]missing value[/color] [color=blue][b]then[/b][/color]
                    [color=blue][b]if[/b][/color] ((([color=blue]current date[/color]) - [color=green]lastSyncStamp[/color]) > [color=green]intMaxSecs[/color]) [color=blue][b]then[/b][/color]
                         --[color=olive] sync[/color]
                         --[color=olive]optionally show a screen message[/color]
                         [color=blue]show screen[/color] [color=blue]message[/color] "Synching calendar with " & ([color=blue]bluetooth name[/color] [color=blue][b]of[/b][/color] [color=green]a_terminal[/color]) [color=blue]duration[/color] 3
                         [color=blue][b]my[/b][/color] [color=green]syncNow[/color]()
                         [color=blue][b]set[/b][/color] [color=green]lastSyncStamp[/color] [color=blue][b]to[/b][/color] ([color=blue]current date[/color])
                    [color=blue][b]else[/b][/color] --[color=olive]the last sync was less than intMaxSecs ago[/color]
                         --[color=olive]don't sync[/color]
                         [color=blue][b]return[/b][/color]
                    [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
               [color=blue][b]else[/b][/color] --[color=olive]last stamp was not set - set it now[/color]
                    --[color=olive]sync[/color]
                    --[color=olive]optionally show a screen message[/color]
                    [color=blue]show screen[/color] [color=blue]message[/color] "Synching calendar with " & ([color=blue]bluetooth name[/color] [color=blue][b]of[/b][/color] [color=green]a_terminal[/color]) [color=blue]duration[/color] 3
                    [color=blue][b]my[/b][/color] [color=green]syncNow[/color]()
                    [color=blue][b]set[/b][/color] [color=green]lastSyncStamp[/color] [color=blue][b]to[/b][/color] ([color=blue]current date[/color])
               [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
          [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
     [color=blue][b]end[/b][/color] [color=blue]process entering proximity[/color]
     
     
     [color=blue][b]on[/b][/color] [color=blue]process terminal connected[/color] [color=green]a_terminal[/color]
          --[color=olive]- Remember, this is just an example…[/color]
          [color=blue][b]tell[/b][/color] [color=blue]application[/color] "SEC Helper"
               [color=blue]show screen[/color] [color=blue]message[/color] ([color=blue]bluetooth name[/color] [color=blue][b]of[/b][/color] [color=green]a_terminal[/color]) & " connected"
          [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
     [color=blue][b]end[/b][/color] [color=blue]process terminal connected[/color]
     
[color=blue][b]end[/b][/color] [color=blue][b]using terms from[/b][/color]

[color=blue][b]on[/b][/color] [color=green]syncNow[/color]()
     [color=blue][b]tell[/b][/color] [color=blue]application[/color] "Finder"
          [color=blue][b]if[/b][/color] ([color=blue][b]get[/b][/color] [color=blue][b]the[/b][/color] [color=blue]name[/color] [color=blue][b]of[/b][/color] [color=blue][b]every[/b][/color] [color=blue]process[/color]) [color=blue][b]does not[/b][/color] [color=blue][b]contain[/b][/color] "MobileSync" [color=blue][b]then[/b][/color]
               [color=blue][b]my[/b][/color] [color=green]activateMS[/color]()
          [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
     [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
     
     --[color=olive]wait until MobilSync is really active[/color]
     [color=blue][b]set[/b][/color] [color=green]blnProceed[/color] [color=blue][b]to[/b][/color] [color=blue][b]my[/b][/color] [color=green]verifyMSActive[/color]()
     
     [color=blue][b]if[/b][/color] [color=green]blnProceed[/color] [color=blue][b]then[/b][/color]
          [color=blue][b]tell[/b][/color] [color=blue]application[/color] "System Events"
               [color=blue][b]if[/b][/color] [color=blue]UI elements enabled[/color] [color=blue][b]then[/b][/color]
                    --[color=olive]set FrontApplication to (get name of every process whose frontmost is true) as string[/color]
                    [color=blue][b]tell[/b][/color] [color=blue]application[/color] "MobileSync"
                         [color=blue]activate[/color] --[color=olive]ensure it is frontmost again[/color]
                    [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
                    [color=blue]keystroke[/color] "t" [color=blue]using[/color] [color=blue]command down[/color] & [color=blue]shift down[/color] --[color=olive]simulate a keyboar shortcut for the sync[/color]
                    
               [color=blue][b]else[/b][/color]
                    [color=blue][b]tell[/b][/color] [color=blue]application[/color] "System Preferences"
                         [color=blue]activate[/color]
                         [color=blue][b]set[/b][/color] [color=blue]current pane[/color] [color=blue][b]to[/b][/color] [color=blue]pane[/color] "com.apple.preference.universalaccess"
                         [color=blue]display dialog[/color] "UI element scripting is not enabled. Check 'Enable access for assistive devices'"
                    [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
               [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
          [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
          (*
[color=olive]          perhaps someone could help with the[/color]
[color=olive]          logic that makes this wait until the[/color]
[color=olive]          sync has completed, then quit MS..          [/color]
[color=olive]          [/color]*)
     [color=blue][b]else[/b][/color] --[color=olive]we had a problem activating MobileSync[/color]
          [color=blue]display dialog[/color] "There was a problem launching MobileSync" --[color=olive]comment if you don't want a dialog here[/color]
     [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
     
[color=blue][b]end[/b][/color] [color=green]syncNow[/color]



[color=blue][b]on[/b][/color] [color=green]verifyMSActive[/color]()
     [color=blue][b]set[/b][/color] [color=green]intChecks[/color] [color=blue][b]to[/b][/color] 0
     [color=blue][b]set[/b][/color] [color=green]lisProc[/color] [color=blue][b]to[/b][/color] {}
     [color=blue][b]repeat[/b][/color] [color=blue][b]until[/b][/color] [color=green]lisProc[/color] [color=blue][b]contains[/b][/color] "MobileSync"
          [color=blue][b]tell[/b][/color] [color=blue]application[/color] "Finder" [color=blue][b]to[/b][/color] [color=blue][b]set[/b][/color] [color=green]lisProc[/color] [color=blue][b]to[/b][/color] [color=blue][b]the[/b][/color] [color=blue]name[/color] [color=blue][b]of[/b][/color] [color=blue][b]every[/b][/color] [color=blue]process[/color]
          [color=blue][b]set[/b][/color] [color=green]intChecks[/color] [color=blue][b]to[/b][/color] [color=green]intChecks[/color] + 1
          [color=blue][b]if[/b][/color] [color=green]intChecks[/color] > [color=green]maxChecks[/color] [color=blue][b]then[/b][/color]
               [color=blue][b]return[/b][/color] [color=blue]false[/color]
          [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
     [color=blue][b]end[/b][/color] [color=blue][b]repeat[/b][/color]
     [color=blue][b]return[/b][/color] [color=blue]true[/color] --[color=olive]if we make it here, we exited the repeat before maxChecks was hit[/color]
[color=blue][b]end[/b][/color] [color=green]verifyMSActive[/color]

[color=blue][b]on[/b][/color] [color=green]activateMS[/color]()
     [color=blue][b]tell[/b][/color] [color=blue]application[/color] "MobileSync"
          [color=blue]activate[/color]
     [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
[color=blue][b]end[/b][/color] [color=green]activateMS[/color]
[/quote]

-------------------------
[This script was automatically tagged for color coded syntax by [url=http://homepage.mac.com/jonn8/as/]Convert Script to Markup Code[/url]

[quote]After using this script for a bit I decided to update it. Some days, I frequently leave my desk and having this triggered every time I come back got a little annoying. So, I added time stamp and interval properties. If the time elapsed isn't long enough, the sync doesn't occur. Haven't tested whether or not the properties will be persistent between runs - I suspect it will.[/quote]
Back to top
View user's profile Send private message Visit poster's website AIM Address
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed May 03, 2006 10:51 pm    Post subject: Reply with quote

With respect to waiting until the sync is done, you don't want to do that. All scripts should complete their duty as quickly as possible.

What you could do is write a "watchdog script" (saving it as an application) that does the grunt work, and have the Salling Clicker script simply launch that application.

Still. MobileSync is lacking a method for checking if it's currently syncing, so the above is more of an academic statement, to deter you from attempting. ;-)

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tom.evans
Newbie


Joined: 28 Apr 2006
Posts: 9

PostPosted: Mon May 08, 2006 8:05 pm    Post subject: Reply with quote

thanks for your help - but i couldn't get the script to compile or run in script editor. is that how you get it to work? I couldn't find "create a new Phone Event Script" where is that function?

much appreciated!
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon May 08, 2006 11:23 pm    Post subject: Reply with quote

Mytzlscript: could you please (please please please) export your script as a cgz file and attach it to a post here to Mr. Evans doesn't have to roll his own?

It'd be much appreciated. Thanks!

Best.
--
Jonas

[quote="tom.evans"]thanks for your help - but i couldn't get the script to compile or run in script editor. is that how you get it to work? I couldn't find "create a new Phone Event Script" where is that function?

much appreciated![/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Mytzlscript
Newbie


Joined: 29 Mar 2006
Posts: 9
Location: St. Paul, MN

PostPosted: Thu May 18, 2006 6:32 am    Post subject: Reply with quote

[quote="salling"]Mytzlscript: could you please (please please please) export your script as a cgz file and attach it to a post here to Mr. Evans doesn't have to roll his own?[/quote]

Sorry for the delay.

Here it is. Not sure why he couldn't compile it though.



autosync.cgz
 Description:

Download
 Filename:  autosync.cgz
 Filesize:  8.47 KB
 Downloaded:  1607 Time(s)

Back to top
View user's profile Send private message Visit poster's website AIM Address
tom.evans
Newbie


Joined: 28 Apr 2006
Posts: 9

PostPosted: Tue May 23, 2006 7:43 pm    Post subject: Reply with quote

oh dear. i seem to be at the patio doors of my knowledge. thanks for your help but i can't get it to work :?

cheers anyway!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Salling Software Forums Forum Index -> MobileSync (retired) All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group