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

[JS] [CS3] Triggering a script

New Here ,
Mar 06, 2008 Mar 06, 2008
Hi all

I am looking to find the best way to trigger a script in InDesign. In the past i have used an applescript to monitor a folder, and when something appears in the folder a doScript will trigger the required script.
I am guessing there is a more efficient way just using JS. My intentions are ultimately to be using IDServer, linked to my companies web site. What I know I can do is create .csv files on the server from actions on the web site. This CSV file will hold the data I need to use in the ID environment.

I know this is very vague, but at the moment I have no solid plans, but want to make sure something can be done. I cannot use AS as the environment for the IDServer will be a Windows server.

Any pointers will be cool.

Cheers

Roy
TOPICS
Scripting
768
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 ,
Mar 07, 2008 Mar 07, 2008
Hi Roy,

I dont know if its possible to monitor a folder in JS, but I did it using timer object in Visual Basic. It is quite easy: you can set an interval property in milliseconds for the timer to trigger a function that does what you want.

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 ,
Mar 07, 2008 Mar 07, 2008
Kasyan Servetsky wrote:
> I dont know if its possible to monitor a folder in JS, but I did it using
timer object in Visual Basic. It is quite easy: you can set an interval property
in milliseconds for the timer to trigger a function that does what you want.

Similarly, you can use the $.sleep() function in a loop to get a similar result.

-X
--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.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
New Here ,
Aug 07, 2008 Aug 07, 2008
xbytor,

Can you give a little more explanation about creating a hotfolder with
the VB timer object?

Thanks in advance
Michel
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 ,
Aug 07, 2008 Aug 07, 2008
I don't know if you can do this in VBScript - but in VB6 IDE you need to add:
- Timer control to Form and set interval
- Folder control and set folder you want to monitor
in Timer's body function you need to check for new files in folder - if you move/delete files after processing - it's piece of cake 😉 just process first file from list until files count > 0 ;)
but if you leave files in watched folder - you need to store somewhere info about files already processed and check if file was processed before you do something with it

robin

--
www.adobescripts.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 ,
Aug 08, 2008 Aug 08, 2008
Hi Michel,

To provide an example, here is a simple program, which monitors a hot folder: every 5000 milliseconds (Interval property of the Timer) it counts files with pdf extension, makes simple calculations and shows statistics.

Kasyan
--------------------------------------------
Dim myPagesMax As Integer
Dim myPagesRekl As Integer
Dim myTop As Single
Dim myLeft As Single
Dim myFolderName As String

Private Sub Command1_Click()
Timer1.Enabled = True
Command1.Enabled = False
Command2.Enabled = True
Command3.Enabled = False
End Sub

Private Function CountFiles() As Integer
Set fsoRef = CreateObject("Scripting.FileSystemObject")
If Not fsoRef.FolderExists(myFolderName) Then
MsgBox ("Ïàïêà " & myFolderName & " íå ñóùåñòâóåò!"), vbCritical, "Îøèáêà"
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
CountFiles = 0
Exit Function
Unload Me
Else
Set folderRef = fsoRef.GetFolder(myFolderName)
i = 0
For Each f In folderRef.Files
If UCase(Right(f.Name, 4)) = ".PDF" Then
i = i + 1
End If
Next
CountFiles = i
End If
End Function

Private Sub Command2_Click()
Timer1.Enabled = False
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = True
Label1.Caption = ""
Label4.Caption = ""
Label6.Caption = ""
Label12.Caption = ""
ProgressBar1.Value = 0
End Sub

Private Sub Command3_Click()
myFolderName = InputBox("Ââåäèòå ïóòü ê ïàïêå äëÿ PDF ôàéëîâ òåêóùåãî íîìåðà", "Âûáîð ïàïêè", myFolderName)
If myFolderName = "" Then Exit Sub ' leaves sub if the variable i is null
Form1.Caption = CurrentIssue
End Sub

