Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
InDesignの「スマートガイド」をON/OFFするJavaScript
// 「スマートガイド」をON/OFFする v2
var b = app.smartGuidePreferences.enabled;
var status = "";
var buttonText = ""
if ( b ){
status = "ON";
buttonText = "OFF";
}else{
status = "OFF";
buttonText = "ON";
}
var result = multiBtnDlg("スマートガイド", "現状:"+status, [buttonText, "Close"], 1);
if(result===0){
app.smartGuidePreferences.enabled = !b;
}
// モーダルウインドウ
// https://uske-s.hatenablog.com/entry/2018/08/08/191022
function multiBtnDlg(title, text, list, focus) {
var cDlg = new Window("dialog", title);
cDlg.add("statictext", undefined, text, {multiline: true});
var btnGrp = cDlg.add("group");
var btnList = [];
for (var i=0; i<list.length; i++) {
if (i === focus) {
btnList.push(btnGrp.add("button", undefined, list[i], {name: "ok"}));
} else {
btnList.push(btnGrp.add("button", undefined, list[i]));
}
eval(
"btnList[i].onClick = function() {\n"+
" cDlg.close("+(i)+");\n"+
"}");
}
return cDlg.show();
};
@monokano
Copy link
Author

monokano commented Oct 29, 2021

InDesignのメニューを見なくても「スマートガイド」の現状確認ができ、ON/OFFの変更もできます。

スクリーンショット 2021-10-29 22 10 11 スクリーンショット 2021-10-29 22 10 21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment