Skip to content

Instantly share code, notes, and snippets.

@moluapple
moluapple / Pinyin4ID ContextMenu.jsx
Created April 17, 2012 03:25
[Indesign] Pinyin4ID ContextMenu
#targetengine 'pyModify'
var ruby = {
"阿": ["ā", "ē"],
"挨": ["āi", "ái"],
"艾": ["ài", "yì"],
"熬": ["áo", "āo"],
"拗": ["ǎo", "ào", "niù"],
"扒": ["bā", "pá"],
"把": ["bǎ", "bà"],
@moluapple
moluapple / autosaveACopy.jsx
Created April 17, 2012 09:20
[Indesign]EventListener AutosaveACopy
#targetengine "autosaveACopy"
(function () {
var f = new Folder("/E/autosave"),
doc = app.documents.item(0);
!f.exists && f.create();
doc.isValid && doc.addEventListener("beforeSave", backUp);
function backUp(docEvent) {
var doc = docEvent.parent,
ver = Number(doc.extractLabel('version'));
doc.insertLabel('version', ++ver + '');
@moluapple
moluapple / ID_DelaySave.vbs
Created April 17, 2012 15:13
[Indesign]自动延时保存vbs脚本
Rem ID_DelaySave.vbs
Rem An InDesign CS5 VBScript
Rem 测试环境: Win7, CS5
Rem 自动延时保存
Rem 请直接双面文件运行, 不要通过 ID 脚本面板运行
main
Function main()
Set myInDesign = CreateObject("InDesign.Application")
@moluapple
moluapple / Hex_encode_decode.jsx
Created May 1, 2012 13:33
字符及其 Hex 值互换
function hex2Ascii (str) {
return str.replace(/../g, function (a) {return String.fromCharCode('0x' + a)})
}
function ascii2Hex (hex) {
return hex.replace(/./g, function (a) {return a.charCodeAt(0).toString(16)})
}
function GBK2Hex (str/*中文字符*/) {
var f = File('hex.txt'), hex;
@moluapple
moluapple / Menu_Action_JS.jsx
Last active May 16, 2020 17:29
[Illustrator]Create, load and execute action all by JS only
// CS6 only
var set = 'Script Action', // 动作集名称
action = 'PastePDF', // 动作名称
menuEn = 'paste', // 菜单英文
menuZh = '粘贴', // 菜单中文
actionStr = ['/version 3',
'/name [ ' + set.length,
ascii2Hex(set),
']',
@moluapple
moluapple / PSD_Fonts_Extractor.py
Created May 10, 2012 13:32
解析获取 PSD 文档所用字体列表
'''
此脚本为 python3 版。
'''
import re
def selectFile():
'''利用win32ui选择文件对话框
如果未安装此模块则弹窗输入路径'''
@moluapple
moluapple / gist:2719021
Created May 17, 2012 13:44
AI CS6 Application.executeMenuCommand(menuCommandString: string ) 方法参数列表
menuCommandString,UI MenuString zh_CN
-------------------------------------
new,新建
newFromTemplate,从模板新建
open,打开
saveacopy,存储副本
Adobe AI Save For Web,存储为 Web 所用格式(W)
Adobe AI Save Selected Slices,存储选中的切片
revert,恢复
AI Place,置入(L)
@moluapple
moluapple / gist:3015959
Created June 29, 2012 05:23
将 sql 数据导出为 csv 文件
# -*- coding: utf-8 -*-
# http://stackoverflow.com/questions/3710263/how-do-i-create-a-csv-file-from-database-in-python
# 如遇编码错误,可使用python3
import csv
import sqlite3
conn = sqlite3.connect("pcd.db")
cursor = conn.cursor()
cursor.execute("select * from domain_data;")
@moluapple
moluapple / MetroUIDemo.jsx
Created July 8, 2012 06:30
Metro-like ScriptUI Demo
#include 'doEx.jsx'
#targetengine 'MetroUIDemo'
(function () {
var metro = {
'Magenta': [255, 0, 151],
'Purple': [162, 0, 255],
'Teal': [0, 171, 169],
'Lime': [140, 191, 38],
'Brown': [160, 80, 0],
'Pink': [230, 113, 184],
@moluapple
moluapple / AlignCellsbyDecimalPoint.jsx
Created July 11, 2012 07:47
[Indesign] 单元格小数点居中对齐
/***************************************************
* 确保单元格文本对齐方式为左对齐,通过以下方式选择需要对其的单元格:
* 1. 仅选中首行数据列(也即非表头及文字列)单元格运行,将自动对齐直至末行的所有数据
* 2. 直接选中所有单元格(如2行2列至100行5列)运行,对齐所有选中的单元格
* 可自动判别对齐小数点或分号(不含空格)
***************************************************/
(function() {
var oColumns = app.selection[0].columns,
i = 0,
rCount = app.selection[0].rows.length,