My objective is to display a list of image names for user to pick, then let InDesign to place those images selected automatically onto its document.
Below is the customized dialog box that will show all images file from a chosen folder, but I am stuck in how to send back the info of checked images to be used later? Please advise! Thanks!
tell application "Adobe InDesign CS3"
activate
tell application "Finder"
activate
set myFolder to (choose folder)
set myImageList to (every item of folder myFolder)
end tell
set myDialog to make dialog
tell myDialog
tell (make dialog column)
tell (make border panel)
tell (make dialog column)
repeat with i from 1 to count of myImageList
make checkbox control with properties {static label:name of text item i of myImageList}
end repeat
end tell
end tell
end tell
set myResult to show myDialog
end tell
end tell
This may not be exactly how you want to do it but this is the general way to do it. I’m using a list of object references for the check box items to make it simpler to address them.
tell application "Adobe InDesign CS3"
activate
tell application "Finder"
activate
set myFolder to (choose folder)
set myImageList to (every item of folder myFolder)
end tell
set checkBoxList to {}
set myDialog to make dialog
tell myDialog
tell (make dialog column)
tell (make border panel)
tell (make dialog column)
repeat with i from 1 to count of myImageList
copy (make checkbox control with properties {static label:name of text item i of myImageList}) to end of checkBoxList
end repeat
end tell
end tell
end tell
set myResult to show myDialog
set checkedItems to {}
repeat with aCheckBox in checkBoxList
if checked state of aCheckBox is true then copy static label of aCheckBox to end of checkedItems
end repeat
end tell
end tell
return checkedItems
Good catch Marc, I forgot to add that in at the end. Thats what I get for quickly grabbing code from one script and pasting it into another.
Retep, you should be able to do it in AppleScript Studio though the process would be a lot different. InDesign is nice because it includes the interface to make custom dialogs, but it is the only program that I know of that has it in it’s scripting dictionary. InDesign’s solution works well, but can be imprecise in layout and you have to fidget around with the code for complex dialogs. It can also take a lot of code to get them right. AppleScript studio is a more robust but has a higher learning curve.