"Apple Event Timed Out" and "Scripting compon

Two questions:

  1. What does “apple event timed out” mean?

  2. When I include the following in a script to check if an application (AppName) is running:

on isRunning(AppName)
tell application “Finder”
set runningApps to (name of every process whose file type is “APPL”) as list
end tell
set numberOfApps to count of items of runningApps
display dialog numberOfApps
repeat with thisName in runningApps
display dialog thisName
end repeat
return false
end isRunning

I receive the following error:

“Scripting Component Error”
but it seems to compile fine.
And when I choose “Edit” in the error window the variable “thisName” is
highlighted within the statement “display dialog thisName” so I guess it has
problems with this variable.

Hmmm…thanks for any suggestions.

Kelsey

  1. “apple event timed out” means exactly that an apple event has timed out. When you send an apple event, it remains waiting for an answer for… :?: 1 minute? I can remember the exact time… Then, if there was not an answer to the question, the event “dies”.
    You can avoid the timeout (eg, you duplicate a 7GB folder in the Finder and it will take 2 months) using this statement:
with timeout of 500000 seconds
	--> do whatever long operation
end timeout

If you are not interested in waiting for a response, you can also stat this (only works when you are targeting a process):

ignoring application responses
	--> do whatever, you won't wait for a response
end ignoring
  1. Your code works fine here; and you can shorten it:
on isRunning(AppName)
	tell application "Finder" to name of processes contains AppName
end isRunning

jj,

What does your code return?

on isRunning(AppName)
tell application “Finder” to name of processes contains AppName
end isRunning

for my code the routine “isRunning” is part of a conditional in the main
or

If (isRunning (AppName) is false) then
blah blah blah
endif

Does your code return a string?

Thanks,

KF

It returns a simple boolean (true/false), so you can use it as follow:

if isRunning("Safari") then --> returned true
     display dialog "Danger: Safari is running!"
else --> returned false
     display dialog "Danger: Safari is not running!"
end if

jj,

These errors with the script disappeared when I executed it from the administrator account so I guess you need certain priviledges to access process information using this script?
Thanks for your help, the scrpt you sent appears to work.

KF

Extra information : an osax will never timeout exept if you include it in a ‘tell … end tell’ block, so keep your calls to osax out of any ‘tell…end tell’ blocks.

Greetings, all!

I am running an applescript to run other applescripts that give commands to Acrobat. Frustrated with the two-minute timeout rule, I inserted a timeout of 3600, but it still timed out.

with timeout of 3600 seconds
set FAA to alias (("..:Desktop:current revs:scripts:" as text) & "FAA.scpt")
set FBB to alias ((...:Desktop:current revs:scripts:" as text) & "FBB.scpt")
set theScriptFiles to [FAA, FBB]

	repeat with scriptFile in theScriptFiles
		run script (contents of scriptFile)
	end repeat
end timeout

I also tried the following:

try
	with timeout of 10 seconds
		repeat with scriptFile in theScriptFiles
			run script (contents of scriptFile)
		end repeat
	end timeout
end try

And this:

ignoring application responses
	repeat with scriptFile in theScriptFiles
		run script (contents of scriptFile)
	end repeat
end ignoring

The script that’s running uses Acrobat, which needs up to 10 minutes or more to save the final document. This two minute timeout business is pretty unhelpful.

Is there no way to tell applescript to wait while ANOTHER applescript does its job? The other applescript does the task fine by itself. It never times out. This problem appeared when I used two of them together.

Any ideas?

run script is part of the standard scripting addition osax. They are free of timeout events but the script they run do have timeouts. That means that you have to set the timeout in the script you’re trying to run, not a timeout on the run script command itself.

DJ beat me to it, but see also the developer info:
“A with timeout statement applies only to commands sent to application objects, not to commands sent to the application that is running the script.” ” https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_control_statements.html

Hi, I read that statement this morning,

“A with timeout statement applies only to commands sent to application objects, not to commands sent to the application that is running the script.”

But what does that mean? That THIS script is fine without a timeout?

set FAA to alias (("..:Desktop:current revs:scripts:" as text) & "FAA.scpt")
set FBB to alias ((...:Desktop:current revs:scripts:" as text) & "FBB.scpt")
set theScriptFiles to [FAA, FBB]

   repeat with scriptFile in theScriptFiles
       run script (contents of scriptFile)
   end repeat

…but that THE OTHER script its running is the one that needs the timeout? That is to say, the FAA and FBB scripts listed above needs the the with timeout of 3600 seconds command added to it?

Please advise.

Now that I think about it, I wonder if Acrobat is impeding on the process and preventing me from blocking the 2-minute timeout? I read somewhere else on this forum that compile pdf applescripts worked only up to 1,000 pages. I dismissed that warning since the posts were old and anyway, the script I found makes a 1,770 page book. But the compiler script is useless by itself, since Acrobat has the same function.

Perhaps I need to give the task of running my book compiler scripts to automator instead of applescript?

Hi. Nobody can advise you on code that isn’t provided, but I can’t think of a good reason for an inexperienced scripter to use your current approach; your task can more easily and understandably be written in sections or as handlers (subroutines) in the body of one script than of several.

Hi Marc Antony, thanks for writing.

I looked up subroutines elsewhere in the forum and discovered I was placing the timeouts within the subroutine instead of outside it. NOW it works! Thanks for mentioning the magic word!