///イラレ/InDesignで開いてるドキュメントをエクスプローラーで開く(win)
var path1=app.activeDocument.fullName.fsName;
with(File(Folder.desktop+"/explorer-de-hiraku.vbs")){
open("w");
write("CreateObject(\"WScript.Shell\").Run(\"explorer /select, "+path1+"\")");
close();
execute();
$.sleep(100);
remove();
};//

//選択アイテム群をアートボードにフィットさせる(未完成)
d=app.activeDocument;
s=d.selection;
x=y=1/0,X=Y=-x;
for(i=0;i<s.length;i++){
b=s[i].visibleBounds;
if(b[0]<x)x=b[0];
if(X<b[2])X=b[2];
if(b[3]<y)y=b[3];
if(Y<b[1])Y=b[1];
}
a=d.artboards[0].artboardRect;
sx=(a[2]-a[0])/(X-x),sy=(a[1]-a[3])/(Y-y);
m=getScaleMatrix(sx*100,sy*100);
m.mValueTX=-sx*x+a[0],m.mValueTY=-sy*Y+a[1];
for(i=0;i<s.length;i++)s[i].transform(m,true,true,true,true,Math.max(sx,sy),Transformation.DOCUMENTORIGIN);//

(function(){
var kakudo=prompt("角度:","0","エリアテキストのシアー")
if(kakudo!=null){
var s=app.selection[0];
var g=s.geometricBounds,o=s.parent,t=Math.tan(kakudo*Math.PI/180),a=(g[1]-g[3])*t/2;
var p=s.parent.pathItems.add();
p.setEntirePath([[g[0]-a,g[1]],[g[0]+a,g[3]],[g[2]+a,g[3]],[g[2]-a,g[1]]]);
var u=o.textFrames.areaText(p);
var m=getIdentityMatrix();
m.mValueC=t;
u.transform(m);
s.transform(m);
s.textRange.move(u,ElementPlacement.PLACEATBEGINNING);
s.remove();
u.selected=true;
}
})();

行末約物半角をベースに両端揃えで中黒の前後が均等になるアキ量設定をつくる(InDesign)

app.activeDocument.mojikumiTables.add("中黒前後均等",
{basedOnMojikumiSet:MojikumiTableDefaults.LINE_END_ALL_ONE_HALF_EM_ENUM,
overrideMojikumiAkiList:[
[11,5,true,0,0,1,0,false], //ひらがな>中黒
[33,5,true,0,0,1,0,false], //カタカナ>中黒
[24,5,true,0,0,1,0,false], //全角数字>中黒
[12,5,true,0,0,1,0,false], //上記以外の和字>中黒
]}); //

//ランダムな山並みを作るイラレスクリプト
var arr=[],N=10,H=100,S=25,B=0.1,pts=[];
for(i=0;i<N;i++)arr.push(Math.random()*H);
for(var i=-S;i<=H+S;i++)pts.push([i,f(i)]);
pts.push([H+S,-S],[-S,-S])
app.activeDocument.pathItems.add().setEntirePath(pts)
function f(x){
var d,y=0;
for(var i=0;i<N;i++)if((d=S-Math.abs(arr[i]-x))>0)y+=d*B;
return y;
} //

win+shift+s押してから10秒でタイムアウトします。キャンセルした場合に延々とクリップボードが書き換わるのを待ち受け続けるのを防ぐため。

スレッドを表示

;AutoHotkeyとIrfanViewで、win+shift+sで撮ったスクショを自動保存する.ahk

Global irfanView="C:\Program Files\IrfanView\i_view64.exe"
Global saveFolder=A_Desktop
Return

~#+s::
OnClipboardChange("saveClipboardImage")
SetTimer, canceled, -10000
Return

canceled:
OnClipboardChange("saveClipboardImage",0)
Return

saveClipboardImage()
{
OnClipboardChange("saveClipboardImage",0)
SetTimer, canceled, Off
Sleep,100
Run, "%IrfanView%" /clippaste /convert=%saveFolder%\c%A_Now%.png
} ;

;winキー+クリックした場所のRGB値をフォトショの描画色にする.ahk
::
MouseGetPos,X,Y
PixelGetColor,c,%X%,%Y%
app:=ComObjActive("Photoshop.Application")
sc:=ComObjCreate("Photoshop.SolidColor")
sc.rgb.red:=Mod(c,256)
sc.rgb.green:=Mod(c>>8,256)
sc.rgb.blue:=Mod(c>>16,256)
app.foregroundColor:=sc
Return ;

最初のとこのアプリ名のリストは、左側がメニュー名(なんでもいい)、右側がBridgeTalkでアプリを特定する文字列。調べるには対象にしたいアプリでalert(BridgeTalk.appSpecifier)というスクリプトを実行する

スレッドを表示

//続き
else gs.push.apply(gs,s[i].allGraphics);
}
for(var i=0;i<gs.length;i++){
if(gs[i].itemLink.status==LinkStatus.NORMAL)ls.push(File(gs[i].itemLink.filePath)+"");
}
var bt=new BridgeTalk;
bt.target=t;
bt.body="var p='"+ls.join(",")+"'.split(',');for(var i=0;i<p.length;i++)app.open(File(p[i]))";
bt.send();
}})(apuriNames[i][1]));
app.menus.item("レイアウトのコンテキストメニュー").submenus.item("編集ツール").menuItems.add(m);
}//

スレッドを表示

