Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[CS3] [JS/AS] How to make a script to be run at a certain interval?

Valorous Hero ,
Oct 23, 2008 Oct 23, 2008
Dear all,

I wrote a script, which checks the active document for modified links and if such a link is found, it warns a user and offers to update it.
Now I want this script to run in the background that is to be triggered automatically, lets say, every minute, without user interaction. (An analog of Timer object in VB)
Im sure this can be done with Active Page Item Developer Toolkit. I cant check it now my demo period is over so I want somebody to confirm or disprove my assumption.

If so, should I use idle event? I couldnt find much information in the manual about it:

idle Sent when the application is idle, about once per second. This allows

you to implement background processing tasks.


Is it possible to change the interval from 1 sec to 1 minute directly or should I use the trick described in Locking InDesign during idle processing example?

Is there some alternative solution in AS?

Thanks in advance.
Kasyan
TOPICS
Scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 23, 2008 Oct 23, 2008
Hi Kasyan,

I wouldn't use the idle event--hitting the application once per second could be a real performance drain. Instead, I think you could use the "afterImport" event listener. I believe it's triggered when you update/replace links, as well as when you place a new file. I don't have time to test this right now, but that seems to me a promising approach.

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 23, 2008 Oct 23, 2008
Hi Olav,

Thank you for the quick response. The problem is that the user, who works in InDesign, wants to be notified whenever somebody else, on the network, modifies an image in Photoshop.

Kasyan
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 23, 2008 Oct 23, 2008
Hi Kasyan,

In that case, I think that a platform-specific script is what you need. Both AppleScript and VBScript have the ability to "watch" specific folders for changes. Those scripts could then use do script to run a script in InDesign. You could have a script in InDesign that creates folder actions on the parent folders of all links in the document.

Thanks,

Ole
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 23, 2008 Oct 23, 2008
You can use the idle handler, but as Ole says, it's no very efficient if you<br />call it all the time. Basically, you you need an idle handler, and the<br />script must be saved as stay-open. You control the time between calls by<br />adding a return statement at the end of the handler. For example:<br /><br />on idle<br />display dialog "Hello"<br />return 5 -- means call again in 5 seconds<br />end idle<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 23, 2008 Oct 23, 2008
Hi Kasyan,

Ole is probably right that the way to go would be a platform-specific
script.

You can do it using an idle event without it being too much of a
resource drain. You can do something like this (in CS3 using a
persistent engine):

if(yourUniqueNameIdleCounter == undefined){yourUniqueNameIdleCounter=0}
yourUniqueNameIdleCounter++;
if(yourUniqueNameIdleCounter>60){
yourUniqueNameIdleCounter=0;
do your check();
}

This would increment the number every second or so. Every time the
number hits 60 (about a minute -- give or take, depending on a lot of
factors) your check will be run. For every other idle event, the only
thing done would be incrementing the variable...

--
Harbs
http://www.in-tools.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 24, 2008 Oct 24, 2008
Thank you, guys! I'll give it a try when I come to work later today.

Kasyan
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Oct 26, 2008 Oct 26, 2008
If you are willing to use a plug-in you can check out IdleTask to be found at:
http://www.indesignscript.de

Ralf
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 26, 2008 Oct 26, 2008
Thank you, Ralf.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 01, 2009 Sep 01, 2009

Hi Kasyan

I have a problem very similar to yours. I wrote a script [JS][InD] which checks folders in search of any files and then process them. It mades PDF files and moves original files to a "processed" folder.

Now I want this script to run in the background by certain periods of time, without user interaction. Just like the "Watched folders" function of Acrobat Distiller.

Did you reached some solution for this?

Thank you for your help

Daniel

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 01, 2009 Sep 01, 2009

http://www.rorohiko.com/wordpress/indesign-downloads/active-page-item-developer/

Take a look at the fileChanged event.

Harbs

http://www.in-tools.com

Innovations in Automation

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 01, 2009 Sep 01, 2009

Thank you Harbs

I looked at

InDesignCS4_ScriptingGuide_JS.pdf

JavaScriptToolsGuide_CS4.pdf

indesigncs4_scriptingtutorial.pdf

and the links...

can't find nothing about the fileChanged event

?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 01, 2009 Sep 01, 2009
LATEST

It's an APID event. Take a look at the link I provided.

Harbs

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines