Photoshop 脚本初体验

test.jsx

#target photoshop
app.bringToFront();

var nowTime = new Date();
var PRESOLUTION = 72; 
var startRulerUnits = app.preferences.rulerUnits;
var startTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.preferences.typeUnits = TypeUnits.PIXELS;
var title = "界面测试";

res = "dialog { \
    text:'" + title + " - 直接保存并关闭', \
    group: Group { \
        orientation: 'column', \
        alignChildren: 'left', \
        top: StaticText { \
            text: '默认为直接覆盖保存 - 请注意选择或做好备份' \
        }, \
        timeline: Progressbar { \
            bounds: [0, 0, 300, 10], \
            minvalue: 0, \
            maxvalue:100 \
        } \
        coordinate: Panel { \
            orientation: 'row', \
            text: '需要尺寸', \
            x: Group { \
                orientation: 'row', \
                s: StaticText { text: '宽:' }, \
                e: EditText { preferredSize: [50, 20] } ,\
                p: StaticText { text:'px' }, \
            }, \
            y: Group { \
                orientation: 'row', \
                s: StaticText { text:'高:' }, \
                e: EditText { preferredSize: [50, 20] }, \
                p: StaticText { text:'px' }, \
            } , \
        }, \
        folderO: Group { \
            orientation: 'row', \
            b: Button { \
                text: '待处理文件夹', \
                properties: { name: 'open' } , \
                helpTip: '选择您需要处理的文件所在的文件夹' \
            }, \
            s: EditText  { \
                text: '', \
                preferredSize: [180, 20] \
            }, \
        }, \
    },\
    buttons: Group { \
        orientation: 'row', \
        alignment: 'right', \
        s: StaticText { \
            text: '[ABOUT]' \
        }, \
        btnOk: Button { \
            text: '确定', \
            properties: { name: 'ok' } \
        }, \
        btnCancel: Button { \
            text: '取消', \
            properties: { name: 'cancel' } \
        } \
    }, \
}";

win = new Window (res);


// 选择目标文件夹
var folderOpen = win.group.folderO;
folderOpen.b.onClick = function() {
		var defaultFolder = folderOpen.s.text;
		var testFolder = new Folder(defaultFolder);
		if ( !testFolder.exists ) {
			defaultFolder = "~";
		}
		var selFolder = Folder.selectDialog("选择待处理文件夹", defaultFolder);
		if ( selFolder != null ) {
            folderOpen.s.text = selFolder.fsName;
            folderOpen.s.helpTip = selFolder.fsName.toString();
	    }
}

// 取消
win.buttons.btnCancel.onClick = function () {
	app.preferences.rulerUnits = startRulerUnits;
	app.preferences.typeUnits = startTypeUnits;
	this.parent.parent.close();
}

win.center();
win.show();


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值