//ページアイテムの右クリックメニューの「編集ツール」に特定のバージョンのadobeアプリを追加するやつ(スタートアップスクリプト用)
session
apuriNames=[
["Illustrator CC 2019","illustrator-23.064"],
["Illustrator CC 2020","illustrator-24.064"],
];
for(var i=0;i<apuriNames.length;i++){
var m=app.scriptMenuActions.add(apuriNames[i][0]);
m.addEventListener("onInvoke",(function(t){return function(){
var gs=[],ls=[],s=app.selection;
for(var i=0;i<s.length;i++){
if(s[i].hasOwnProperty("itemLink"))gs.push(s[i]);
//続く

テキストフレームの1段の幅(縦組みなら高さ)を変えずに段数を1つ減らすやつ
f=app.selection[0],vb=f.visibleBounds,tp=f.textFramePreferences,is=tp.insetSpacing,cc=tp.textColumnCount,cg=tp.textColumnGutter,sw=f.strokeWeight;
f.parentStory.storyPreferences.storyOrientation%4?(i=1,j=3,k="Horizontal"):(i=0,j=2,k="Vertical");
vb[j]-=((vb[j]-vb[i])-(sw*2+is[i]+is[j]-cg)*f["absolute"+k+"Scale"]/100)/cc;
tp.textColumnCount--,f.visibleBounds=vb;//

スレッドを表示

テキストフレームの1段の幅(縦組みなら高さ)を変えずに段数を1つ増やすやつ
f=app.selection[0],vb=f.visibleBounds,tp=f.textFramePreferences,is=tp.insetSpacing,cc=tp.textColumnCount,cg=tp.textColumnGutter,sw=f.strokeWeight;
f.parentStory.storyPreferences.storyOrientation%4?(i=1,j=3,k="Horizontal"):(i=0,j=2,k="Vertical");
vb[j]+=((vb[j]-vb[i])-(sw*2+is[i]+is[j]-cg)*f["absolute"+k+"Scale"]/100)/cc;
tp.textColumnCount++,f.visibleBounds=vb;//

app.doScript(function(){
app.scriptPreferences.measurementUnit=2054188905;
f=app.selection[0],s=f.parentStory,p=s.storyPreferences,A=0.70866141732283,B="lineAki";
if(p.frameType==1179087984 && p.storyOrientation==1986359924)
v=f.visibleBounds,b=f.textFramePreferences.insetSpacing,g=s.gridData,w=(100/f.absoluteHorizontalScale*(v[3]-v[1])-f.strokeWeight*2-b[1]-b[3]),u=g.pointSize*g.horizontalScale/100,t=g[B],n=(w+t)/(u+t),g[B]=(w-u*(n-1))/(n-2),f.visibleBounds=v
},1246973031,[],1699963733);//

スレッドを表示

app.doScript(function(){
app.scriptPreferences.measurementUnit=2054188905;
f=app.selection[0],s=f.parentStory,p=s.storyPreferences,A=0.70866141732283,B="lineAki";
if(p.frameType==1179087984 && p.storyOrientation==1986359924)
v=f.visibleBounds,b=f.textFramePreferences.insetSpacing,g=s.gridData,w=(100/f.absoluteHorizontalScale*(v[3]-v[1])-f.strokeWeight*2-b[1]-b[3]),u=g.pointSize*g.horizontalScale/100,t=g[B],n=(w+t)/(u+t),g[B]=(w-u*(n+1))/n,f.visibleBounds=v
},1246973031,[],1699963733);//

スレッドを表示

選択アイテムが縦組みフレームグリッドのとき、行間を調整してフレームの横幅はそのままで行数を1つ増やす(InDesign)

同じく右から縮める
app.doScript(function(){
app.scriptPreferences.measurementUnit=2054188905;
f=app.selection[0],s=f.parentStory,p=s.storyPreferences,A=0.70866141732283,B="lineAki";
if(p.frameType==1179087984 && p.storyOrientation==1986359924)
v=f.visibleBounds,b=f.textFramePreferences.insetSpacing,g=s.gridData,g[B]+=A/((100/f.absoluteHorizontalScale*(v[3]-v[1])-f.strokeWeight*2-b[1]-b[3]+g[B])/(g.pointSize*g.horizontalScale/100+g[B])-1),f.move("",[-A,0]);
},1246973031,[],1699963733);//

スレッドを表示

選択アイテムが縦組みフレームグリッドのとき、行間を調整してフレームの横幅を0.25mmほど左から縮める
app.scriptPreferences.measurementUnit=2054188905;
f=app.selection[0],s=f.parentStory,p=s.storyPreferences,A=0.70866141732283,B="lineAki";
if(p.frameType==1179087984 && p.storyOrientation==1986359924)
v=f.visibleBounds,b=f.textFramePreferences.insetSpacing,g=s.gridData,g[B]-=A/((100/f.absoluteHorizontalScale*(v[3]-v[1])-f.strokeWeight*2-b[1]-b[3]+g[B])/(g.pointSize*g.horizontalScale/100+g[B])-1);//

スレッドを表示

同じく右に伸ばす
app.doScript(function(){
app.scriptPreferences.measurementUnit=2054188905;
f=app.selection[0],s=f.parentStory,p=s.storyPreferences,A=0.70866141732283,B="lineAki";
if(p.frameType==1179087984 && p.storyOrientation==1986359924)
v=f.visibleBounds,b=f.textFramePreferences.insetSpacing,g=s.gridData,g[B]+=A/((100/f.absoluteHorizontalScale*(v[3]-v[1])-f.strokeWeight*2-b[1]-b[3]+g[B])/(g.pointSize*g.horizontalScale/100+g[B])-1),f.move("",[A,0]);
},1246973031,[],1699963733);//

スレッドを表示
もっと見る
DTP-Mstdn.jp

DTP-Mstdn.jpは、DTP・デザイン・印刷に関わる人々のためのMastodonインスタンスです。特定分野の専門インスタンスですので、日々のつぶやき、耳寄りな情報の共有、ディスカッション、質問とその回答、役立つスクリプトなど、他では投稿しづらい内容も、思う存分トゥートしましょう!