>>932 こんなのどう? set theFCs to {} set theSCs to {} tell application "Adobe Illustrator" tell document 1 set pItemsCount to count of page items repeat with i from 1 to pItemsCount try set theFC to fill color of page item i set theSC to stroke color of page item i if {theFC} is not in theFCs then set the end of theFCs to theFC if {theSC} is not in theSCs then set the end of theSCs to theSC end try end repeat make new layer set theGB to geometric bounds set x to item 1 of page origin set Y to height + (item 2 of page origin) repeat with i from 1 to count of theFCs set theRH to height / (count of theFCs) make new rectangle with properties {bounds:{x, Y - theRH * (i - 1), x + 10, Y - theRH * i}, fill color:item i of theFCs, stroke color:{class:no color info}} end repeat repeat with i from 1 to count of theSCs set theRH to height / (count of theSCs) make new path item at beginning with properties {entire path:{{x + 10, Y - theRH * (i - 1)}, {x + 20, Y - theRH * i}}, filled:false, stroke color:item i of theSCs} end repeat end tell end tell 新しいレイヤーに使っている色の一覧が作られるので(グラデは除外) Illustrator上で自動選択ツールの設定を許容値を0にして一覧の色を選択
需要あるかな?Safariを利用したプログレスバー --Safariを利用したプログレスバー global BL set BL to 300 tell application "Finder" to set selected to selection as list set work to "Finderで選択されたアイテム名" my makeprogresswindow(work) set deno to count of selected repeat with i from 1 to deno my progressbar(name of item i of selected & "を処理中", i, deno, work) delay 0.2 --ここに処理を入れる end repeat my breakprogresswindow(work) on makeprogresswindow(W) tell application "Safari" activate make new document with properties {URL:"about:blank"} set bounds of window 1 to {30, 30, 50 + BL, 200} do JavaScript "document.write ('<title>" & W & "</title><body><div id=¥"bar¥" style=¥"background:#eeeeee;width:" & BL & ";height:10;margin: 0 auto;font-size:12px¥"></div></body>');" in document 1 end tell end makeprogresswindow on progressbar(WN, NU, DE, W) tell application "Safari" set PBL to round NU / DE * BL do JavaScript "document.getElementById(¥"bar¥").innerHTML='<div style=¥"background:#999999;width:" & PBL & ";height:100%;margin: 0¥"></div>" & WN & "';" in document W end tell end progressbar on breakprogresswindow(W) tell application "Safari" to close document W end breakprogresswindow
on open drop_item_list tell application "Finder" set the clipboard to "" repeat with obj in drop_item_list set file_size to size of obj set the clipboard to (the clipboard) & file_size & return end repeat end tell end open
実行すると Volume myusb on disk2s1 failed to unmout というエラーメッセージが出てアンマウントできませんでした。 実行したプログラムそのものが存在するドライブをアンマウントするのでエラーは当たり前なのかもしれないですが、それを回避してアンマウントするappを「USBメモリ内に」作る方法はないでしょうか?
tell application "System Events" to set myPID to the unix id of process the (name of the current application) do shell script "echo 'while kill -0 " & myPID & " 2> /dev/null; do sleep 1; done; diskutil unmount /Volumes/myusb; rm -f /tmp/realUnmountUSBVol.sh' > /tmp/realUnmountUSBVol.sh" do shell script "sh /tmp/realUnmountUSBVol.sh > /dev/null 2>&1 &"
do shell script は & だけじゃバックグラウンドプロセスを起動してすぐ帰るってしてくれなくて、> /dev/null 2>&1 を付ければOK。ってことでこのスレらしくない?w >>949
tell application "System Events" to set myPID to the unix id of process the (name of the current application) set cshScript to "while( 1 ) /bin/kill -0 " & myPID & " >& /dev/null if( $? ) break sleep 1 end diskutil unmount /Volumes/myusb"
set savedDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to return set cshScript to text items of cshScript set AppleScript's text item delimiters to ASCII character 10 set cshScript to cshScript as string set AppleScript's text item delimiters to savedDelimiters
tell application "System Events" to set myPID to the unix id of process the (name of the current application) do shell script "/bin/csh -c " & quote & "/bin/bash -c 'while kill -0 " & myPID & " 2> /dev/null; do sleep 1; done; diskutil unmount /Volumes/Untitled'" & quote & " > /dev/null 2>&1 &"
ちょっと教えてください。AcrobatProfessionalについているPDFをチェックする プリフライト機能、というのがあるんですが、これがメニューからドロップレット が作れます。中を開くとAppleScriptなので、これ幸いと自分のスクリプトに 組み込めないかと苦闘したのですが、実現できません。 on process_item(this_item)ハンドラを他のスクリプトに内蔵することってできない でしょうか。
on open these_items try process_item(these_items) end try end open
-- process the file on process_item(this_item) try tell application "Finder" set myPath to path to me end tell with timeout of 1 second tell application "Adobe Acrobat Professional" activate delay 1 ≪event PRFLPRFL≫ this_item given ≪class PATH≫:myPath end tell end timeout end try end process_item
どうしても分からんorz applescript studioのイベントハンドラで on key down theObjectと on key up theObject があるかと思うけど、ウインドウにボタンを配置しておき、 シフトかオプション、コマンド、コントロールなどキーは問わないが、 キーを押した時点でボタンの表示がたとえば「印刷」から「用紙を指定して印刷」 とか代わって、そのままクリックするとそれぞれ別のスクリプトが動くようにしたい のだけど、どうすればいいんでしょうか。on key down の例を探したけど、 見つからなかった。applescript studio のイベントハンドラ 一覧とその例とか どっかにないかな……。
tell application "Finder" activate set theVolume to disk of (path to me) select theVolume tell application "System Events" key code (14) using command down end tell end tell
on IsDown(theKeys, theKeyMask) return ((theKeys / (shift of theKeyMask)) mod 2) as integer is 1 end IsDown
on idle set theModifiersKey to call method "modifierFlags" of class "NSEvent" if not IsDown(theModifiersKey, NSAlternateKeyMask) then set theButtonTitle to "Print" else set theButtonTitle to "Print..." end if set title of button "Print" of window "main" to theButtonTitle return 0.5 end idle