Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript: Launch und hide application

In Tiger I was using this AppleScript snippet to launch and hide my Address Book:

tell application "Address Book" to activate
tell application "System Events" to set visible of process "iCal" to false

Now in Leopard, my Address Book is launched but the application window stays on screen. Inserting a "delay 1" between the two lines seems to do the trick -- but is there a more elegant solution?

Flipp.

Mac OS X (10.5)

Posted on Nov 11, 2007 1:09 AM

Reply
5 replies

Nov 11, 2007 4:22 AM in response to flipp

The most obvious problem is that you're telling iCal to hide, not Address Book...?

The second approach is to tell the application to launch, not activate

Launching an application causes it to open in the background. Activating it specifically tells it to come frontmost.

tell application "Address Book" to launch


I can't confirm off-hand whether it works in this particular case (it may open its window behind the current app, which is not the same as hiding), but it might work.

Nov 11, 2007 4:35 AM in response to Camelot

Except he said
flipp wrote:
In Tiger I was using this AppleScript snippet to launch and hide my Address Book:
... my Address Book is launched but the application window stays on screen


so I did code to hide the address book. Agreed his code said hide iCal but his request was Address Book. We better wait for him to clarify I guess. Anyway snippet I posted hides Address Book.

Nov 11, 2007 4:40 AM in response to flipp

The most obvious problem is that you're telling iCal to hide, not Address Book...?


Sorry, copy and paste error in my above post. Of course I want to open and hide Address Book.

FromOZ’s approach works great for me. With Camelot’s approach though lanching in background, Address Book’s main window is still present.

Thank you guys!

Message was edited by: flipp

AppleScript: Launch und hide application

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.