tell application "Finder" set X to every disk sort by name set N to length of X set M to 0 repeat N times set M to M + 1 set Y to item M of X set position of Y to {994, 720 - M * 34} end repeat end tell
AppleScript リファレンス で, 調べてみると... repeat with Y in X と言う形があって, とっても便利そう... (Y には, X の要素を一つづつ順番に代入される. ) (さらに, 自動的に loop 脱出. <-- 無限 loop にならないところが, イカス.)
tell application "Finder" set N to 0 set X to (every disk that ejectable = true) sort by name repeat with Y in X set position of Y to {994, N * 51} set N to N + 1 end repeat end tell
set oldDelim to AppleScript's text item delimiters
(display dialog "区切り文を入力して、アーティスト欄をどちらにするか選んでください" ツ buttons {"キャンセル", "V.A.", "アーティストごと"} default button 1 default answer " / ") as list set {AppleScript's text item delimiters, chooseButton} to result
tell application "iTunes" activate set trackList to selection in browser window 1 repeat with i_track in trackList if chooseButton = "V.A." then set name of i_track to name of i_track & AppleScript's text item delimiters & artist of i_track set artist of i_track to "V.A." else set trackInfo to name of i_track set name of i_track to text item 1 of trackInfo set artist of i_track to text item 2 of trackInfo end if end repeat end tell
set AppleScript's text item delimiters to oldDelim
iTunesが起動してる時は演奏中のトラックを記憶して終了、起動してない時は起動して前回 終了時のトラックを再生という感じにしたかったのですが、 「iTunesが起動してるかどうか」を調べる方法がよくわからなかったのでとりあえず 「set frontmost of process "iTunes" 〜」をtryしてみるという形にしてみたら 一応思ったように動いているみたい・・ もっとスマートな方法があるんじゃないかと思うけど
property NowTrack : "" property NowVolume : ""
tell application "Finder" try set frontmost of process "iTunes" of application "Finder" to true tell application "iTunes" set NowTrack to current track stop quit end tell tell application "Sound Scripting" set NowVolume to sound volume end tell on error tell application "iTunes" try set volume NowVolume end try try play NowTrack end try end tell end try end tell
tell application "Finder" set Active_List to every process that visible is true if Active_List contains {process "iTunes"} then activate display dialog "起動してる" else activate display dialog "起動していない" end if end tell
tell application "Finder" set X to (every disk that ejectable = false) sort by name set Y to (every disk that ejectable = true) sort by name set X to X as list set Y to Y as list set N to 0 repeat with Z in X set position of Z to {994, 690 - N * 35} set N to N + 1 end repeat set N to 0 repeat with Z in Y set position of Z to {994, N * 51} set N to N + 1 end repeat end tell
set {M, N} to {0, 0} repeat with Z in X set position of Z to {994, 690 - N * 35} set M to M + 1 end repeat repeat with Z in Y set position of Z to {994, N * 51} set N to N + 1 end repeat
tell application "Finder" set X to (every disk sort by name) as list set {M, N} to {0, 0} repeat with i in X if ejectable of i then set position of i to {920, M * 51} set M to M + 1 else set position of i to {920, 690 - N * 35} set N to N + 1 end if end repeat end tell
tell application "Finder" set {L, X, Y} to {0,(every disk that ejectable = false), (every disk that ejectable = true)} set {W, M, N} to {(X as list) sort by name, 690, L * 35} my A(W, M, N) set {W, M, N} to {(Y as list) sort by name, L * 51, 0} my A(W, M, N) set N to 0 repeat with Z in Y set position of Z to {994, N * 51} set N to N + 1 end repeat end tell
on A(W, M, N) tell application "Finder" repeat with Z in Y set position of Z to {994, M - N} set L to L + 1 end repeat end tell end A
tell application "Finder" set move_disk to every disk that ejectable is false set fix_disk to every disk that ejectable is true my set_position(move_disk, 994, 690, 35) my set_position(fix_disk, 994, 0, -51) end tell
on set_position(the_item, X, Y, Z) tell application "Finder" set item_list to (the_item sort by name) as list repeat with i from 1 to (count of item_list) set position of item i of item_list to {X, Y - (i - 1) * Z} end repeat end tell end set_position
tell application "Finder" set {X, Y} to {every disk that ejectable /= true, every disk that ejectable = true} set {X, Y, M, N} to {(X as list) sort by name, (Y as list) sort by name, 0, 0} repeat with Z in X set position of Z to {994, 690 - N * 35} set M to M + 1 end repeat repeat with Z in Y set position of Z to {994, N * 51} set N to N + 1 end repeat end tell
>>42 #42 の Script は, error が発生するようです. 原因は ' (X as list) sort by name ' の部分. ( ' sort by name ' が reference の filter コマンドであるためと思われます.) んで, 結局, 次のようにせざるを得ませんでした.
tell application "Finder" set X to (every disk that ejectable/=true) sort by name set Y to (every disk that ejectable = true) sort by name set {X, Y, M, N} to {X as list, Y as list, 0, 0} repeat with Z in X set position of Z to {994, 690 - M * 35} set M to M + 1 end repeat repeat with Z in Y set position of Z to {994, N * 51} set N to N + 1 end repeat end tell
tell application "Finder" set {X, Y} to {(every disk that ejectable/=true), (every disk that ejectable = true)} set {X, Y, M, N} to {(X as list) sort by name, (Y as list) sort by name, 0, 0} repeat with Z in X set position of Z to {994, 690 - M * 35} set M to M + 1 end repeat repeat with Z in Y set position of Z to {994, N * 51} set N to N + 1 end repeat end tell
on open A2 with timeout of 8000000 seconds try set {A0, A1} to {{], {]} tell application "Finder" repeat with C0 in A2 if disk (name of C0) exists then if (local volume of C0 = true) and (startup of C0 = false) then set A0 to Ao & C0 end if end repeat set D to count A0 if D = 0 then beep of " display dialog "Please drop only local and non-startuo volumes." with icon caution buttons {"OK"} default button 1 else display dialog "May I only optimize these volumes, or also wipe free space?" buttons {"Cancel", "Wipe", "Optimize"} default button 3 set B to button returned of result if B /= "Cancel" then repeat with C1 in A0 set A1 to A1 & (position of C1) end repeat open application file "Speed Disk" of startup disk tell application "Speed Disk" repeat with D1 from 1 to D0 set C2 to item D1 of A0 if B = "Optimize" then optimize C2 with verifying directories and verifying data without verifying media and wiping free apace else optimize C2 with verifying directories, verifying data wiping free apace without verifying media end if end repeat quit end tell repeat with D2 from 1 to D0 set position of (item D2 of A0) to ((item (D2 + 2 - 2) of A1), (item (D2 + 2) of A1)) end repeat beep end if end if end tell on error Err0 number Err1 partial result Err3 to Err4 beep of 2 set AppleScript's text item delimiters to "," display dialog (Err0 & return & "Error Cord : " & Err1 & return & "Result List : " & (Err3 as string) & return & "Expected Type : " & (Err4 as string) & return & return & ((current date) as string)) with icon caution button {"OK"} default button 1 set AppleScript's text item delimiters to "" end try end tim out end open
tell application "Finder" open application file "Speed Disk" of startup disk end tell
>>45 問題があるのは, set {X, Y, M, N} to {(X as list) sort by name, (Y as list) sort by name, 0, 0} の部分なんですけどぉ〜... ついでに... reference の部分を2行に分けたのは,横に長くなるのを嫌ったためれふ.
tell application "Finder" set move_disk to every disk that ejectable is false set fix_disk to every disk that ejectable is true my set_position(move_disk, 994, 690, 35) my set_position(fix_disk, 994, 0, -51) end tell on set_position(the_item, X, Y, Z) tell application "Finder" if the_item is not {} then set item_list to (the_item sort by name) as list repeat with i from 1 to (count of item_list) set position of item i of item_list to {X, Y - (i - 1) * Z} end repeat end if end tell end set_position
>>52 >御指摘の意味がいまいち分かりかねますが… 7.xと8.6では、フィルタ参照形式に対して任意の項目の項目を指定することができませんでした つまり、item i of item_listのような書き方ができなかったのです 但し、count item i of item_listのように項目数を数えることは可能です AppleScriptもバージョンが上がって使いやすくなっているみたいですね
--わたしが普段使っているやつです。1/2 property Ctype : "ttxt" on run set CT to my formalName() if CT is not "" then set Ctype to CT end if my setCreator() end run
on open itemList tell application "Finder" set fname to (name of (path to current application)) set orgdelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to {"."} set Fnlist to text items of fname set AppleScript's text item delimiters to orgdelimiters
set CT to my formalName() if CT is not "" then set Ctype to CT else my setCreator() end if
repeat with aItem in itemList if (aItem as text) does not end with ":" then set creator type of aItem to Ctype else set creator type of (every file in aItem) to Ctype end if end repeat end tell end open
--つづき(2/2) to setCreator() set CT to "" repeat until length of CT is 4 display dialog "Exchange creator type to..." default answer Ctype copy text returned of the result to CT end repeat set Ctype to CT set ca to (path to current application) tell application "Finder" to set name of ca to ("Xcreator." & Ctype) end setCreator
to formalName() tell application "Finder" set fname to (name of (path to current application)) set orgdelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to {"."} set Fnlist to text items of fname set AppleScript's text item delimiters to orgdelimiters end tell if (number of Fnlist ウ 2 and (length of item 2 of Fnlist) is 4) then set rbuf to item 2 of Fnlist else set rbuf to "" end if return rbuf end formalName
property C : {} property T : {} tell application "Finder" display dialog "select the action: Load/Release" buttons {"Load", "Release"} if button returned of result = "Load" then set C to creator type of selection set T to file type of selection else display dialog C & " : Creator" & " " & T & " : Creator" & " " buttons {"Both", "Type", "Creator"} set Sel to button returned of result if Sel = "Both" then set creator type of selection to C set file type of selection to T end if if Sel = "Type" then set file type of selection to T end if if Sel = "Creator" then set creator type of selection to C end if end if end tell
ファイルメーカープロで、困ってます。 どなたか、助けて下さい。 ファイルメーカースクリプトで、メッセージ選択 や、スクリプト一時停止/続行 が実行されると、returnか、enterまたはマウスクリックが無ければ先に 進みません。 これを解決するために、Apple Scriptで、returnか、enterを キーボードで、押したことにするという方法はないでしょうか? set dataでファイルメーカーにASCII character13を送ってみました がダメでした(下の全て、ダメでした)。 tell application "ファイルメーカー Pro" set data window 1 to ASCII character 13 set data window 1 to return set data field 1 of window 1 to "" set data field 1 of window 1 to ASCII character 13 set data field 1 of window 1 to ASCII character 9 end tell
tell application "Finder" if C = {} and T = {} then set (C, T) to (creator type of selection, file type of selection) display dialog C & " : Creator" & return & T & " : Creator" buttons {"OK"} default button 1 else set Act to display dialog C & " : Creator" & return & T & " : Creator" & return & return & "select the action: Cancel/Change/Continue" buttons {"Cancel", "Change", "Continue"} default button 3 if button returned of Act = "Change" then set (C, T) to (creator type of selection, file type of selection) else if button returned of Act = "Continue" then set Sel to display dialog C & " : Creator" & return & T & " : Creator" buttons {"Both", "Type", "Creator"} if button returned of Sel = "Both" then set (creator type of selection, file type of selection) to (C, T) else if button returned of Sel = "Type" then set file type of selection to T else set creator type of selection to C end if end if end if end tell
tell application "Finder" set X to selection if C = {} and T = {} then set (C, T) to (creator type of X, file type of X) display dialog C & " : Creator" & return & T & " : FileType" buttons {"OK"} default button 1 else set Act to display dialog C & " : Creator" & return & T & " : FileType" & return & return & "select the action: Cancel/Change/Continue" buttons {"Cancel", "Change", "Continue"} default button 3 if button returned of Act = "Change" then set (C, T) to (creator type of X, file type of X) else if button returned of Act = "Continue" then set Sel to display dialog C & " : Creator" & return & T & " : FileType" buttons {"Both", "Type", "Creator"} if button returned of Sel = "Both" then set (creator type of X, file type of X) to (C, T) else if button returned of Sel = "Type" then set file type of X to T else set creator type of X to C end if end if end if end tell
tell application "Finder" set X to selection as strings if C = {} and T = {} then set (C, T) to (creator type of file X, file type of file X) display dialog C & " : Creator" & return & T & " : Creator" buttons {"OK"} default button 1 else set Act to display dialog C & " : Creator" & return & T & " : FileType" & return & return & "select the action: Cancel/Change/Continue" buttons {"Cancel", "Change", "Continue"} default button 3 if button returned of Act = "Change" then set (C, T) to (creator type of file X, file type of file X) else if button returned of Act = "Continue" then set Sel to display dialog C & " : Creator" & return & T & " : FileType" buttons {"Both", "Type", "Creator"} if button returned of Sel = "Both" then set (creator type of file X, file type of file X) to (C, T) else if button returned of Sel = "Type" then set file type of file X to T else set creator type of file X to C end if end if end if end tell
property szType : "" property szCreator : "" on run repeat set theFile to choose file with prompt "サンプルファイルの選択" tell application "Finder" to set {bufType, bufCreator} to {file type of theFile, creator type of theFile} set dialogReply to display dialog ("以下のファイルタイプとクリエータを保存します" & return & "直接入力も可能です") default answer bufType & "," & bufCreator buttons {"reset", "OK"} if button returned of dialogReply is "OK" then set {szType, szCreator} to my text_to_list(text returned of dialogReply) exit repeat end if end repeat end run
on text_to_list(thisText) set oldDelimin to AppleScript's text item delimiters set AppleScript's text item delimiters to "," set theList to every text item of thisText set AppleScript's text item delimiters to oldDelimin return theList end text_to_list
on open itemList tell application "Finder" repeat with theFile in itemList set {file type of theFile, creator type of theFile} to {szType, szCreator} end repeat end tell end open
set mes to return & return & return & return & return & return & return & return & return & return & return & return & return & return set {btn, timer} to {"OK", 3600} dialog(mes, btn, timer) if gave up of result is true then set {mes, btn, timer} to {"ヽ( `Д´ )ノウワーン 地図出ねーよ!", "ガカーリ", 4} dialog(mes, btn, timer) end if on dialog(mes, btn, timer) display dialog mes buttons btn default button 1 giving up after timer end dialog
ドロップされたもののなかにフォルダやボリュームが混じっていた場合 エラーが起きてスクリプトが直ちに終了しますよね するとドロップされたファイルの一部については 処理を施せない可能性が生じてしまいます repeat with theFile in itemList try set {file type of theFile, creator type of theFile} to {szType, szCreator} on error end error end repeat こうすれば確実な動作をします
OS 9.1のAppleScriptで上手く実行されていたAppleScriptを OS 9.2.1以降のAppleScriptで実行させると、ファイルやフォルダ名に 日本語が含まれていた場合、うまく処理出来ないという不具合が あったと思うのですが、これをコード側かOSAXなどで回避する 方法はありますか?
>>127 AppleScript 1.8.3 の変更点に >>・ Allows scripts to work with files and folders whose names contain accented or other special characters. という記述を見つけたので、ひょっとしたら直ってるかも。 誰か確認した人はいませんか?
------------------------------------------------------------------------- tell application "Finder" activate set docFolder to alias "Macintosh HD:書類:iTunes:" set LibBox to (docFolder as string) & "iTunes 2 Library Files:" set currentLib to (docFolder as string) & "iTunes Music Library (2)" as alias
if exists process "iTunes" then quit application "iTunes"
if not (exists container LibBox) then make folder at docFolder with properties {name:LibBox} set comment of currentLib to "default" return end if
set LibBox to LibBox as alias set LibList to ((comment of currentLib) as list) & (list folder LibBox without invisibles) set newLib to choose from list LibList default items comment of currentLib if result = false then return
if newLib as string /= comment of currentLib then set name of currentLib to comment of currentLib move currentLib to LibBox
set newLib to (LibBox as string) & newLib as alias move newLib to docFolder set comment of newLib to name of newLib set name of newLib to "iTunes Music Library (2)" end if end tell
tell application "iTunes" to activate -------------------------------------------------------------------------
まずは、問題点の切り分けの為に tell application "Finder" activate if exists process "iTunes" then quit application "iTunes" if not (exists container LibBox) then make folder at docFolder with properties {name:LibBox} set comment of currentLib to "default" return end if end tell 最初の部分だけで正常動作するか?というのはどうですか。 上手く動いたら次のステップを追加してまた確認という感じで 修正していけばそのうち上手く行くでしょう。 まぁ、あきらめずに思いつく事をいろいろとやってみて下さい。 considering ブロックでtell app "Finder" ブロック全体をかこむとか 問題の箇所だけtell app "Finder" ブロックからはずすとか 問題のアプリが最前面にこないように他のプロセスをactivate するとか
tell application "Netscape Navigator 3.01 [ja]" activate set theUrl to get the clipboard make new window set bounds of front window to {0, 36, 640, 480} OpenURL ("http://" & theUrl) to front window end tell
on calcMode() display dialog "calc mode : 計算を入力して下さい。" default answer "" buttons {"キャンセル", "OK"} default button "OK" with icon note set inputText to text returned of result as string
set lastDelim to AppleScript's text item delimiters set AppleScript's text item delimiters to "+" set listText to every text item of inputText --数字摘出 set AppleScript's text item delimiters to " + " set equationText to listText as string --表示数式設定 set AppleScript's text item delimiters to lastDelim set N to length of listText --項数
set calcAnswer to 0 repeat with M from 1 to N --計算ルーチン set anserItem to text item M of listText set calcAnswer to calcAnswer + anserItem end repeat
display dialog equationText & " =" default answer calcAnswer buttons {"他の計算", "キャンセル", "コピー"} default button "コピー" with icon note set nextStep to button returned of result if nextStep is "他の計算" then calcMode() if nextStep is "コピー" then set the clipboard to calcAnswer as string end calcMode
on calcMode() set inputText to text returned of (display dialog "calc mode : 計算を入力して下さい。" default answer "" buttons {"キャンセル", "OK"} default button 2 with icon note) set AppleScript's text item delimiters to "," set listText to every text item of inputText set AppleScript's text item delimiters to {} set calcAnswer to 0 repeat with N from 1 to (count listText) set calcAnswer to calcAnswer + (item N of listText) end repeat set nextStep to button returned of (display dialog inputText & "......" default answer calcAnswer buttons {"他の計算", "キャンセル", "コピー"} default button "コピー" with icon note) if nextStep = "他の計算" then calcMode() else if nextStep = "コピー" then set the clipboard to calcAnswer as string end if end calcMode
・repeat〜end repeat <-- 無限 loop ・repeat n times<-- n 回 loop する. ・repeat until ... <-- 条件 ... が false の間,loop (true になると loop 脱出) ・repeat while ... <-- 条件 ... が true の間,loop (false になると loop 脱出) ・repeat Cnt from A to B <-- ' Cnt ' が A から B まで increment されながら loop ・repeat with Y in X <-- list X から, 一つづつ item を Y に代入しながら loop
--iTuns2のラヂオチューナで録音。URL Trackをselectして実行 try set fnum to 0 tell application "iTunes" to ツ set the_stream to item 1 of address of selection if the_stream is "" then return set pls to ((path to desktop folder) as text) & "strm.pls" considering application responses tell application "Finder" to ツ if exists file pls then move file pls to trash tell application "URL Access Scripting" to ツ set convfile to download the_stream to ツ file pls replacing yes with progress tell application "Finder" update desktop set cnt to 3 repeat until exists convfile or cnt イ 0 set cnt to cnt - 1 delay 2 end repeat end tell end considering if cnt イ 0 then error number 3205 set fnum to open for access convfile set strm to read fnum using delimiter {return, "="} as text close access fnum set fnum to 0 if (item 3 of strm) is "0" then error number 4081 on error msg number num tell me to activate if fnum > 0 then close access fnum set num to 3205 end if if num is -2753 then set dmsg to "これは URL Track ではありません" set dbtn to {"まちがえますた"} else if (num is 3205) or ("URL Access" is in msg) then set dmsg to "接続に失敗しました" set dbtn to {"なけてきますた"} else if num is 4081 then set dmsg to "放送してません" set dbtn to {"ざんねんですた"} else set dmsg to msg set dbtn to {"OK"} end if display dialog dmsg & return & ツ "終了します" buttons dbtn default button 1 ツ with icon note giving up after 10 return end try tell application "iTunes" to convert convfile
--スクリプティング機能拡張フォルダーにCursor OSAX と、S穫di's Additionsが必要です。 property first_clic : {777, 10} --最初のクリックの座標(保持出来る様になってます。)デフォルト 777,10 property second_clic : {777, 60} --2番目にクリックする座標(保存出来る様になってます。)デフォルト 777,60 set init_pos to {HorizontalMouseLocation, VerticalMouseLocation} --このスクリプト終了時に復帰する座標を保持します。 set now_pos to {0, 0} --現在マウスがいる場所を記録するリスト set first_clic to first_clic --前回終了時に設定されていた1番目のクリック場所をセット set second_clic to second_clic --上に同じく、2番目のクリック場所をセット set x to 0 set y to 0 if (OptionIsDown) then --if Option Key is Down then init Position -- オプションキーで、first_clic と、second_clicの場所を初期化します。 repeat --number is not change then exit set x to item 1 of first_clic display dialog "Step 1:1st Mouse X Position is:same is set end" default answer x buttons {"SET"} default button 1
set x to (text returned of result) --as number -- as list set x to x as number
if x is not equal to item 1 of first_clic then set item 1 of first_clic to x else exit repeat --値に変更が無ければ、次の設定項目(y)
end if beep MoveMouse first_clic --確認のため、設定位置へ移動します。 repeat 100 times repeat 5000 times end repeat end repeat end repeat -- 2へ続く
--その2 --1st clic y position set set y to item 2 of first_clic
repeat --number is not change then exit set y to item 2 of first_clic display dialog "Step 2:1st Mouse Y Position is:same is set end" default answer y buttons {"SET"} default button 1
set y to (text returned of result) set y to y as number
if y is not equal to item 2 of first_clic then set item 2 of first_clic to y else exit repeat
end if beep MoveMouse first_clic repeat 100 times repeat 5000 times end repeat end repeat --if select_button is "OK" then exit repeat end repeat
repeat --number is not change then exit set x to item 1 of second_clic display dialog "Step 3:2nd Mouse X Position is:same is set end" default answer x buttons {"SET"} default button 1
set x to (text returned of result) --as number -- as list set x to x as number
if x is not equal to item 1 of second_clic then set item 1 of second_clic to x else exit repeat end if beep MoveMouse second_clic repeat 100 times repeat 5000 times end repeat end repeat --if select_button is "OK" then exit repeat end repeat
--その3 --2nd clic y position set set y to item 2 of second_clic repeat --number is not change then exit set y to item 2 of second_clic display dialog "Step 4:2nd Mouse Y Position is:same is set end" default answer y buttons {"SET"} default button 1
set y to (text returned of result) --as number -- as list set y to y as number
if y is not equal to item 2 of second_clic then set item 2 of second_clic to y else exit repeat
end if beep MoveMouse second_clic repeat 100 times repeat 5000 times end repeat end repeat --if select_button is "OK" then exit repeat end repeat end if
--main MoveMouse first_clic PressButton
repeat 100 times --ここでプルダウンメニューが表示されるまで、待ちたいのですが、repeat文ではダメのよう。 repeat 5000 times end repeat end repeat
MoveMouse second_clic repeat 50 times repeat 5000 times end repeat end repeat
PressButton repeat 300 times repeat 5000 times end repeat end repeat beep --MoveMouse init_pos --この1文で動かない
純正のキーボード追加OSAXとHyperCardを使います まずHyperCardで新たなスタック"ScriptChenge"を作成し そこにUSfontに設定した入力可能なカードフィールド"US"を作成 さらにカードボタン "USscript"を作成し on mouseUp click at loc of cd fld "US" end mouseUp この様なスクリプトを設定 下のAppleScriptを実行
set font and keyboard script synchronization to true tell application "Finder" to open alias "HD:ScriptChenge" tell application "HyperCard" tell card button "USscript" to mouseUp set font and keyboard script synchronization to false quit end tell
選択して実行すると対象を片っ端からロックする、というのを習作として作ったんですが、 これ自体はうまく動作しているのですが、これをドロップレットにしようとして悩んでます。 ドロップレットではselectionが使えないためref folders of selection以下の再帰的な参照渡しができません。 速度を追求してこの形になったのでできればrepeatで1つ1つ処理するようなことは 避けたいのですが、上手い方法ないでしょうか?
set theLock to true tell application "Finder" activate set locked of files of selection to theLock set folderList to a reference to folders of selection repeat while contents of folderList /= {} set locked of files of folderList to theLock set folderList to (a reference to folders of folderList) end repeat beep end tell
repeat with theItem in fileList if last character of (theItem as string) = ":" then repeat while contents of theItem /= {} set locked of files of theItem to theLock set theItem to (a reference to folders of theItem) end repeat else set locked of theItem to theLock end if end repeat
property last_container : "" on idle tell application "Finder" try set front_container to ツ (container of (front container window)) as alias on error set front_container to (path to desktop folder) as alias end try end tell if last_container is not front_container then tell application "Coela" activate open front_container end tell set last_container to front_container end if return 1 end idle
on open selected_items tell application "Finder" to select selected_items lock_it() end open
on lock_it() tell application "Finder" activate ignoring application responses set locked of selection to true end ignoring end tell beep 2 end lock_it
set it1 to choose file tell application "Finder" set knd to kind of it1 end tell if knd is "アプリケーション" then display dialog "このアプリのクリエータを登録します。" & return & crt as string buttons {"キャンセル", "OK"} default button 2 set crt to file creator of (info for it1) tell application "Finder" set name of (path to me) to crt end tell else set it1 to it1 as string tell application "Finder" set (file creator of file it1) to crt end tell end if
on sort_list(thelist) set outList to {} repeat until thelist is {} set minItem to 1st item of thelist repeat with i from 1 to (length of thelist) if minItem is not less than (item i of thelist) then set minItem to (item i of thelist) set minItemNum to i end if end repeat set end of outList to minItem set thelist to my remove_list(minItemNum, thelist) end repeat return outList end sort_list
on remove_list(n, thelist) if n is 1 then set thelist to rest of thelist else if n is (length of thelist) then set thelist to rest of (reverse of thelist) else set thelist to items 1 thru (n - 1) of thelist & items (n + 1) thru (length of thelist) of thelist end if return thelist end remove_list
on CombSort(aList, ascending) set nData to length of aList set gap to nData repeat set gap to (gap * 10) div 13 if (gap = 0) then set gap to 1 else if (gap = 9) or (gap = 10) then set gap to 11 end if if ascending then set idx0 to 0 set idx1 to idx0 + gap else set idx1 to 0 set idx0 to idx1 + gap end if set nLoop to nData - gap set exchanged to false
repeat nLoop times set idx0 to idx0 + 1 set idx1 to idx1 + 1 set tmp0 to item idx0 of aList set tmp1 to item idx1 of aList if (tmp0 > tmp1) then set item idx0 of aList to tmp1 set item idx1 of aList to tmp0 set exchanged to true end if end repeat if (not exchanged) and (gap = 1) then return end repeat end CombSort
on run set thelist to {} repeat 300 times set end of thelist to random number 1000 end repeat CombSort(thelist, true) thelist end run
on QuickSort(thelist) set listCount to (length of thelist) if listCount is 1 or listCount is 0 then return thelist set pivotItem to some item of thelist set lessList to {} set greatList to {} set equalList to {} repeat with i from 1 to listCount set szItem to (item i of thelist) if pivotItem is greater than szItem then set end of lessList to szItem else if pivotItem is less than szItem then set end of greatList to szItem else set end of equalList to szItem end if end repeat return QuickSort(lessList) & equalList & QuickSort(greatList) end QuickSort
>>261 お疲れさまですた。 ところでスクリプトを見て思ったけど4行目set pivotItem to some item of thelist じゃなくてset pivotItem to 1st item of thelistというように決め打ちしてしまい、 7行目set equalList to {pivotItem} 8行目repeat with i from 2 to listCount とした方がrepeatを一回減らせるんで多少速くなるかも。 でも実際やってみたらほとんど変わらんかった。
try if (sound volume) is not 0 then --音量が0でなければおえかき起動 set svol to sound volume --現在の音量を保存 set sound volume to 0 --音量を0に activate application "おえかきv1.3(OSX)" --おえかき起動 else --音量が0ならばおえかき終了 quit application "おえかきv1.3(OSX)" --おえかき終了 set sound volume to svol --保存しておいた音量に戻す end if end try
property svol : sound volume --現在の音量を保存 try if (sound volume) is not 0 then --音量が0でなければおえかき起動 set sound volume to 0 --音量を0に activate application "おえかきv1.3(OSX)" --おえかき起動 else --音量が0ならばおえかき終了 quit application "おえかきv1.3(OSX)" --おえかき終了 set sound volume to svol --保存しておいた音量に戻す end if end try
set volume 0 tell application "おえかきv1.3(OSX)" to activate
on idle tell application "Finder" if "おえかきv1.3(OSX)" is not in ツ name of (every application process) then set volume 7 tell me to quit end if end tell return 1 end idle
on opening folder thisFolder set containerPath to thisFolder as string set folderName to "K" tell application "Finder" to open item (containerPath & folderName) end opening folder
(続き) tell application "Jedit4" activate select document 1 copy document 1 make new document paste document 1 select document 1 tell document 1 select byte 1 get number of byte of selection set X to result repeat select byte X if fore color of selection = {0, 0, 0} then delete selection else set X to X + 1 end if select byte X data size of selection if result = 0 then exit repeat end repeat end tell end tell (おわり)
tell application "Jedit4" activate set theName to name of document 1 set newText to make new document tell document theName repeat with idx from 1 to (count of style run) if fore color of style run idx is not {0, 0, 0} then insert style run idx at after last byte of newText end if end repeat end tell end tell
on run tell application "Microsoft Entourage" set keitai_mail to "携帯アドレス" set subject_mail to "一人でがんばってます…" set content_mail to "とりあえず、受信しました…" make outgoing message at folder "送信トレイ" with properties {subject:subject_mail, address:keitai_mail, content:content_mail} send end tell end run
身内が突然入院することになって、数日留守にしなければならなくなり メールの受信確認をどうしようと思いOE用のがネット上にあったので 流用させてもらったはいいがスケジュールで実行するとエラーになり on run~end runの存在を知るのに朝方までかかってしまいました。
tell application "Chinpo" set Chin to Chinpo repeat if noGirlFriend then set position of migite to {0, 0} set position of migite to {0, 100} else insert Chin eject Chin end if end repeat end tell
tell application "Finder" activate select file "fix.xls" of folder "fix" of folder "excel_data" of startup disk open selection end tell tell application "Microsoft Excel" Activate Select Range "A1B2" set CutCopyMode to false CopyObject Selection end tell tell application "ファイルメーカー Pro" activate go to cell "データ1" of current record paste end tell ....以下コピペ部分延々繰り替えし
>354 on open nameFile tell application "Finder" activate set filenum to open for access file nameFile try repeat make folder with properties {name:read filenum before return} end repeat end try close access filenum end tell end open
>>355様>>359様ありがとうございました。 当方OS9.14ですが on open Droplist tell application "Finder" activate set nameFile to item 1 of Droplist set filenum to open for access file nameFile try repeat make folder with properties {name:read filenum before return} end repeat end try close access filenum end tell end open で動きました。デスクトップで起動したのでフォルダが画面いっぱいになったのは驚きましたが。 text名のフォルダにおさめるようにしたらいいのですね。
set tempPath to "MacHD:FileCutList.temp" --path of temp file set exlist to ""
tell application "Finder" set theItemList to selection if theItemList is {} then if exists front window then set exlist to ((target of front window) as alias) as string else display dialog "Nothing to FileCut" with icon 1 return end if else repeat with theObj in theItemList if exlist is "" then set exlist to (theObj as alias) as string else set exlist to exlist & return & (theObj as alias) as string end if end repeat end if end tell
try set fileNum to open for access file tempPath with write permission set eof fileNum to 0 write exlist to fileNum beep end try close access file tempPath
set temppath to "MacHD:FileCutList.temp" --path of temp file
try set tempfile to open for access file temppath set theItemList to read tempfile using delimiter {return} as text on error display dialog "read error" return end try close access tempfile
--display dialog theItemList
tell application "Finder" --set theTarget to target of front window --display dialog (theTarget as alias) as string
-- Youpi Key has bugs --if ((target of front window as alias) as string) does not end with ":" then --display dialog (target of front window as alias) as string --set theTarget to container of target of front window --end if
--move theItemList to folder ((target of front window) as string) repeat with theObj in theItemList --display dialog theObj if exists theObj as alias then if container of (theObj as alias) is target of front window then display dialog "can not" else try duplicate theObj as alias to (target of front window) as alias delete theObj as alias end try end if else display dialog "file not found" & return & theObj with icon 0 end if end repeat end tell
set FileCutListPath to ((path to preferences) as string) & "FileCutList" set FCL to load script file FileCutListPath set pFileCutList of FCL to {}
tell application "Finder" set theItemList to selection if theItemList is {} then if exists front window then set pFileCutList of FCL to {((target of front window) as alias)} else display dialog "Nothing to FileCut" with icon 1 return end if else repeat with theObj in theItemList if pFileCutList of FCL is {} then set pFileCutList of FCL to {theObj as alias} else set pFileCutList of FCL to pFileCutList of FCL & {theObj as alias} end if end repeat end if end tell store script FCL in file FileCutListPath replacing yes
set FileCutListPath to ((path to preferences) as string) & "FileCutList" set FCL to load script file FileCutListPath set theItemList to pFileCutList of FCL
--display dialog theItemList
tell application "Finder" set theTarget to (target of front window as alias) as string --display dialog (theTarget as alias) as string
-- Youpi Key has bugs --if ((target of front window as alias) as string) does not end with ":" then ----display dialog (target of front window as alias) as string --set theTarget to (container of target of front window as alias) as string --end if
--move theItemList to folder ((target of front window) as string) duplicate theItemList to folder theTarget delete theItemList end tell
このスレに何度も登場してる open for access~close accessについて エラー処理をしといた方がいいというのは分かるんですが 見るたびにtry構文の仕掛け方が違うんですね どれが正解なんでしょう? 例えば少し上の>>397では try open for access file FilePath (*いろいろな処理*) end try close access file FilePath ってなってますが、これだとファイルを開くことに失敗した場合 ファイルを閉じることができない(もともと開いてないから)と エラーになると思います
1.Appleが配付してるサンプルの例 try open for access file FilePath (*いろいろな処理*) close access file FilePath on error try close access file FilePath end try end try
2.AppleScriptリファレンスの例 open for access file FilePath try (*いろいろな処理*) on error errorMsg number errorNum close access file FilePath error errorMsg number errorNum end try close access file FilePath
3.鳶氏のAppleScript Dictionary try open for access file FilePath (*いろいろな処理*) end try close access file FilePath
try open for access file FilePath (*いろいろな処理*) close access file FilePath on error errorMsg number errorNum try close access file FilePath end try error errorMsg number errorNum end try
on replace_text(theText, searchStr, replaceStr) set AppleScript's text item delimiters to searchStr set itemList to every text item of theText set AppleScript's text item delimiters to replaceStr set theText to itemList as string set AppleScript's text item delimiters to "" return theText end replace_text
set theText to "ABCDE" ignoring case theText is "abcde" --true
set AppleScript's text item delimiters to "ab" set theText to (text items of theText) as string theText is "abcde" --true set AppleScript's text item delimiters to ""
書き込んだ後も本を調べていたのですが repeat with ~ in ~に 「リストの要素を1つずつ拾いながら、リストの要素の個数会だけ繰り返す」 と説明があったので、使えるかも?と思ったが repeat with NAME in ALLNAME if NAME end with ".d" then select file NAME of folder "efg" delete selection end repeat (↑多分、構文むちゃくちゃなんだろうな…) フォルダ内の全てのファイル名をリスト(ALLNAME)に入力する方法が解らなかった…。
tell application "アプリケーション切替" if keyboard cycling active then set keyboard cycling active to false else set keyboard cycling active to true end if end tell
tell application "アプリケーション切替" --get cycling keystroke --結果:{class:keystroke, key:tab key, modifiers:{command down}} set key of cycling keystroke to tab key set modifiers of cycling keystroke to control down end tell
tell application "Finder" copy button returned of (display dialog "枠はいるの? "buttons{"あり","なし"} default button 2) to as_0 if as_0 is "あり" then tell application "ランチャー" set frame visible of palette to true end tell else tell application "ランチャー" set frame visible of palette to false end tell end if end tell
>>467 レスサンクスです。 コンパイルしようとすると 「構文誤り、この(application constant or consideration)のあとにapplication constant of cnsiderationを書く事はできません。」 となって 「startup system folder alias」がハイライトされます。 OS 9.2.2 AppleScript J1-1.6 です。
on open dropFiles tell application "Finder" set CurrentDate to current date set modification date of dropFiles to CurrentDate move dropFiles to folder "Documents" of desktop end tell end open
on open dropFiles tell application "Finder" set CurrentDate to current date repeat with thisItem in dropFiles set modification date of thisItem to CurrentDate move thisItem to folder "Macintosh HD:ユーザ:xxx:Documents" end repeat end tell end open
on open fileLst tell application "Finder" set butu to a reference to every document file of selection set modification date of butu to current date move butu to folder "書類" of startup disk--ここは好きなのに変えてけれ end tell end open
手本。もとは>>510のとこでもらったヤツだけど簡易化してる。説明も付けた。 ttp://pc.2ch.net/test/read.cgi/mac/1032115716/221-222 それともう一つ。上で書いたように、OS9から別パーティションのOS9で再起動するヤツ --ここから tell application "起動ディスク" activate set startup system folder alias to alias "HD2:システムフォルダ:System" end tell tell app "Finder" end tell --ここまで ハードディスクの名前は自分の環境に合わせて変えろ。 手本っつーか答えじゃねーかよ。これでできんとか言ったら殺す。
今頃&厚かましいと承知の上なんですが、 >>491さんが作って下さった tell application "Finder" tell front window to set spatial view arrangement to arranged by name end tell というスクリプトなんですが、更にズームボックスを押した状態でフォルダを閉じる という機能をどうかプラスしては頂けないでしょうか!? 自分で記録機能を使ってみましたが、いまいちよくわかりませんでした。。。 何度も申し訳ないですが、どうかお願い致します。。。
スクリブト編集プログラムで新しいスクリプトウインドゥ開いて "記録"ボタン押してから Finderでズームボックス押して、ウインドゥ閉じて スクリプト記録"停止"したら下のが出来たよ。 tell application "Finder" activate set zoomed of container window 〜 to true close container window of 〜 end tell
後は、教えてもらったスクリプトにこれを追加すれば良いんでない。 tell application "Finder" tell front window set spatial view arrangement to arranged by name set zoomed to true close end tell end tell
tell application "URL Access Scripting" try with timeout of 10 seconds download "http://〜" end timeout end try quit end tell だと、「ダウンロードの接続が確率するまで」に10秒以上かかる場合はtimeout処理をしてくれるのですが。。
tell application "Finder" display dialog "フォルダ名" default answer "" buttons {"キャンセル", "OK"} default button 2 set fnm to text returned of result make folder with properties {name:fnm} end tell
set theFol to choose folder repeat tell application "Finder" display dialog "フォルダ名を入力" default answer "" buttons {" cancel ", " OK "} default button 2 set theResult to result set nameOfFolder to text returned of theResult set btnResult to button returned of theResult if btnResult is " cancel " then exit repeat else make folder at theFol with properties {name:nameOfFolder} end if end tell end repeat
tell application "Finder" set fnm to (choose from list LST with prompt "ファルダ名を選択 :" OK button name "コレにする" cancel button name "ヤメ") as string if fnm is not "false" then make folder at desktop with properties {name:fnm} end if end tell
on adding folder items to this_folder --after receiving added_items tell application "Finder" if ((every file of this_folder) is not {}) then ignoring application responses open this_folder end ignoring end if end tell end adding folder items to on removing folder items from this_folder --after losing deleted_items tell application "Finder" if ((every file of this_folder) is {}) then ignoring application responses close window of this_folder end ignoring end if end tell end removing folder items from on closing folder window for this_folder tell application "Finder" if ((every file of this_folder) is not {}) then ignoring application responses open this_folder end ignoring end if end tell end closing folder window for
起動時にドライブのアンマウントをしようとおもって tell application "Finder" put away disk "名称未設定" without asking end tell っていうスクリプト組んで起動項目に突っ込んだんですが MacOS9.1/AppleScript1.5.5 の環境ではダイアログを表示せずに動くのに MacOS9.0.4/AppleScript1.4.3 ではダイアログが表示されてしまいます。 2番目の環境でもダイアログを出さないようにする方法は無いでしょうか?
property currentapp : "" on idle set capp to (path to frontmost application as text) if capp is not (path to me as text) then ツ set currentapp to capp return 3 end idle on reopen tell application "iTunes" next track end tell tell application currentapp to activate end reopen
on open drop_items display dialog "さがす語は?" default answer "0" set D_search to text returned of result display dialog "入れ換えたい語は?" default answer "" set D_replace to text returned of result tell application "Finder" repeat with obj in drop_items set name of obj to xReplace name of obj search D_search replace D_replace end repeat end tell end open
末尾の時は下の様な処理でファイル名とさがす語を逆さまにしてリプレイスしたら また元に戻すってかんじでどうですか。 on reverse_text(textobj) set texttmp to every text item of textobj set rtext to "" repeat with str in texttmp set rtext to str & rtext end repeat return rtext end reverse_text
on replace_first(the_str, search_str, replace_str) if search_str is not in the_str then return the_str set ASTID to AppleScript's text item delimiters --デリミタ待避 set AppleScript's text item delimiters to search_str set temp_list to text items of the_str set replaced_part to (item 1 of temp_list) & replace_str & (item 2 of temp_list) set temp_list to rest of temp_list set item 1 of temp_list to replaced_part set result_str to temp_list as text set AppleScript's text item delimiters to ASTID --デリミタ復帰 return result_str end replace_first
on replace_last(the_str, search_str, replace_str) if search_str is not in the_str then return the_str set ASTID to AppleScript's text item delimiters --デリミタ待避 set AppleScript's text item delimiters to search_str set temp_list to text items of the_str set replaced_part to (item -2 of temp_list) & replace_str & (item -1 of temp_list) --変更点 set temp_list to reverse of (rest of (reverse of temp_list)) --変更点 set item -1 of temp_list to replaced_part --変更点 set result_str to temp_list as text set AppleScript's text item delimiters to ASTID --デリミタ復帰 return result_str end replace_last
Outlook Expressで自動的に指定されたメールアドレスにメールを送るスクリプトを 友達を頼りに作ったのですがエラーが出てしまって困ってます。 だれか救助をキボンっす。。。
tell application "Outlook Express" make message at end of mailbox "送信" of mail folder "" tell message 0 set field "To" to 送信先アドレス set field "Subject" to メールタイトル set field "" to 本文 end tell queue message 0
tell application "Outlook Express" make message at end of mailbox or "送信" of mail or folder "" tell message 0 set field "To" to 送信先アドレス set field "Subject" to メールタイトル set field "" to 本文 end tell queue message 0 end tell こんな風に変えてみたけどまだ駄目です… Outlook Expressのせいではないと思うのですが…
>>656,657、色々ヒントを頂きましたので container windowsをチェックする方法でプロトタイプを作ってみました。 が、make new aliasのところでエラーになってしまいますねん。 repeat内のxがcontainer window of folder "システムフォルダ" of startup diskみたいに container window ofがついてるのがマズイようなので、 stringに変換してデリミタで削ろうと思ったんですが、string変換でエラーになって出来ません。 あともう一歩。。。 ---------------------------- tell application "Finder" --repeat set check1 to container windows delay 5 set check2 to container windows if check2 is not check1 then repeat with x in check2 if x is not in check1 then make new alias folder to x at desktop end if end repeat end if --end repeat end tell
on idle tell application "Finder" set check1 to container windows end tell if check1 is not check2 then repeat with x in check1 try if x is not in check2 then tell application "Finder" set nm to name of (item of x) if ((file nm of folder "最近使ったフォルダ" of folder "アップルメニュー" of folder "システムフォルダ" of startup disk) exists) is false then make new alias to (item of x) at (folder "最近使ったフォルダ" of folder "アップルメニュー" of folder "システムフォルダ" of startup disk) end if end tell end if end try end repeat end if set check2 to check1 return 1 end idle
on opening folder theFolder tell application "Finder" if (count of alias file in folder recentFolders) is greater than or equal to num then set aliasLists to every alias file in folder recentFolders delete last item of (sort aliasLists by creation date) end if make new alias to theFolder at folder recentFolders end tell end opening folder
set DialogReply to (display dialog "日付を入力して下さい。" buttons {"OK"} default button 1 default answer "") set hizuke to text returned of DialogReply set DialogReply to (display dialog "3桁の数字を入力して下さい。" buttons {"OK"} default button 1 default answer "") set suuji to text returned of DialogReply tell application "Finder" copy folder suuji of folder hizuke of folder "A" to desktop end tell
set DialogReply to (display dialog "続けますか?" buttons {"続ける", "やめる"} default button 2) set abutton to button returned of DialogReply if abutton = "やめる" then exit repeat end if end repeat
>>687 687さんが言っておられるのはこんな感じなんでしょうが、 tell application "Finder" open file "SCSI_HD" of disk "data" --data の中にある SCSI_HD のエイリアスを開いている close container window of disk "SCSI_HD" --開いた SCSI_HD のウインドウのクローズ end tell マウント→ウインドウオープン→ウインドウクローズより、 マウント→(エラー部分とばし)の方が速いです。 アプリケーションのファイルなどなら、起動時間があったりしてなおさら 時間がかかると思います。
tell application "Finder" activate select file "001.mov" of folder "before" of disk "HDD" open selection end tell tell application "QuickTime Player" activate with timeout of 600 seconds save movie "001.mov" in file "HDD:after:001.mov" as self contained end timeout close movie "001.mov" saving no end tell
とりあえず「記録」コマンドで出来上がったスクリプトに、 タイムアウトのエラーが出ないように with timeout of 〜を加え(応答待ち時間無制限て出来るのでしょうか?)、 上の「001.mov」の文字(数字)を002、003以下略と変えた命令文をひたすらつけ足した この上なくブサイクなApplescriptを作ってみたら、一応動作しました。
set sttDate to date "2003年 5月 15日 木曜日 6:23:30 PM" set endDate to date "2003年 5月 15日 木曜日 6:23:50 PM"
set isRecFlag to false
repeat until ((current date) > endDate) if ((current date) > sttDate) then if (isRecFlag = false) then tell application "iMovie" to start recording set isRecFlag to true end if end if end repeat
set fivedaysago to day of ((current date) + 5 * days) tell application "Finder" repeat with fileA in folder "folderA" set mdfdate to modification date of fileA set dayofmdf to day of mdfdate if fivedaysago = dayofmdf then delete fileA end if end repeat end tell
>>722 tell application "Finder" set today to date "00:00:00" of (current date) delete (every file in folder tmpfolder whose ツ creation date < today) end tell うちではこんな感じでやってるけど 上の(current date)は((current date) + 5 * days) にすればいいかも。 day of 〜とかは必要なんかな? 時間まで正確に5日でないとダメすか?
set fivedaysago to ((current date) - 5 * days) tell application "Finder" repeat with finderItemA in folder "folderA" of desktop if modification date of finderItemA <= fivedaysago then delete finderItemA else log "5日前より新しい" end if end repeat end tell
やってみました。 で、結果なんですが、〜 of desktop とパスを指定しても同じでした。 やり方としては、>>722での "folderA" 内に if に当てはまるファイルを6つくらい 入れておいて実行。ってかんじです。 3つめまではゴミ箱へ行くのですが、4つめのところでエラーが出ました。 なんでだろ・・・ もひとつの day of ((current date) - 5 * days) ですが、今現在の日付(5/18)から、 set A to day of ((current date) - 18 * days) としてみたところ、30と表示しました。 こっちは問題ないみたいです。 Finderのフィルタっていうのはわからないです、すいません・・・ あ、OSはともに9.2.2です。
>>733 それを見たとき、日付同士の引き算?とか思ったのですが、set C to (A - B) としてみて 納得いたしました。 こんなんも出来るんですねぇ、なるほど。 試しに+だとどうなるかと思ってやってみたらエラーが出ました(w で、これを日数で出したい時は / 86400 とかじゃないと駄目なんでしょうか? day of (B - A) では駄目だったもので。 あぁ、そっか day は日付であって日数じゃないからか、なるほど。 と、書き込んでる途中で気づきました。 まだデータについてきちんと理解できてないですね・・・
>>736 >やり方としては、>>722での "folderA" 内に if に当てはまるファイルを6つくらい >入れておいて実行。ってかんじです。 >3つめまではゴミ箱へ行くのですが、4つめのところでエラーが出ました。 >なんでだろ・・ ここがキーワードですな。 イベントログ見ると get modification date of item 1 of folder "hogehoge" の様にitem 1とインデックスで指定されてるから 3個削除したらフォルダ内に3個のファイルしかなくなって item 4を参照できないからとまるんでは?
以下適当 set fivedaysago to day of ((current date) + 5 * days) set delFile to {} tell application "Finder" --フォルダの項目をリストに保存 repeat with fileA in folder "hogehoge" set end of delFile to fileA as alias end repeat --そのリストを元に削除するか調べて削除 repeat with fileA in delFile set mdfdate to modification date of fileA set dayofmdf to day of mdfdate if true or fivedaysago = dayofmdf then display dialog fileA as string delete fileA end if end repeat end tell
tell app "Finder" delete every file in folder "folderA" of desktop whose modification date is not greater than ((current date) - 5*days) end tell
とかで行けない?(OS Xじゃフィルタが効かないので試してない) Finderのフィルターってのは『whose なんとか is なんとか』で条件しぼるやり方の事ね。
>>737 ぐわっ、実際に捨てるとこまでやってなかったからその問題に気付かなかったよ。 ええい!こうなったら本気で作った俺様の超美麗スクリプト(ウソ)をば!! 動作確認OS X 10.2.6
set fivedaysago to ((current date) - 5 * days) set gomiList to {} tell application "Finder" repeat with finderItemA in folder "folderA" of desktop if modification date of finderItemA イ fivedaysago then set end of gomiList to finderItemA else log "5日前より新しい"--スクリプトエディタから実行するとイベントログに出ます end if end repeat delete every item of gomiList end tell
【1つめ,ATalkがオフならオンにし、ディスクをマウントするスクリプトapp】 tell application "ネットワーク設定スクリプト" open database \r begin transaction --(\rは改行してあります) set ATflg to AppleTalk active of AppleTalk options 1 if ATflg = false then set AppleTalk active of AppleTalk options 1 to true end if end transaction \r close database quit end tell mount volume "ディスク名" on server "サーバ名" as user name "ユーザ名" with password "パスワード"
【2つめ,ディスクがあったら片づけて、ATalkを切るスクリプトapp】 tell application "Finder" activate if exists disk "ディスク名" then put away disk "ディスク名" end tell tell application "ネットワーク設定スクリプト" open database \r begin transaction set AppleTalk active of AppleTalk options 1 to false end transaction \r close database quit end tell
on open droppedItem tell application "Jedit4" activate make new document set newfilename to name of result repeat with aFile in droppedItem --set numString to "1" set allInfo to info for aFile if allInfo's file type is "TEXT" then open aFile activate set para1 to paragraph 1 of document 1 insert para1 at end of document newfilename close document 1 saving no --set numString to ((numString as integer) + 1) as text end if end repeat end tell end open
OSX 10.2.6 ScriptEditor 1.9です。 Could not run the script "Collect title-paragraph" because of a program error. -1408 editボタンを押すと、 Couid not run a script editor because of a disk error. -38とでます。 スクリプトエディターのディスクエラーって?なんでしょう...。
on open droppedItem tell application "Finder" to set newText to make new file at desktop with properties {name:"Pickup_Line_1.txt", creator type:"JED3"} set lineList to {} repeat with theText in droppedItem set openedTheText to open for access theText try set theLine to read openedTheText until return on error close access openedTheText end try close access openedTheText set end of lineList to theLine end repeat set outText to lineList as string set openedNewText to open for access newText as alias with write permission try write outText to openedNewText on error close access openedNewText end try close access openedNewText end open
IEなどでは、selected text やselectionなどが使えるがsafariでは使えない。 UIscriptingもいまひとつということで、どのへんが便利かは別としてこんなのを書きました。 スクリプトエディタで実行するとうまくいくんですが、コンパイルするとうまくいきません。 なぜでしょう。 --使用方法:ttp~など不完全なURLをクリップボードにコピーして実行
tell application "Safari"
set surl to the clipboard as text if surl contains "://" then set text item delimiters of AppleScript to "://" set surl to text item 2 of surl end if set curl to "http://" & surl open location curl end tell
do java..の練習をしてみました。 tell application "Safari" repeat with i from 1 to the count of documents do JavaScript "self.moveTo(0,0);self.resizeTo(800,600)" in document i end repeat repeat 5 times do JavaScript "self.moveTo(0,0)" in document 1 do JavaScript "self.moveTo(0,30)" in document 1 do JavaScript "self.moveTo(30,30)" in document 1 do JavaScript "self.moveTo(30,0)" in document 1 do JavaScript "self.moveTo(0,0)" in document 1 end repeat open location "http://tenki.or.jp/qua/quake_2.html" end tell
>>820 Safari自体にフォームへの自動入力があるので 可能ならそっちを使った方が楽ですが、 試したところ tell application "Safari" activate do JavaScript "document.forms[0].elements['FROM'].value='ななし'" in document 1 do JavaScript "document.forms[0].elements['mail'].value='sage'" in document 1 do JavaScript "document.forms[0].elements['MESSAGE'].value='p2の書き込みウインドウに書き込みテスト'" in document 1 end tell の様にAppleScript + JavaScirptでできました。 document.forms[0].submit()で送信もできるかもしれませんが テストしてないのでできたら教えて下さい。
set Title to text returned of (display dialog "調べたい映画の題名は?" default answer "題名") tell application "Safari" activate set URL of document 0 to "http://www.stingray-jp.com/allcinema/prog/index2.php3" delay 15 do JavaScript "document.forms[0].elements['frmHeadSearchTxt'].value=" & "'" & Title & "'" in document 1 do JavaScript "document.forms[0].elements[1].checked =true;" in document 1 do JavaScript "document.forms[0].submit()" in document 1 end tell
set p1 to "'$text = <STDIN>;'" set p2 to "'$text=〜s/([^0-9A-Za-z_ ])/\"%\".unpack(\"H2\",$1)/ge;'" set p3 to "'$text=〜s/\\\\s/+/g;'" set p4 to "'print $text'"
set the clipboard to "ポケット" set theTitle to do shell script "pbpaste | perl -e " & p1 & " -e " & p2 & " -e " & p3 & " -e " & p4 tell application "Safari" activate set url1 to "http://www.stingray-jp.com/allcinema/prog/search.php3?" set url2 to "frmHeadSearchTxt=" & theTitle & "&frmHeadSearchType=0&frmHeadSearchOpt1=all" set URL of document 1 to (url1 & url2) end tell
"再帰"というのがどうも理解できないんですけど...。 テキストファイルに拡張子をつけるドロップレットなんですけど 動くようにするにはどう書いたらいいんでしょうか? on open dropitems tell application "Finder" repeat with obj in dropitems set extension hidden of obj to false if class of obj is folder then my (items of obj) else set name of obj to my addextensionname(obj) end if end repeat end tell end open to addextensionname(thefile) set recordofit to (info for thefile) set current_filename to name of recordofit if current_filename does not contain "." then if file type of recordofit is "TEXT" then set addedName to current_filename & ".txt" return addedName as string else return name of recordofit end if end if end addextensionname
on open drop_items tell application "Finder" select drop_items as list my re_name(selection, the_ext) end tell end open
on re_name(item_list, the_ext) tell application "Finder" repeat with i in item_list if class of i is document file then set extension hidden of i to false if file type of i is "TEXT" then set the_name to name of i if the_name does not contain "." then set new_name to the_name & the_ext set name of i to new_name end if end if else if class of i is folder then my re_name(items of i, the_ext) end if end if end repeat end tell end re_name
on adding folder items to folderA after receiving addeditem tell application "fetch" put into transfer window "なんちゃらかんちゃら" item addeditem end tell end adding folder items to
on adding folder items to folderA after receiving addeditem tell application "Finder" select addeditem set senditem to (items whose (name does not end with "/")) of selection as alias end tell tell application "Fetch" with timeout of 60000 seconds put into transfer window "なんたらかんたら" item senditem end timeout end tell end adding folder items to
on adding folder items to folderA after receiving addeditem tell application "Finder" repeat with allitem in addeditem if addeditem ends with "/" then set senditem to allitem as alias tell application "Fetch" with timeout of 60000 seconds put into transfer window "なんとかかんとか" item senditem end timeout end tell end if end repeat end tell end adding folder items to
tell application "アプリケーション切替" to ツ set {keyboard cycling active, icon size of palette, names visible of palette, frame visible of palette, constraint of palette, ツ orientation of palette, position of palette, anchor point of palette, button ordering of palette, quit delay} to ツ {true, small, true, true, one monitor, ツ vertical, lower right, lower right, alphabetical, 2}
tell application "iTunes 4.0.1" if selection exists then -- オブジェクトが存在する? set n to (item 1 of index of selection) -- n=何曲目 --if artworks of track n exists then --アートワークがn曲目に存在する? --display dialog "存在する場合の処理" --end if end if end tell
>>885 ありがとうございます。スマートで感激しました。 set img to data of front artwork of current track 上記で、img にPICT形式のアートワークをセットすることが出来たと思うのですが、 これをPICT形式のファイルで書き出したいです。ヒントを頂けないでしょうか。
on open theItem set theItem to quoted form of the POSIX path of theItem do shell script "mv " & theItem & " ~/DustShoot_dir" end open
on run set file_list to do shell script "cd ~/DustShoot_dir;ls" display dialog file_list & return & "を削除します。" if button returned of result is "OK" then do shell script "rm -dr -f ~/DustShoot_dir;mkdir ~/DustShoot_dir" end if end run
property smJapanese : 1 property smMaskAscii1 : 4 property smMaskAscii2 : 8 property smTransAscii1 : 2 property smTransAscii2 : 3 set src to the clipboard set srcTop to ASCII number (character 1 of src) if srcTop ウ 127 then set the clipboard to (Transliterate src srcMask 8 target 2 scriptCode 1) else set the clipboard to (Transliterate src srcMask 4 target 3 scriptCode 1) end if display dialog "Result:" & return & (the clipboard)
set theText to the clipboard set srcStr to {" ttp:", " tp:", " p:", " "} set rplStr to {"http:", "http:", "http:", ""}
repeat with i from 1 to count srcStr set AppleScript's text item delimiters to (item i of srcStr) set theList to every text item of theText set text item delimiters to (item i of rplStr) set theText to theList as string end repeat
set the clipboard to theText display dialog "Result:" & return & (the clipboard)
set theText to the clipboard as string set theText to change "'" into "'\"'\"'" in theText set theText to do shell script "echo '" & theText & "'" set the clipboard to theText as string
AppleScript's text item delimitersで 置換したらできないケースがあったので 置換できるosax探して試したら動いた。 ところで任意のスタイルを設定できる方法か osaxって無いですか?
set theText to create styled text of "こんにちは。Halo" with properties {font:"Osaka−等幅", size:14, color:{0, 0, 60000}} scrap style info of theText--確認用 set the clipboard to theText
on open dropItem set fPath to "Macintosh HD:Desktop Folder:filelist.txt" tell application "Finder" open for access file fPath with write permission my doInfoData(dropItem, fPath) close access file fPath end tell end open on doInfoData(allItems, fPath) tell application "Finder" repeat with obj in allItems set objName to obj as text set isHere to (folder objName exists) if isHere = true then set allObjItems to every item of obj my doInfoData(allObjItems, fPath) else write objName to file fPath write return to file fPath end if end repeat end tell end doInfoData
tell application "Finder" to duplicate folder "_untitled" of disk "OS9 plus" to container of window of insertion location 今もう一度やってみたら、これでできました。 条件分岐いらないっす。
>>975 on replaceText(inText, inOld, inNew) set OriginalDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to {inOld} set workData to text items of inText set AppleScript's text item delimiters to {inNew} set workData to workData as string set AppleScript's text item delimiters to OriginalDelimiters return workData end replaceText
set the clipboard to my replaceText(the clipboard, return, "@" & return)
> この場合だと改行で区切ると思うんですが、その記述はどの set the clipboard to my replaceText(the clipboard, return, "@" & return) ↓ set AppleScript's text item delimiters to {inOld}
>どこでクリップボードのテキスト情報を set the clipboard to my replaceText(the clipboard, return, "@" & return) の、replaceText(the clipboard, return, "@" & return)
>>982 >>983 set theText to "hoge" set strLen to length of theText if character strLen of theText is not return then set theText to theText & "@" end if こんな感じで文字の最後が改行かどうかわかるので うまい具合に組み込んで下さい