Skip to main content
Inspiring
November 17, 2008
Question

CS3 Scripting Guide AppleScript

  • November 17, 2008
  • 21 replies
  • 1552 views
Shane Stanley wrote:

> No, I have no financial link with Script Debugger, but I do think that
> trying to script without it is a bit like having one hand tied behind your
> back.
>
> We've talked of doing AppleScript Pro Sessions in Amsterdam, but alas
> nothing has come of it so far. Ray did do a session for Apple over there a
> couple of years back.

Okay, I'll download the Script Debugger demo at some point and give it
a run, but I'd better stick to one thing at a time at this point considering
how long it's taking me just to get through the ID Scripting Guide. I have,
however, managed to get beyond Chapter 2, and have renamed this topic
accordingly.

Thanks,
Roy
This topic has been closed for replies.

21 replies

Roy McCoyAuthor
Inspiring
November 18, 2008
P.S. I managed to get a find-and-replace script to work with the confirmation dialog I wanted, and to use the list method for find and change terms that you recommended before, but it's a little clunky since I couldn't find an elegant solution for the problem I ran into, that finds after the first one weren't displayed when they were on different pages. I wanted to simply get the page the selected find was on and go to that page, but that turned out to be easier said than done. The only thing that worked for me was sending cmd-y to System Events, which toggled me between edit and layout views. I tried inserting a second cmd-y to keep me in layout view, but that didn't work.

So here's what I wound up with that works, at least. Any suggesting for refining it so that the script goes from page to page in layout view would be very welcome, thanks.

tell application "Adobe InDesign CS3"
activate
set find text preferences to nothing
set change text preferences to nothing
set case sensitive of find change text options to true
set include footnotes of find change text options to true
set include hidden layers of find change text options to true
set include locked layers for find of find change text options to true
set include locked stories for find of find change text options to true
set include master pages of find change text options to true
set whole word of find change text options to false

set theToBeFounds to {"ch", "gh", "hh", "jh", "sh", "au", "eu", "Ch", "Gh", "Hh", "Jh", "Sh", "Au", "Eu"}
set theToBeChangedTos to {"ĉ", "ĝ", "ĥ", "ĵ", "ŝ", "aŭ", "eŭ", "Ĉ", "Ĝ", "Ĥ", "Ĵ", "Ŝ", "Aŭ", "Eŭ"}

repeat with i from 1 to count of theToBeFounds

set find what of find text preferences to (item i of theToBeFounds)
set change to of change text preferences to (item i of theToBeChangedTos)
set theFinds to find text document 1
repeat with j from (count of theFinds) to 1 by -1
select text item j of theFinds

tell application "System Events"
keystroke "y" using command down
keystroke "y" using command down
end tell

display dialog "Change this one?" buttons {"Yes", "No", "Cancel"} ¬
default button "Yes"
if button returned of result is "Yes" then
change text item j of theFinds
end if

end repeat

end repeat

end tell