1 Reply Latest reply on Nov 24, 2015 10:14 AM by WCBaxter

    apple script help needed

    davidn5918184

      In InDesign cc I have the "copy all link information" mapped to the keyboard shortcut shift+option+L. With a image selected, when the script is triggered it displays a dialogue box asking what needs to be done sets that to a variable, then runs the keystroke shift+option+L to copy the link info. Next it creates a text file on the desktop if its not there and appends it with the display box variable and pastes the link information. The problem is that it doesn't copy the link information correctly. Its as if its delayed. For example. If I copy something to the clipboard like the word "capture" and then select the image and run the script it will paste the word "capture" instead of the link information. But if I run it again on a different image it will paste the link information from the first time I ran the script. Its like its delayed by 1. Anyhow if anyone has any idea how to fix this strange behavior I would be grateful. Perhaps it would work with javascript, Im not sure.

       

      Thanks,

      ~David

       

      --dialog box

       

      display dialog "What do you need done" default answer "Remove Background"

      set theAnswer to (text returned of result)

       

      activate application "Adobe InDesign CC 2015"

       

      tell application "System Events" to keystroke "L" using {shift down, option down}

      end

       

      set this_story to "

       

      ------------------- " & theAnswer & " -------------------

       

      "

      set this_file to (((path to desktop folder) as string) & "ArtCorrections.txt")

      my write_to_file(this_story, this_file, false)

       

       

      on write_to_file(this_data, target_file, append_data)

        try

        set the target_file to the target_file as string

        set the open_target_file to open for access file target_file with write permission

        if append_data is true then set eof of the open_target_file to 0

        write this_data to the open_target_file starting at eof

        close access the open_target_file

        return true

        on error

        try

        close access file target_file

        end try

        return false

        end try

      end write_to_file

       

       

      set myVar to the clipboard

      my write_to_file(myVar, this_file, false)

       

      on write_clip_file(myVar, target_file, append_data)

        try

        set the target_file to the target_file as string

        set the open_target_file to open for access file target_file with write permission

        if append_data is true then set eof of the open_target_file to 0

        write myVar to the open_target_file starting at eof

        close access the open_target_file

        return true

        on error

        try

        close access file target_file

        end try

        return false

        end try

      end write_clip_file