I have just spent ages trying to work out how to refer to Illustrator documents properly. I have something that works, but I was wondering if there were some more sensible ways.
The script should make a clipping mask of selected objects, copy and paste them into a new document.
tell application "Adobe Illustrator"
activate
set openDocs to every document
set i to count of openDocs
log openDocs
set proofDoc to make new document with properties {width:3118.11023622, height:841.88976378, color space:CMYK}
repeat i times
set current document to document 2
my copyAllObjectsClipped()
close current document saving no
set current document to document 1
my pasteClipboard()
end repeat
end tell
on copyAllObjectsClipped()
--copy all objects - doesn't account for locked layers or objects yet
tell application "System Events"
tell application process "Adobe Illustrator"
keystroke "a" using command down
delay 1
keystroke "7" using command down
delay 1
keystroke "c" using command down
delay 1
end tell
end tell
end copyAllObjectsClipped
on pasteClipboard()
tell application "System Events"
tell application process "Adobe Illustrator"
keystroke "f" using command down
delay 1
if exists window "Swatch Conflict" then --set swatchWindow to true
keystroke return -- for merge swatches
end if
end tell
end tell
end pasteClipboard
Model: 2 x 2.8 GHz Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.6.14
Operating System: Mac OS X (10.6)