uni-factory.jp

26年3月:WordPressをやめてObsidianpandocを使ったページに変更。

InDesign

テキスト揃え

標準のショートカットを使わずに外部ショートカットアプリで操作するために作成。

#テキスト上揃え
tell application "Adobe InDesign 2024" to set vertical justification of text frame preferences of selection to top align
#テキスト下揃え
tell application "Adobe InDesign 2024" to set vertical justification of text frame preferences of selection to bottom align

ツールパレット操作

標準のショートカットを使わずに外部ショートカットアプリで操作するために作成。

#セレクトツール
tell application "Adobe InDesign 2024" to set current tool of tool box 1 to selection tool
#ダイレクト選択ツール
tell application "Adobe InDesign 2024" to set current tool of tool box 1 to direct selection tool

段落スタイル移動

段落スタイルパレットに新規フォルダを作り、元々フォルダに入っていない段落スタイルを移動します。

tell document 1 of application "Adobe InDesign 2024"
    set a0 to "uni"--新規フォルダ名
    set a1 to paragraph styles
    try
        set a2 to make paragraph style group with properties {name:a0}
    end try
    repeat with a5 in a1
        try
            move a5 to beginning of paragraph style group a0
        end try
    end repeat
end tell

上記の逆。フォルダに入っている段落スタイルをフォルダ外に移動。 同名段落スタイがある場合はママ。

tell application "Adobe InDesign 2024"
    activate
    set a1 to paragraph style groups of document 1
    repeat with a2 in a1
        set a4 to all paragraph styles of a2
        repeat with a5 in a4
            try
                move a5 to beginning of document 1
            end try
        end repeat
    end repeat
end tell

整列パレット色々

数値指定均等配置 a0で数値を変えます。

tell document 1 of application "Adobe InDesign 2024"
set a0 to 6
    set a1 to items of selection
    if a1 is not {} then
        
        distribute align distribute items selection distribute option vertical space align distribute bounds item bounds absolute distribute measurement a0 with use distribute measurement
    end if
end tell

選択オブジェクトマージン上揃え

tell document 1 of application "Adobe InDesign 2024"
    set a1 to items of selection
    if a1 is not {} then
        align align distribute items selection align option top edges align distribute bounds margin bounds
    end if
end tell

選択オブジェクト上揃え

tell document 1 of application "Adobe InDesign 2024"
    set a1 to items of selection
    if a1 is not {} then
        distribute align distribute items selection distribute option top edges align distribute bounds item bounds absolute distribute measurement 0 with use distribute measurement
    end if
end tell

オブジェクトスタイルの基本を変更

tell document 1 of application "Adobe InDesign 2024"
    set applied grid object style of page item defaults to object style "[基本グリッド]"
    set applied graphic object style of page item defaults to object style "[基本グラフィックフレーム]"
    set applied text object style of page item defaults to object style "[基本テキストフレーム]"
end tell

段落スタイル名を変更

元のスタイル名+ランダム5文字

tell document 1 of application "Adobe InDesign 2024"
    set a1 to paragraph styles
    set a3 to a7() of me
    repeat with a2 in a1
        try
            set name of a2 to name of a2 & a3
        end try
    end repeat
end tell

on a7()
    set {a1, a2} to {{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}, "|"}
    repeat 4 times
        set a2 to a2 & some item of a1
    end repeat
    return a2
end a7

パッケージ

ドキュメントと同一フォルダーに、上位フォルダー名でパッケージをします。

tell document 1 of application "Adobe InDesign 2024" to set a1 to file path as Unicode text
tell application "Finder" to set a2 to name of alias a1
tell current application to do shell script "mkdir -p '" & POSIX path of alias a1 & a2 & "/'"
set a3 to a1 & a2 & ":"
tell application "Adobe InDesign 2024" to package document 1 to alias a3 with copying fonts, copying linked graphics, updating graphics and including hidden layers without copying profiles, ignore preflight errors and creating report
beep 2

