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
-hans- wrote:
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
And that is probably the reason!
Copy link to clipboard
Copied
I have been testing this, and so far it looks liek we ahve a winner! I altered it to look like below:
It will not time out until 150 seconds
It wil run every 300 second
Applescript pop up lasts for 5 secons
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 150 seconds
try
tell application "Adobe InDesign CS5" --<<<<<<<YOUR APP!!!
Ā«event K2 doscĀ» pathToScript given Ā«class doLgĀ»:Ā«constant ScLgJSLgĀ»
end tell
on error e
activate
display dialog e giving up after 3
end try
end timeout
return 300
end idle
on clickAlertButton()
tell application "System Events"
set namesOfCurrProcesses to name of every process
if namesOfCurrProcesses contains "Adobe InDesign CS5" 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 5
end try
end if
end tell
end clickAlertButton
Copy link to clipboard
Copied
Good morning,
allready sunrise in norway? Have to say that I can not understand / read one of the errormessages you've posted! Cryptical language š
Just a few points to clarify:
1. set time out to specific time means that this is just the maximum time given to a process' duration. If finished earlier everything will go on from this moment and will not wait until timeout duration is over!
2. If the second errormessage appears it means that system events failed on clicking the button of alert window. UI-Scripting is not very robust and should be avoided if possible.
3. Be aware that the 'clickAlertButton'-function is just a workaround. Could be used if there no possibility to modify the executed script
3.b. If you want a Javascript alert and you want it to close after a specific time then try to use the handler I posted in response to Kevin. Just run it with 'displayDialog('anyStringYouLike')'
Have a good day
Hans-Gerd ClaĆen
Copy link to clipboard
Copied
Thx a lot!
At this time of year in Oslo, we hardly have daylight š
Copy link to clipboard
Copied
espenmoe wrote:
One last question: How to make the script click the "OK"-button at the end?
as an alternative, instead of using alert('done'), you could build your own dialog, show it, and dismiss it after x seconds.
Copy link to clipboard
Copied
the code works fine for me here under CS5.5 & CS6, maybe double check that you have saved it as a stay open application.
on idle
tell application "Adobe InDesign CS6" --works fine in CS5.5 & CS6
do script "Macintosh HD:Applications:Adobe InDesign CS6:Scripts:Scripts Panel:Samples:JavaScript:CropMarks.jsx" language javascript
end tell
return 5 --changed for testing
end idle
Copy link to clipboard
Copied
Depends on what the script does. You really don't want it firing off when you are working in an app and the script targets that app.
Copy link to clipboard
Copied
Larry: I'm using a dedicatet Mac.