Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Sync with iSync in the background Apps
I've got a Sony Ericsson P910i, and wanted to be able to sync it with a key combo. Since I have Butler installed, and it can run AppleScripts, I thought I'd write a script to activate iSync and synchronize.
tell application "iSync"
	activate
	synchronize
end tell
I quickly realized that the iSync window popping up is annoying. So I sought out a way to hide iSync after activating it. It turns out that Butler was waiting for the sync to finish before releasing itself for other tasks, so I needed some way of telling iSync to synchronize and not wait for the result.

Here's my solution:
tell application "iSync"
	activate
	set visible of window 1 to false
	ignoring application responses
		synchronize
	end ignoring
end tell
This script activates iSync (whether it's running or not), 'kills' (hides) the front window, then tells it to sync, without waiting for a response. The only downside is that iSync is still the frontmost application, but it'd be quick to add a system events tell that does Command-Tab to switch back to the application you were in before you initiated the sync.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[7,254 views]  

Sync with iSync in the background | 8 comments | Create New Account
Click here to return to the 'Sync with iSync in the background' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Sync with iSync in the background
Authored by: foilpan on May 01, '06 08:36:04AM

can't you omit the activate to keep iSync open in the background? my applescript-foo is rusty, but i think you can skip the activate part and be all set.



[ Reply to This | # ]
Sync with iSync in the background
Authored by: inemo on May 01, '06 08:47:15AM

Telling it to activate means that it will be open, whether it is already or not.

I'm sure applescript is clever enough to figure out its not open and open it, but I learnt to use activate.


---
http://caius.name/

I'm just a mac baby :)

[ Reply to This | # ]

Sync with iSync in the background
Authored by: foilpan on May 01, '06 08:59:47AM

i just checked, and iSync, or any other app will do whatever you tell it without the "activate" command, so you should be able to avoid having it pop to the front just by omitting that line.



[ Reply to This | # ]
Sync with iSync in the background
Authored by: locklin on May 01, '06 09:11:03AM

iSync works fine without the "activate" command, I just checked.



[ Reply to This | # ]
Sync with iSync in the background
Authored by: barefootguru on May 01, '06 11:27:14AM

If iSync's in your Dock, you can also click-and-hold (or ctrl-click) to bring up its menu, which includes a Sync Devices option. It will then perform the sync in the background.



[ Reply to This | # ]
Improvement (with app hiding)
Authored by: PCheese on May 02, '06 01:41:21AM
Here's an improvement with hiding of the full application rather than just the sync window.

ignoring application responses
   tell application "iSync" to synchronize
end ignoring

tell application "System Events"
   set visible of (get first process whose name = "iSync") to false
end


[ Reply to This | # ]
Sync with iSync in the background
Authored by: loren_ryter on May 02, '06 06:58:11AM
yes, it's true -- activate is exactly the same as "bring window to front". if you tell any application to do something without activate, it will do it without bringing it to the front. if the application is not running, it will be launched. for added guarantee that it gets launched, you can optionally use the command "launch" instead of activate.

here's a script i use to sync, which i have scheduled with cron to run daily. I think it was originally posted here. it has the added advantage of quitting iSync when done if it wasn't open when launched.

tell application "System Events" to set iSyncRunning to 
	(number of items in (processes whose name is "iSync") is greater than 0)
tell application "iSync"
	synchronize
	repeat while (syncing is true)
		delay 5
	end repeat
	if iSyncRunning is not true then quit
end tell


[ Reply to This | # ]
just use the Sync Menu
Authored by: Hes Nikke on May 06, '06 01:18:05PM

in the .Mac system preference pane (of all places) under the Sync tab, you can turn on/off the iSync Menu. From that menu, you can start a sync at any time without launching iSync. as a bonus, you can see when it's done just by glancing at it, because it spins while it's synchronizing! :)


---
vacuums do not suck. they merely provide an absence that allows other objects to take the place of what becomes absent.



[ Reply to This | # ]