段落罫線をボックスに合わせる

フレーム内マージン+フォントサイズに段落罫線を設定します。

set w1 to 0
---この数値を変えると線幅が変わります。
tell document 1 of application "Adobe InDesign 2024"
    set a1 to parent text frames of selection
    copy geometric bounds of a1's item 1 to {p1, p2, p3, p4}
    set c1 to fill color of a1's item 1
    try
        copy inset spacing of text frame preferences of a1's item 1 to {i1, i2, i3, i4}
    on error
        set {i1, i2, i3, i4} to {0, 0, 0, 0}
    end try
    set {g1, g2} to {0, 0}
    try
        set co1 to make new color with properties {space:CMYK, color value:{10, 10, 10, 0}, name:"uni01"}
    end try
    try
        set co2 to make new color with properties {space:CMYK, color value:{0, 0, 0, 100}, name:"uni02"}
    end try
    set l1 to object reference of paragraphs of parent story of selection
    repeat with p5 in l1
        copy properties of p5 to {point size:b5, leading:l6}
        set g1 to g2 + (b5 * 0.25) + i1
        set properties of p5 to {rule below line weight:p3 - p1 - (w1 * 2), rule below offset:-g1 + w1, rule below:true, rule below width:text width, rule below right indent:-i4 + w1, rule below left indent:-i2 + w1, rule below color:"uni01"} 
        set properties of selection to {rule above line weight:p3 - p1, rule above offset:-i1, rule above:true, rule above width:text width, rule above right indent:-i4, rule above left indent:-i2, rule above color:"uni02"}
    end repeat
end tell

ID テキストをだいたい順番に書き出し

テキストボックスの座標を元に左上からテキストを取得していきます。 ドキュメント同一フォルダに●●.indd.txtとして書き出されます。

tell document 1 of application "Adobe InDesign 2024"
    set p1x to name of page 1
    set p1x1 to count pages
    set {a1x, a7x, a3x, a2x} to {parent page of parent text frames of character 1 of (every story whose "nafalse" is not name), geometric bounds of parent text frames of character 1 of (every story whose "nafalse" is not name), "", parent story of parent text frames of character 1 of (every story whose "nafalse" is not name)}
    repeat with a4x from 1 to count a1x
        try
            set {c1x, c2x} to {a7x's item a4x's item 1, a7x's item a4x's item 2}
            set c1x to (("000" & ((round c1x rounding toward zero) as Unicode text)) as Unicode text)'s characters -3 thru end & (c1x mod 1 as Unicode text)'s characters 2 thru end as Unicode text
            set c2x to (("000" & ((round c2x rounding toward zero) as Unicode text)) as Unicode text)'s characters -3 thru end & (c2x mod 1 as Unicode text)'s characters 2 thru end as Unicode text
            set a3x to a3x & name of a1x's item a4x & ":" & c1x & ":" & c2x & ":" & a4x & "\n"
        end try
    end repeat
    tell current application to set a4x to do shell script "echo " & quoted form of a3x & " | sort -it:  | sed -e 's/.*://' | perl -pe 's/^$\n//'"
    set {b1x, b2x} to {POSIX path of (file path as Unicode text), name}
    set {a7x, a5x, a9x} to {{}, b2x & "\r\r", 0}
    repeat with a8x in paragraphs of a4x
        set a7x to a7x & a8x
    end repeat
    repeat with a6x in a7x
        try
            set a11x to ("000" & a9x)'s characters -3 thru end as Unicode text
            set a8x to contents of a2x's item a6x's item 1
            set a12x to name of applied paragraph style of a2x's item a6x
            set a5x to a5x & "##" & a11x & "_" & a12x & "\r" & contents of a2x's item a6x's item 1 & "\r\r"
            set a9x to a9x + 1
        end try
    end repeat
    set a5x to "P " & p1x & " |全" & p1x1 & "ページ|" & a5x as Unicode text
    set b6x to b1x & b2x & ".txt"
    tell current application to do shell script "echo " & quoted form of a5x & " > " & b6x
