Copy link to clipboard
Copied
I have osx 10.7 and indesign CS5, and I use a script I run several times a day. Would it be possible to have my mac start this script automatically - maybe every 15 minute?
Hi,
Kevin showed you the syntax to use AppleScript, sthg. like:
--open in Scripteditor, save as Programm with option stay open!
on idle
tell application "Adobe InDesign CS5"
--usage: do script pathToyourScript scriptinglanguage
do script "Mac Red-Grafik 3:Users:claessen:Desktop:FunnyScript.jsx" language javascript --applescript language
end tell
return 900
end idle
Shareware for doing sheduled tasks: hazel
OSX BuiltIn LaunchD
Hope it'll help
Hans-Gerd Claßen
Copy link to clipboard
Copied
hi
yes it's possible, and there a varied ways to do it, heres a few ideas.
you could use CRON, which is daemon process running in the back ground all the time
or you could use a simple on idle applescript something like the below.
(* -- UNCOMMENT TO USE
on run
------------------------------------------------------------------------
-- INITIALIZATION OF APPS ,MOUNT SERVERS ETC HERE
------------------------------------------------------------------------
end run
*)
on idle
------------------------------------------
-- YOUR SCRIPT HERE
------------------------------------------
return 900 -- 15 MINUTES
end idle
(*
Save as a stay open application, script will run every 15 minutes
*)
Copy link to clipboard
Copied
Kevin: How do I define my script? I'm a novice on apple script, so this is as far as I got: on run application "Adobe InDesign CS5" end run on idle return 9 -- 15 MINUTES end idl I manage to start the app 😄 The name of my script is myscript
Copy link to clipboard
Copied
You can also add them to iCal events to fire them off or you could use Adobe's Bridge schedule tasks… What is the script… AppleScript or ESTK?
Copy link to clipboard
Copied
Maybe i was not clear, but I'm talking about running an Indesign-script every 15 minute, not just an Apple script.
So question: What is the syntax for running Indesign script from an Apple script?
Copy link to clipboard
Copied
Hi,
Kevin showed you the syntax to use AppleScript, sthg. like:
--open in Scripteditor, save as Programm with option stay open!
on idle
tell application "Adobe InDesign CS5"
--usage: do script pathToyourScript scriptinglanguage
do script "Mac Red-Grafik 3:Users:claessen:Desktop:FunnyScript.jsx" language javascript --applescript language
end tell
return 900
end idle
Shareware for doing sheduled tasks: hazel
OSX BuiltIn LaunchD
Hope it'll help
Hans-Gerd Claßen
Copy link to clipboard
Copied
With my adress to my script, I get this error:
Expected end of line, but found "script"
on idle
tell application "Adobe InDesign CS5"
--usage: do script pathToyourScript scriptinglanguage
do script "Macintosh HD:Applications:Adobe InDesign CS5:Scripts:Scripts Panel:plasserinnhold.jsx" language javascript --applescript language
end tell
return 900
end idle
Copy link to clipboard
Copied
Hi,
you shouldn't get Errors while compiling, but may be when running the *.jsx ...
Let's try from the start again:
property pathToScript : ""
on idle
if pathToScript is "" then set pathToScript to (choose file with prompt "Please choose the Javascriptfile") as text
tell application "Adobe InDesign CS5.5"
do script pathToScript language javascript
end tell
return 900
end idle
Please paste the above code to a new window of AppleScript-Editor.app. Then save as APP with option STAY OPEN (IMPORTANT!!!) to any place on your harddisk.
double click the newly created app. You should be requested for the *.jsx-file once. Please choose it. Done! The targetScript should be launched every 900 seconds from now on.
Hans-Gerd Claßen
If running into errors: Please try to explain exactly ...
Copy link to clipboard
Copied
thtas a good idea Hans
Copy link to clipboard
Copied
Now it is running - thx a LOT!
Message was edited by: espenmoe
Copy link to clipboard
Copied
One last question: How to make the script click the "OK"-button at the end?
Copy link to clipboard
Copied
my pick is that the jsx file has a dialog set to be thrown when the process has finished running, so id open the jsx file look near the bottom of the code and comment out or remove the area appropriate to the dialog, it may look like this
alert("Done");
Copy link to clipboard
Copied
Found it, and killed it
// alert("Done");
But this can not be clicked out by my little apple-script?
Copy link to clipboard
Copied
Hi,
you may tell system events to do this, but as it's possible to edit the source it's bit inconvinient.
Guess this should work and could be added before invoking your targetscript:
tell application "System Events"
tell process "Adobe InDesign CS5.5"
if accessibility description of window 1 is "alert" then
try
click button "OK" of window 1
end try
end if
end tell
end tell
Hans-Gerd Claßen
Copy link to clipboard
Copied
Hans: adding it at the begining now!
("Time out for Apple event" "Edit")
But I just discovered the Apple-script is timing out after a short while. Can I set the timeout for Applescript?
Or is it just my indesign-script hitting a bumper and stalling?
Or is the problem that Indesign is still running the script when Apple script is trying to start the indesignscript?
Copy link to clipboard
Copied
thought that might happen, maybe add to the end of the jsx script a piece of code to kill the dialog after say 5 seconds, I dont no how to do that, but i think it will work.
Copy link to clipboard
Copied
JavaScript windows have no giving up after… n seconds
Copy link to clipboard
Copied
Hello Kevin,
you may imitate the AS Alert-giving up in JS:
try{
//...
}catch (e){displayDialog(e)}
function displayDialog(message){
var infoWindow = new Window("palette");
infoWindow.add("statictext", undefined, "Houston, we've got a problem: " + message);
infoWindow.show();
$.sleep(2000);
infoWindow.close();
}
Hans-Gerd Claßen
Copy link to clipboard
Copied
Hi espenmoe,
gave it a custom-timeout, added the systemeventspart, and throwing errors when occur but giving up to not stopp the process ...
property pathToScript : ""
on idle
if pathToScript is "" then set pathToScript to (choose file with prompt "Please choose the Javascriptfile") as text
my clickAlertButton()
with timeout of 850 seconds
try
tell application "Adobe InDesign CS5.5" --<<<<<<<YOUR APP!!!
do script pathToScript language javascript
end tell
on error e
activate
display dialog e giving up after 3
end try
end timeout
return 30
end idle
on clickAlertButton()
tell application "System Events"
set namesOfCurrProcesses to name of every process
if namesOfCurrProcesses contains "Adobe InDesign CS5.5" then --<<<<<<<YOUR APP!!!
try
tell process "Adobe InDesign CS5.5" --<<<<<<<YOUR APP!!!
if accessibility description of window 1 is "alert" then
click button "OK" of window 1
end if
end tell
on error e
activate
display dialog e giving up after 3
end try
end if
end tell
end clickAlertButton
Give it a try
Hans-Gerd Claßen
Copy link to clipboard
Copied
Gives me an error:
Copy link to clipboard
Copied
Hi,
the ID-Part did not change, so it should work if worked before ... Shure that the target is a (the) Javascriptfile? (May be resafe the script and choose the file again ...)
It worked on my machine this morning and as I#M on a PC for the rest of the day ... I can only check it this evening. But again: seems as if 'pathToScript' doesn't target a *.jsx-file.
Hans-Gerd Claßen
Copy link to clipboard
Copied
OK - testing now! Jus to let me check that I got this: The timeout for for the apple script-erro, not the indesign-popup?
Copy link to clipboard
Copied
Hans!
I have been testing this script for many times, and every time it fails to close the indesign-document! The original script you wrote (the small one that did not kill Apple-script-popup) did manage to close indesign-documents.
Any idea why?
I have changed my Indesign script so it does not end the job with a jolly popup message, so that problem is solved.
The only problem left is the timeout message from Applescript.
property pathToScript : ""
on idle
if pathToScript is "" then set pathToScript to (choose file with prompt "Please choose the Javascriptfile") as text
my clickAlertButton()
with timeout of 60 seconds
try
tell application "Adobe InDesign CS5" --<<<<<<<YOUR APP!!!
do script pathToScript language javascript
end tell
on error e
activate
display dialog e giving up after 3
end try
end timeout
return 30
end idle
on clickAlertButton()
tell application "System Events"
set namesOfCurrProcesses to name of every process
if namesOfCurrProcesses contains "Adobe InDesign CS5.5" then --<<<<<<<YOUR APP!!!
try
tell process "Adobe InDesign CS5" --<<<<<<<YOUR APP!!!
if accessibility description of window 1 is "alert" then
click button "OK" of window 1
end if
end tell
on error e
activate
display dialog e giving up after 3
end try
end if
end tell
end clickAlertButton
Copy link to clipboard
Copied
Dear espenmoe ;-),
well, AS timeout is 120 seconds as standard. If your script takes longer so set it up (for example 1 hour, better more then less).
property pathToScript : ""
on idle
if pathToScript is "" then set pathToScript to (choose file with prompt "Please choose the Javascriptfile") as text
try
--set timeout up to 1 hour
with timeout of 3600 seconds
tell application "Adobe InDesign CS5.5" --<<<<<<<YOUR APP!!!
do script pathToScript language javascript
end tell
end timeout
on error e
activate
display dialog e giving up after 3
end try
--run script every 15 minutes after finishing the current turn
return 900
end idle
The script you posted above should never have clicked any button cause there still 5.5 as target:
if namesOfCurrProcesses contains "Adobe InDesign CS5.5" then --<<<<<<<YOUR APP!!!
To say anything about the problems using system events it would be necessary to post the executed script, as it works on my machine without any problem.
Good luck
Hans
Copy link to clipboard
Copied
Cool!