Friday, October 31, 2014

#1 2008-09-17 11:41:21 am

evocomps
Member
From: Oklahoma
Registered: 2007-10-15
Posts: 119
Website

Wait until app finishes launching

I am trying to get my app to launch Adobe InDesign CS2, but wait for it to finish launching before it moves to the next step. But it gets ahead of itself and errors out.

Any idea how to halt my script until it finishes launching fully?

Thanks!

Offline

 

#2 2008-09-17 03:28:48 pm

Budgie
Member
From: New Zealand
Registered: 2005-02-22
Posts: 547

Re: Wait until app finishes launching

Hi

maybe a "delay 15" or "delay 20" seconds, this will depend on how quick it takes your Mac to launch ID.


Budgie


Budgie

No use, Joker! I knew you'd employ your sneezing powder, so I took an Anti-Allergy Pill! Instead of a SNEEZE, I've caught YOU, COLD! - Batman

Offline

 

#3 2008-09-17 03:58:04 pm

StefanK
Member
From: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 10624
Website

Re: Wait until app finishes launching

Budgie wrote:

Hi
maybe a "delay 15" or "delay 20" seconds, this will depend on how quick it takes your Mac to launch ID.

Hi,

"random" delays are always unreliable.
A better way is to wait for a certain UI element like a window or a palette


regards

Stefan

Offline

 

#4 2008-09-18 10:25:58 am

evocomps
Member
From: Oklahoma
Registered: 2007-10-15
Posts: 119
Website

Re: Wait until app finishes launching

StefanK, Good idea!

I'm looking thru InDesign's AS library but I'm not sure how I should go about scripting it.
I'm thinking that the best solution would be to use the Tools palette but I dont know how to see if that palette has been loaded.

Any suggestions?

Offline

 

#5 2008-09-18 01:59:30 pm

Adam Bell
Administrator
From: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4635

Re: Wait until app finishes launching

I don't have the App, but the way I normally do this is to write a brief script to look at the open windows after a fresh start of the app. Then knowing how to identify the window, in a repeat until loop with a short delay in it, I hang in the loop until that window appears then drop out of the loop and press on.


iMac & MBP both running OS X 10.9.1

Offline

 

#6 2008-09-19 09:45:57 am

SuperMacGuy
Member
From: Amish Country, Lancaster, PA
Registered: 2004-06-23
Posts: 416
Website

Re: Wait until app finishes launching

Maybe do a repeat with a try to get something from ID, like the version number or something.
Like

Applescript:

set myIDActive to false
repeat while myIDActive is false
try
delay 1
tell app "adobe indesign cs2"
get version --if doesn't work then try statement jumps out and myIDActive doesn't change
set myIDActive to true
end tell
end try
end repeat

It's kind of a dumb hack but maybe it'll work. ??
I'd recommend having ID get started at the very beginning of the script as soon as possible


Scripts for InDesign: http://chris.paveglio.com
ASOC & Cocoa, specializing in InDesign, Photoshop, Ai, FileMaker

Offline

 

#7 2008-09-25 10:51:55 am

evocomps
Member
From: Oklahoma
Registered: 2007-10-15
Posts: 119
Website

Re: Wait until app finishes launching

SuperMacGuy, that did it!

Thanks!

Offline

 

#8 2013-01-31 01:52:11 pm

Wookie
Member
From: Frankfurt/Main, Germany
Registered: 2013-01-29
Posts: 25

Re: Wait until app finishes launching

The problem with the script in post #6 is that it works only once, if at all. If the related app (in this example "InDesign") has been started and quit previously (read: is no longer running), the system still knows the version info, thus will return 'true' without even (re)launching the app. This is no good unless there is a command (which I don’t know of) to immediately drop the obtained version info:

Applescript:

set myIDActive to false
repeat while myIDActive is false
   try
       delay 1
       tell application "adobe indesign cs2"
           get version --if doesn't work then try statement jumps out and myIDActive doesn't change
           set myIDActive to true
           -- forget/drop the version info here
       end tell
   end try
end repeat

Last edited by Wookie (2013-01-31 01:58:38 pm)

Offline

 

#9 2013-01-31 08:04:53 pm

Shane Stanley
Member
From: Australia
Registered: 2002-12-07
Posts: 3730

Re: Wait until app finishes launching

So try some property like "active document".

But this begs the question: why do you need a delay?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#10 2013-03-21 08:38:21 am

Matt-Boy
Member
Registered: 2005-10-21
Posts: 480

Re: Wait until app finishes launching

I always do:
Tell Application "Indesign CS2" to launch
at the beginning of the script so it will start launching in the background. THen do all of your other startup steps. Then when you need Indesign, do:

Tell Application "Indesign CS2"
   Activate
   --rest of script


The activate will wait until the app is responding (i.e. it is finished launching).

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.033 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)