end tell

光彩(外側)

スウォッチの塗り色に合わせて選択テキストボックスに光彩(外側)のシャドウを付けます。 画像の上にある絵解きなどに。 1. 画像の色をスポイトツールで取得 2. テキストボックスを選択してスクリプトを実行

tell document 1 of application "Adobe InDesign 2024"
    set {a4, a2} to {selection's item 1, ((colors)'s item -1)}
    set properties of outer glow settings of content transparency settings of a4 to {effect color:a2, size:3.0, noise:0.0, spread:30.0, blend mode:darken, opacity:100.0, applied:true, technique:softer}
end tell

コピペ

以前掲載していた物から書き直しています。 私は流し込みの時にエディターとInDesignを行ったり来たりしないで、 テキストファイルをドキュメントにドロップしてコピーペーストしていくことがあります。

行の選択取得→行の選択流し込みをショートカット1発でできるので、 自動化されていない細かいコピーペーストに重宝します。

property a4 : "ss"
tell document 1 of application "Adobe InDesign 2024"
    try
        if a4 = "" then
            select character 1 of paragraph 1 of selection existing selection add to
            select character -1 of paragraph -1 of selection existing selection add to
            set a4 to contents of selection as Unicode text
            if character -1 of a4 = "\r" then set a4 to a4's characters 1 thru -2 as Unicode text
            delete selection
        else
            set a3 to -1
            set a5 to contents of paragraph -1 of selection as Unicode text
            if character -1 of a5 = "\r" then set a3 to -2
            ignoring application responses
                select character 1 of paragraph 1 of selection existing selection add to
                select character a3 of paragraph -1 of selection existing selection add to
                set contents of selection to "a"
                set contents of selection to a4 as Unicode text
                select character 1 of paragraph 1 of selection existing selection add to
            end ignoring
            set a4 to ""
        end if
    on error
        set a4 to ""
    end try
end tell

開いているドキュメントをPDFで保存

開いているドキュメント全てをPDFで保存します。

