As far as I know your best bet is wrapping an AppleScript. But AppleScript is magic to me so I leave it as an exercise for the questioner :-)
This might help a little: http://www.macosxhints.com/article.php?story=20060105082728937&lsrc=osxh
Koen Bok
2009-01-26 19:38:41