InDesign CS5, when re-linking an image, you are taken to a Choose File dialog box. If you are faced with a large list of files, you type the first few characters of the needed file name to select the first matching name.
I’d really like to learn a way to do this: When presented with the Choose File dialog, send keystrokes of the existing link’s file name as a way of selecting the closest matching file name. I couldn’t figure a way to make it happen.
Any ideas or other help would be appreciated. (I’m not a very advanced Applescripter.) Thanks.
-Mike
--with an InDesign picture box already selected
set defaultFolder to (choose folder) -- (just for this example)
tell application "Adobe InDesign CS5"
tell document 1
try
set thePath to file path of item link of graphic 1 of selection
on error
set thePath to file path of item link of selection
end try
set olddelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set thename to last text item of (thePath as text)
set AppleScript's text item delimiters to ""
set characterCount to ((count of characters of thename) - 4)
set thename to (characters 1 thru characterCount) of thename as string
set AppleScript's text item delimiters to olddelim
relink item link of graphic 1 of selection to (choose file with prompt "Choose image " & thename of type {"TIFF", "JPEG", "EPS"} default location defaultFolder without invisibles)
--NEED THIS TO HAPPEN SOMEHOW WHILE THE PREVIOUS DIALOG BOX IS OPEN
tell application "System Events" to keystroke (every character of thename) --to select the first close match in list
end tell
end tell
Model: Mac Pro
Browser: Firefox 7.0.1
Operating System: Mac OS X (10.6)