function main() {
if (app.documents.length == 0) {
alert("請至少打開一個文檔")
return
}
var win = new Window("dialog", "我要自學(xué)網(wǎng)案例-畫板加矩形")
win.margins = 20
win.onClose = function () {
var winHeight = win.bounds.height
for (var i = 100; i >= 0; i = i - 4) {
win.opacity = i / 100
win.bounds.height = winHeight * i / 100
$.sleep(10)
}
}
var areaPnl = win.add("panel", undefined, "更改范圍")
areaPnl.orientation = "row"
areaPnl.margins = 20
var onlyChoose = areaPnl.add("radiobutton", undefined, "當(dāng)前激活的畫板")
onlyChoose.value = true
areaPnl.add("radiobutton", undefined, "當(dāng)前文檔所有畫板")
var actionGroup = win.add("group")
var aboutBtn = actionGroup.add("button", [0, 0, 60, 30], "關(guān)于")
var okBtn = actionGroup.add("button", [0, 0, 60, 30], "執(zhí)行")
var closeBtn = actionGroup.add("button", [0, 0, 60, 30], "關(guān)閉")
aboutBtn.onClick = callMe
okBtn.onClick = function () {
var artboards = app.activeDocument.artboards
var layer = app.activeDocument.layers.add()
var newColor = new CMYKColor()
newColor.cyan = 0
newColor.magenta = 100
newColor.black = 0
newColor.yellow = 0
if (onlyChoose.value) {
var art = artboards[artboards.getActiveArtboardIndex()]
var left = art.artboardRect[0]
var top = art.artboardRect[1]
var width = art.artboardRect[2] - art.artboardRect[0]
var height = art.artboardRect[1] - art.artboardRect[3]
var rect = layer.pathItems.rectangle(top, left, width, height)
rect.fillColor = new NoColor()
rect.strokeWidth = UnitValue(1, "mm").as("pt")
rect.strokeColor = newColor
alert("創(chuàng)建成功")
win.close()
} else {
for (var i = 0; i < artboards.length; i++) {
var art = artboards[i]
var left = art.artboardRect[0]
var top = art.artboardRect[1]
var width = art.artboardRect[2] - art.artboardRect[0]
var height = art.artboardRect[1] - art.artboardRect[3]
var rect = layer.pathItems.rectangle(top, left, width, height)
rect.fillColor = new NoColor()
rect.strokeWidth = UnitValue(1, "mm").as("pt")
rect.strokeColor = newColor
}
alert("創(chuàng)建成功")
win.close()
}
}
closeBtn.onClick = function () {
win.close() // 關(guān)閉窗口
}
win.center()
win.show()
}
function callMe() {
var fileName = Folder.temp + "\\關(guān)于我們.url"
var myFile = new File(fileName)
myFile.open("w") // write 寫入
myFile.writeln("[InternetShortcut]")
myFile.writeln("URL=http://www.51zxw.net/")
myFile.close()
myFile.execute()
}
main()
承擔(dān)因您的行為而導(dǎo)致的法律責(zé)任,
本站有權(quán)保留或刪除有爭議評論。
參與本評論即表明您已經(jīng)閱讀并接受
上述條款。