Private Sub Form_Load()
Command2.Enabled = False
myTop = GetSetting("PdfCounter", "Settings", "Top", 0)
myLeft = GetSetting("PdfCounter", "Settings", "Left", 0)
myPagesMax = GetSetting("PdfCounter", "Settings", "PagesMax", 160)
myPagesRekl = GetSetting("PdfCounter", "Settings", "PagesRekl", 50)
myFolderName = GetSetting("PdfCounter", "Settings", "FolderName", "K:\PS\801\Original")
Form1.Top = myTop
Form1.Left = myLeft
Text1.Text = myPagesMax
Text2.Text = myPagesRekl
mySplit = Split(myFolderName, "\")
myCurIssue = mySplit(2)
Form1.Caption = myCurIssue
End Sub

Private Sub Form_Unload(Cancel As Integer)
myTop = Form1.Top
myLeft = Form1.Left
SaveSetting "PdfCounter", "Settings", "Top", myTop
SaveSetting "PdfCounter", "Settings", "Left", myLeft
SaveSetting "PdfCounter", "Settings", "PagesMax", myPagesMax
SaveSetting "PdfCounter", "Settings", "PagesRekl", myPagesRekl
SaveSetting "PdfCounter", "Settings", "FolderName", myFolderName
End Sub

Private Sub Text1_Change()
myPagesMax = CInt(Val(Text1.Text))
End Sub

Private Sub Text2_Change()
myPagesRekl = CInt(Val(Text2.Text))
End Sub

Private Sub Timer1_Timer()

If Not CountFiles = 0 Then
Label1.Caption = CountFiles

myPagesRekl = CInt(Val(Text2.Text))
myPagesOur = myPagesMax - myPagesRekl
If Not myPagesOur = 0 Then
myOnePercent = 100 / myPagesOur
End If
myPagesCur = CountFiles
myPagesLeft = myPagesOur - myPagesCur

myCurPercent = CountFiles * myOnePercent
Label4.Caption = CInt(myCurPercent)
Label6.Caption = myPagesLeft
Label12.Caption = myPagesOur

If myCurPercent > 100 Then
myCurPercent = 100
End If

ProgressBar1.Visible = True
ProgressBar1.Min = 0
ProgressBar1.Max = 100
ProgressBar1.Value = myCurPercent
Else
Label1.Caption = 0
myPagesRekl = CInt(Val(Text2.Text))
myPagesOur = myPagesMax - myPagesRekl
If Not myPagesOur = 0 Then
myOnePercent = 100 / myPagesOur
End If
myPagesCur = 0
myPagesLeft = myPagesOur

myCurPercent = 0
Label4.Caption = 0
Label6.Caption = myPagesOur
Label12.Caption = myPagesOur

ProgressBar1.Visible = True
ProgressBar1.Min = 0
ProgressBar1.Max = 100
ProgressBar1.Value = myCurPercent

End If

End Sub

Private Function CurrentIssue() As String
If Not myFolderName = "" Then
If Val(Mid(myFolderName, 7, 3)) > 0 Then
CurrentIssue = "Òåêóùèé íîìåð: " & Val(Mid(myFolderName, 7, 3))
Else: CurrentIssue = "Òåêóùèé íîìåð íå âûáðàí."
End If
Else
CurrentIssue = "Òåêóùèé íîìåð íå âûáðàí."
End If
End Function
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
New Here ,
Aug 11, 2008 Aug 11, 2008
LATEST
Kasyan,

Thanks for your posting, but this is Visual Basic I think.
What I need is a vbscript solution.

I think I found something very simple like this that does the job:

Set objShell = CreateObject("Wscript.Shell")
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Do
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='C:\scripts'} Where " _
& "ResultClass = CIM_DataFile")

If colFileList.Count >= 1 Then
objShell.Run("C:\indesign\triggerdoc.indd")
Wscript.Sleep 15000
End If

Loop

Michel
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