set a0 to "[プレス品質]" #←使用するPDF書き出しプリセット名に変える
tell application "Adobe InDesign 2024"
    activate
    repeat with a1 in documents
        copy properties of a1 to {file path:b1, name:c0}
        set d2 to b1 & (c0's characters 1 thru -6) & ".pdf" as Unicode text
        asynchronous export file a1 format PDF type to alias d2 using a0
        delay 0.2
    end repeat
    repeat until background tasks is {}
        delay 1
    end repeat
    display notification "uni-factory" with title "PDF書き出し" subtitle "終了しました"
end tell

Adobe 日本語単数行コンポーザに変える

最前面ドキュメントの段落スタイルを全て変えます。 コンポーザ→Adobe 日本語単数行コンポーザ 禁則調整方式→調整量を優先

tell document 1 of application "Adobe InDesign 2024" to set properties of paragraph styles to {composer:"Adobe 日本語単数行コンポーザ", kinsoku type:kinsoku prioritize adjustment amount}

ロック解除

ページアイテムのロックを解除します。 コマンド+オプション+Lと一緒

tell document 1 of application "Adobe InDesign 2024" to set locked of page items to false

ランダム角度変更

選択オブジェクトを-8度~8度の間でランダムに角度を付けます。 使い道は色々。

tell document 1 of application "Adobe InDesign CS2_J"
 set a2 to {-8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8}
 repeat with a1 in selection
 set absolute rotation angle of a1 to some item of a2
 end repeat
end tell

画像リサイズ

※不要ドキュメントで検証してから使って下さい
変形パレット「線を拡大縮小」にチェックが入っていると不具合が出ます。
クロップ機能は100%で張り込まれた画像に対してしか正常に動作しません。
インデザイン上に張り込まれている画像のサイズが100%で指定dpiになるようにPhotoShopでリサイズします。
スクリプトパネルから使用してください。
- 全てのオブジェクトを100%リセットします(実行後元には戻りません)。 - 「線を拡大縮小」のチェックを外す(実行後元の設定に戻します)。 - 定規の開始位置をスプレッドにする(実行後元の設定に戻します)。 - リサイズをかけないとクロップしない設定に仕様変更。

PhotoShop下準備
アクションパレットでフォルダuni-factoryを作り、action02action03を作って下さい。
action03が処理前、action02が処理後に実行されます。
アクションが無い場合は無視して処理が実行されます。
download

文字あふれ確認

ドキュメント上に文字あふれを調べます。 全部カバーできてるはずです

tell application "Adobe InDesign 2024"
    tell document 1
        try
            set {a02, h1, ov1} to {overflows of parent text frames of every text of every story, name of pages, {}}
        end try
        try
            set ov1 to overflows of cells of tables of every story
        end try
        if true is in a02 then
            display dialog "文字アフレのボックスがあります!!"
            return
        else if true is in ov1 then
            display dialog "文字アフレのボックスがあります!!"
            return
        end if
    end tell
    display dialog "文字アフレはありません"
end tell

合成フォント削除

ダイアログで選択した合成フォントを削除します。
※このスクリプトはドキュメント内に使われている合成フォントも削除します。

tell document 1 of application "Adobe InDesign CS2_J"
    set a1 to name of every composite font
    set b1 to choose from list a1 with prompt "削除する合成フォントを選択"  with multiple selections allowed
    repeat with a2 in b1
        try
            delete composite font a2
        end try
    end repeat
end tell

文字組みアキ量設定削除

ダイアログで選択した文字組みアキ量設定を削除します
※このスクリプトは、ドキュメント上で使われている文字組みアキ量設定も削除します。

tell document 1 of application "Adobe InDesign 2024"
    set a1 to name of mojikumi tables
    set b1 to choose from list a1 with prompt "削除する文字組みアキ量設定を選択"  with multiple selections allowed
    repeat with a2 in b1
        try
            delete mojikumi table a2
        end try
    end repeat
end tell

ドキュメントをCalendarに登録

スクリプトを実行した時間でドキュメント名を登録します。

global b1, e1, a1
tell application "Calendar"
    set {c1, a1} to {current date, name of every calendar}
    d1() of me
    make new event at end of calendar (b1's item 1) with properties {start date:c1, summary:e1, recurrence:""}
end tell
on d1()
    tell document 1 of application "Adobe InDesign 2024" to set {e1, b1} to {name as Unicode text, choose from list a1 with prompt "登録するカレンダーを選択"}
end d1

オブジェクトサイズ調整

複数選択したオブジェクトのサイズを一括調整します download

選択ボックスガイド

複数選択したオブジェクトの周囲にガイドを引きます。 download

Illustrator

テキスト合体

複数テキストオブジェクトをそれぞれの座標を元にまとめます。 エリア文字には未対応。グループ化も未対応。ポイント文字に変換、グループ化を解除して実行してください。

tell document 1 of application "Adobe Illustrator"
    set ruler origin to {0, 0}
    set {a1, a2, a3, a4, a6} to {contents of items of selection, anchor of items of selection, "", "", ""}
    set gl1 to make new group item with properties {name:"ksu"}
    move selection to end of gl1
    repeat with a5 from 1 to count a1
        tell current application to set a12 to do shell script "echo " & quoted form of a1's item a5 & " | sed -e 's/,/〓/g'"
        set {t1, t2} to {a2's item a5's item 2, a2's item a5's item 1}
        tell current application to set {t1, t2} to {round t1, t2}
        set a3 to a3 & "-" & t1 & "," & t2 & "," & a12 & "\n"
    end repeat
    tell current application to set a44 to run script (do shell script "a1=`echo " & quoted form of a3 & "  | sort -nu -t, -k1,2| sed -e 's/,.*,/,\"/g;s/$/\"}/g;s/^/{/g' | perl -pe 's/^\n$//g;s/{\"}//g;s/\n/,/g' | perl -pe 's/,,//g;s/^/{/;s/$/}/'` ; a2=`echo " & quoted form of a3 & " | sort -n -t, -k1,2| sed -e 's/,.*,/,\"/g;s/$/\"}/g;s/^/{/g' | perl -pe 's/^\n$//g;s/{\"}//g;s/\n/,/g' | perl -pe 's/,,//g;s/^/{/;s/$/}/;s/〓/,/'` ; echo  {$a1\\,$a2}")
    set {k2, a4} to {0, a44's item 2} #set a44 to a44's item 1
    set k3 to a4's item 1's item 1
    repeat with a5 in a4
        if k2 = 0 then
            set a6 to a6 & a5's item 2
            
        else if a5's item 1 is not k2 then
            set a6 to a6 & "\r" & a5's item 2
        else
            set a6 to a6 & a5's item 2
        end if
        set k2 to a5's item 1
    end repeat
    if last character of a6 is "\r" then set a6 to a6's characters 1 thru -2 as Unicode text
    
    set a1 to geometric bounds of selection
    ignoring application responses
        delete selection
    end ignoring
    set n1 to make new text frame of layer 1 with properties {anchor:{(a1's item 1), k3 * -1}, contents:a6, selected:true}
end tell

オブジェクト整列

tell application "System Events"
    tell application process "Adobe Illustrator"
        
        #click menu item "水平方向左に整列" of menu "整列" of menu item "整列" of menu "オブジェクト" of menu bar item "オブジェクト" of menu bar 1
        #click menu item "水平方向中央に整列" of menu "整列" of menu item "整列" of menu "オブジェクト" of menu bar item "オブジェクト" of menu bar 1
        #   click menu item "水平方向右に整列" of menu "整列" of menu item "整列" of menu "オブジェクト" of menu bar item "オブジェクト" of menu bar 1
        click menu item "垂直方向上に整列" of menu "整列" of menu item "整列" of menu "オブジェクト" of menu bar item "オブジェクト" of menu bar 1
        #click menu item "垂直方向中央に整列" of menu "整列" of menu item "整列" of menu "オブジェクト" of menu bar item "オブジェクト" of menu bar 1
        #click menu item "垂直方向下に整列" of menu "整列" of menu item "整列" of menu "オブジェクト" of menu bar item "オブジェクト" of menu bar 1
        
    end tell
end tell

レイヤーの色一括変換

tell document 1 of application "Adobe Illustrator" to set properties of every layer to {locked:false, color:{class:RGB color info, red:153, green:204, blue:0}}

アートボードのサイズを少し拡大

tell document 1 of application "Adobe Illustrator"
    set a9 to every artboard
    repeat with a7 in a9
        copy properties of a7 to {artboard rectangle:{a2, a3, a4, a5}}
        set artboard rectangle of a7 to {a2 - 5, a3 + 5, a4 + 5, a5 - 5}
    end repeat
end tell

オブジェクトの角度を計算

選択したラインの角度を求めます。

tell document 1 of application "Adobe Illustrator"
    copy properties of selection to {width:a1, height:a2, entire path:h1}
    set h1 to anchor of h1's item 1
    tell current application to set a3 to do shell script " echo 'scale=50;a(" & quoted form of (a1 as Unicode text) & "/" & quoted form of (a2 as Unicode text) & ")/(a(1)*4)*180' | bc -l"
    set a4 to 90 - a3
    set az to a3 & "\r\n" & a4
    set t10 to make new text frame of layer 1 with properties {anchor:h1, contents:az}
end tell

テキスト分割

選択テキストを行毎に分割してグループ化します。 元のスタイルなどは維持しません。

tell document 1 of application "Adobe Illustrator"
    activate
    copy properties of selection to {contents:a0, geometric bounds:{a9, a4, a5, a6}}
    delete selection
    set gl1 to make new group item with properties {name:"a1"}
    
    repeat with a2 in paragraphs of a0
        set a8 to make new text frame of layer 1 with properties {anchor:{a9, a4}, contents:a2, selected:true}
        set a4 to a4 - 10
        set a9 to a9 + 1
        move a8 to end of gl1
    end repeat
    
    set selected of gl1 to true
end tell

不要レイヤー削除

オブジェクトの無いレイヤーを削除します。 スクリプト実行後全てのレイヤーロックが解除されます。

tell document 1 of application "Adobe Illustrator"
    activate
    set locked of every layer to false
    repeat with b1 in (name of every layer as list)
        try
            if (count page items of layer b1) = 0 then delete layer b1
        end try
    end repeat
end tell

選択オブジェクトがあるレイヤー以外を非表示

tell document 1 of application "Adobe Illustrator"
    activate
    set a1 to name of every layer whose has selected artwork is true
    set visible of every layer to false
    repeat with a2 in a1
        ignoring application responses
            set visible of layer a2 to true
        end ignoring
    end repeat
end tell

Safari

ウインドウを最大化

フルスクリーンにはしたくないときに。

tell application "Finder" to set a1 to bounds of window of desktop
tell application "Safari" to set bounds of window 1 to a1

数値を変える場合。

tell application "Safari" to set bounds of window 1 to {920, 25, 3200, 3600}

開いているページのテキストをCotEditorへ

tell application "Safari"
    set tt1 to every text of current tab of window 1
    set u1 to URL of current tab of window 1
    set t2 to properties of window 1
end tell
tell application "CotEditor"
    activate
    set a1 to make new document
    set contents of a1 to u1 & "\n" & tt1
end tell

開いているページをメモへ

tell application "Safari" to set {a4, a5} to {URL of current tab of window 1, name of current tab of window 1}
tell application "Notes"
    make new note at folder "Notes" of account "iCloud" with properties {name:a5, body:"<a href=\" " & a4 & "\">" & a4 & "</a>"}
end tell

開いているページをリマインダーへ

tell application "Safari" to set {a4, a5} to {URL of current tab of window 1, name of current tab of window 1}
tell application "Reminders"
    make new reminder at list "ホーム" of account "iCloud" with properties {body:a4, name:a5}
end tell

その他

メールを指定フォルダに書き出し

日付&件名のemlファイルで書き出します。

set a0 to "/Users/●●/Desktop/mail/" #保存先フォルダ。適当に変えて下さい。

tell application "Mail"
    set a1 to selection
    set m1 to {}
    repeat with a9 from 1 to count a1
        set m0 to message id of a1's item a9
        if m0 is not in m1 then
            set m1 to m1 & m0
            set d1 to date sent of a1's item a9
            set d1 to short date string of d1
            set d1 to d1's characters 1 thru 4 & d1's characters 6 thru 7 & d1's characters 9 thru 10 as Unicode text
            set a4 to subject of a1's item a9
            tell current application to set a4 to (do shell script "echo " & quoted form of a4 & " | perl -pe 's/://g;s/\\///g;'")
            set a6 to d1 & "_" & a4 & a9 & ".eml"
            set a7 to a0 & a6
            with timeout of 1200 seconds
                tell current application to do shell script "touch " & quoted form of a7 & " ; osascript -e 'tell application \"Mail\" to source of item " & a9 & " of item 1 of {selection}' > " & quoted form of a7
            end timeout
        end if
        set flag index of a1's item a9 to 1
    end repeat
end tell

ミュージックリピート

tell application "Music" to set song repeat to all

ミュージック音量調整

0〜100で調整

tell application "Music" to set sound volume to 20

UI element全取得

タイトル通り、指定したアプリケーションのUI elementを取得します。 要素が多いメニュー項目などは時間がかかる場合があります。

http://d.hatena.ne.jp/zariganitosh/ 色々アイディアをいただきました。ありがとうございます。

※Safari上のpop up buttonはmenu item のUI elementがないので内容が取得できません。 ※pop up buttonをクリックしたあとに、下矢印など、キーストロークで選択するしかないようです。

基本部分は5行目。

取得から整形までをやってます。 ここだけで一応OKですが、他の部分で最終的な見やすい形にしています。

do shell script 内にosascriptを使い取得部分を入れているのは、do shell scriptの制限対策。 あと、こうすると取得した値がテキストで返ってくるので、あとの処理が楽だったりします。

tell application "System Events"
    set {o4, a1, a11, t1, t3} to {o1(name of application processes whose background only is false) of me, "", "", "tell application \"System Events\"", " of UI elements "}
    tell application process (o4's item 2) to set frontmost to true
    set t2 to "tell application process \"" & o4's item 2 & "\""
    set a2 to (do shell script "osascript -s s -e 'tell application \"System Events\" \n tell application process \"" & o4's item 2 & "\"\n tell " & o4's item 1 & " to UI elements & UI elements" & t3 & " & UI elements" & t3 & t3 & " & UI elements" & t3 & t3 & t3 & " & UI elements" & t3 & t3 & t3 & t3 & " & UI elements" & t3 & t3 & t3 & t3 & t3 & " & UI elements" & t3 & t3 & t3 & t3 & t3 & t3 & "  & UI elements" & t3 & t3 & t3 & t3 & t3 & t3 & t3 & " & UI elements" & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & "  & UI elements" & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & "  & UI elements " & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & "  & UI elements" & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & t3 & "  \nend tell\nend tell'| perl -pe 's/of application \"System Events\"/\n/g' | grep -E '(list|menu|value indicator|pop up button|button|radio button|checkbox|text field|slider)' | sed -e 's/window.*$/window 1/g' | perl -pe 's/[{},]//g'")
    if not o4's item 1 = "menu bar 1" then
        repeat with a9 in paragraphs of a2
            try
                if "pop up button" is in a9 then
                    try
                        run script (t1 & " to " & t2 & " to name" & t3 & "  of menu 2 of (click " & a9 & ")")
                        repeat with b1 in result
                            set a1 to a1 & b1 & ","
                        end repeat
                    end try
                    set {a11, a1} to {a11 & "click menu item \"uni-factory\" of menu 2 of " & a9 & "-->uni-factory = " & a1 & return as Unicode text, ""}
                    keystroke return
                else if "button" is in a9 or "checkbox" is in a9 or "radio button" is in a9 then
                    set a10 to run script (t1 & "\n" & t2 & " to properties of " & a9 & "\nend" as Unicode text)
                    set a11 to a11 & "click " & a9 & "-->" & role description of a10 & "," & value of a10 & "," & accessibility description of a10 & return as Unicode text
                else if "value indicator" is in a9 or "text field" is in a9 or "list" is in a9 or "slider" is in a9 then
                    set a10 to run script (t1 & "\n" & t2 & " to properties of " & a9 & "\nend" as Unicode text)
                    set a11 to a11 & "set value of " & a9 & "to \"" & value of a10 & "\"-->" & role description of a10 & "," & accessibility description of a10 & return as Unicode text
                end if
            end try
        end repeat
    else
        set a11 to a2
    end if
end tell

try
    tell application "Script Editor" to (activate) & (check syntax of (make new document with properties {text:t1 & "\ntell application process \"" & o4's item 2 & "\"\n " & a11 & "\nend\nend"}))
end try

on o1(a4)
    tell application "Finder"
        activate
        return {item 1 of (choose from list {"menu bar 1", "window 1", "every window"} with prompt "取得したいUI elementを選択" with title "uni-factory"), item 1 of (choose from list a4 with prompt "取得するアプリケーションを選択" with title "uni-factory")}
    end tell
end o1

モニターの明るさ変更

ターミナルでm1ddcをインストール

brew install m1ddc
do shell script "/opt/homebrew/bin/m1ddc display 1 set  luminance 50"
do shell script "/opt/homebrew/bin/m1ddc display 1 set  contrast 40"