I have to make a billion new colors and I’m trying to make them using a dialog that just stays open. Four things:
Can someone help with this: I don’t understand why it doesn’t work.
global cval, mval, yval, kval, newSwatch
tell application "InDesign CS"
activate
set myDialog to make dialog
tell myDialog
set myDialogColumn to make dialog column
tell myDialogColumn
--create Color Name entry field
set myNameField to make text editbox with properties {edit contents:"", min width:250}
--create a Color Value Fields
set myCyanField to make text editbox with properties {edit contents:""}
set myMagField to make text editbox with properties {edit contents:""}
set myYelField to make text editbox with properties {edit contents:""}
set myBlkField to make text editbox with properties {edit contents:""}
end tell
show
--get the setting from the ColorName field
--get the settings from the ColorVal fields
set newSwatch to edit contents of myNameField
set cval to edit contents of myCyanField
set mval to edit contents of myMagField
set yval to edit contents of myYelField
set kval to edit contents of myBlkField
destroy myDialog
end tell
tell document 1
set myNewColor to make new color with properties {color value:{cval, mval, yval, kval}, name:newSwatch}
end tell
end tell
If I hard code the values, or even the variables used, the make color part works. However, even tho the log says it’s putting the values in I get an error:
"make new color with properties {color value:{“15”, “15”, “45”, “25”}, name:“asdf”}
“InDesign CS got an error: Can’t make a color.”
I need the dialog to be persistent until I’m done making colors or I cancel. Should I just use a loop, or is there a more elegant way of doing that? Just take the destroy myDialog out?
Is there any way to get the color and name from a box and label it underneath?
Anybody want to write this for Quark 4, 5, 6, Photoshop and Illustrator I’d be forever grateful. Yeah, we’re making palettes for every app.
global cval, mval, yval, kval, newSwatch
tell application "InDesign CS"
activate
set myDialog to make dialog
tell myDialog
set myDialogColumn to make dialog column
tell myDialogColumn
--create Color Name entry field
set myNameField to make text editbox with properties {edit contents:"", min width:250}
--create a Color Value Fields
set myCyanField to make text editbox with properties {edit contents:""}
set myMagField to make text editbox with properties {edit contents:""}
set myYelField to make text editbox with properties {edit contents:""}
set myBlkField to make text editbox with properties {edit contents:""}
end tell
show
--get the setting from the ColorName field
--get the settings from the ColorVal fields
set newSwatch to edit contents of myNameField
set cval to (edit contents of myCyanField) as real
set mval to (edit contents of myMagField) as real
set yval to (edit contents of myYelField) as real
set kval to (edit contents of myBlkField) as real
destroy myDialog
end tell
tell document 1
set myNewColor to make new color with properties {space:CMYK, color value:{cval, mval, yval, kval}, name:newSwatch}
end tell
end tell
Note that you have to declare the color space when defining a color.
Thanks for pointing that out. Also, I needed to add in the mode so as to have spot or process.
I was able to use xcode to write the interface and now I can add the swatches without repeatedly
opening up dialogs. Here’s the latest…
-- Swatcher.applescript
-- Swatcher
-- Created by mac2 on 9/2/05.
-- Copyright 2005 __MyCompanyName__. All rights reserved.
on clicked theObject
tell window of theObject
if the name of theObject = "AddSwatchButton" then
set SwatchColor to contents of text field "myColorField"
set cval to contents of text field "myCyanField" as real
set mval to contents of text field "myMagField" as real
set yval to contents of text field "myYelField" as real
set kval to contents of text field "myBlackField" as real
set theState to state of button "Spotify" of window of theObject
log theState
--> Returns either 0 (false) or 1 (true)
set contents of text field "myColorField" to ""
set contents of text field "myCyanField" to ""
set contents of text field "myMagField" to ""
set contents of text field "myYelField" to ""
set contents of text field "myBlackField" to ""
set contents of text field "LastColorField" to SwatchColor & " {" & cval & "," & mval & "," & yval & "," & kval & "}"
tell application "InDesign CS"
try
set myDocument to document 1
on error
set myDocument to make document
end try
if theState = 0 then
tell document 1
set myNewColor to make new color with properties {model:process, space:CMYK, color value:{cval, mval, yval, kval}, name:SwatchColor}
end tell
end if
if theState = 1 then
tell document 1
set myNewColor to make new color with properties {model:spot, space:CMYK, color value:{cval, mval, yval, kval}, name:SwatchColor}
end tell
end if
end tell
end if
if the name of theObject = "quitterButton" then
quit
end if
if the name of theObject = "HelpButton" then
display dialog "This app makes swatches in InDesign. That's really all it does.
However, the dialog stays open til you close it."
end if
end tell
end clicked
This works for me, sans error checking so…
just have to do figure out the layout and labeling aspect of the script. Any help appreciated.