+1  A: 

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