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

Applescript: How do I attach a script to an event??

Participant ,
Nov 16, 2015 Nov 16, 2015

I have an applescript that creates PDF and uploads it to a specific destination. (see below)

I want to invoke this script every time the user "saves" the doc.

I am a novice when it comes InDesign applescripting...I don't know if its possible to attach a script to the "save" function??

I am guessing I need to incorporate an event listener?? again i am guessing. perhaps there is a better way? attach the script to key combo Command-s??

the objective is to give the user the option to send a PDF every time they save a document.

Here is the script thus far:

......................

set _ExportPDF to (display dialog "Send Proof?" with icon caution buttons {"Cancel", "PDF"} default button 2)

tell application "Adobe InDesign CS6"

  if button returned of _ExportPDF is "PDF" then

  set myFolder to "PDFProofs:"

  set _dest to myFolder as Unicode text

  set screenSettings to PDF export preset "[High Quality Print]"

  set page range of PDF export preferences to all pages

  set docName to name of document 1

  if docName ends with ".indd" then

  set docName to text 1 thru -6 of docName

  end if

  tell application "Adobe InDesign CS6"

  export document 1 format PDF type to (_dest & docName & ".pdf") using screenSettings without options

  if modified of active document is true then

  tell active document to save

  close document 1

  end if

  (*

           tell PDF export preferences

               set view PDF to true

           end tell

           *)

  end tell

  end if

end tell

......................

TOPICS
Scripting
1.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

correct answers 1 Correct answer

Participant , Nov 18, 2015 Nov 18, 2015

i figured it out.

an event listener needs to be placed in the InDesign startup scripts folder

that script listens for the Save events... specifically: afterSave, afterSaveAs, afterSaveACopy

(it could listen for other events as well but i am only interested in the after save functions)

i wanted to trigger my PDF upload script after any of those events...so the script was very simple

tell application "Adobe InDesign CS6"

  set myEventNames to {"afterSave", "afterSaveAs", "afterSaveACopy"}

  repeat with m

...
Translate
Participant ,
Nov 17, 2015 Nov 17, 2015

ok i see now where i can save the script as a "start-up" script (i.e. applications>adobe indesign>scripts>startup scripts) but how do i make the script run on "save" the doc??

anyone?? bueller? anyone??

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 ,
Nov 17, 2015 Nov 17, 2015

The easiest way is to set keyboard shortcut Command-S to your script.

I also set various save/package scripts to common keyboard shortcuts.

gr

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
Participant ,
Nov 18, 2015 Nov 18, 2015
LATEST

i figured it out.

an event listener needs to be placed in the InDesign startup scripts folder

that script listens for the Save events... specifically: afterSave, afterSaveAs, afterSaveACopy

(it could listen for other events as well but i am only interested in the after save functions)

i wanted to trigger my PDF upload script after any of those events...so the script was very simple

tell application "Adobe InDesign CS6"

  set myEventNames to {"afterSave", "afterSaveAs", "afterSaveACopy"}

  repeat with myEventName in myEventNames

  make event listener with properties {event type:myEventName, handler:"Macintosh HD:Applications:Adobe InDesign CS6:Scripts:Scripts Panel:Samples:AppleScript:PDFUpload.scpt"}

  end repeat

end tell

handler = the path to my PDFUpload applescript

done and done

thank you everyone for your help!! R

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