on run tell application "iCab" set hida to 6 set ue to 42 set migi to 770 set shita to 600 set mado to number of window repeat mado times set bounds of window mado to {hida, ue, migi, shita} set mado to mado - 1 if mado = 0 then exit repeat set hida to hida + 5 set ue to ue + 5 set migi to migi + 5 set shita to shita + 5 end repeat end tell end run
IEで、1さんの作ったスクリプトと同じ動作をするものを作ってみました。 -- tell application "Internet Explorer" set wlist to ListWindows set ct to 0 repeat with i in wlist Activate i do script "window.moveTo(" & ct * 10 & "," & ct * 20 & ");" set ct to ct + 1 end repeat end tell --
on run tell application "iCab" set {hida, ue, migi, shita} to {6, 42, 770, 600} set mado to number of window repeat while mado > 0 set bounds of window mado to {hida, ue, migi, shita} set mado to mado - 1 set {hida, ue, migi, shita} to {hida + 5, ue + 5, migi + 5, shita + 5} end repeat end tell end run
--選択範囲を開く。板上で「ttp://〜」なんてのがある場合に「wwwから」選択してどうぞ。 tell application "iCab" tell window 1 set selectedurl to selection OpenURL selectedurl toWindow 0 end tell end tell
--ページをexciteの翻訳ページを使って英日翻訳 tell application "iCab" Activate set currenturl to URL of window 1 set hon to "http://www.excite.co.jp/world/url/body/?body=" set hon2 to "&trans_type=enja-ATL" OpenURL (hon & currenturl & hon2) toWindow 0 end tell
on run set flag to false repeat until flag is true set dt to inputdate() if (length of (dt as text) is 8) then set flag to true end repeat
set y to text 1 thru 4 of dt set m to text 5 thru 6 of dt set d to text 7 thru 8 of dt
set a to (12 - m) div 10 set b to (16 * a + 13 * m + 8) div 5 set c to (5 * (y - a)) div 4 set e to y - a div 100 set f to e div 4 set w to ((b + c + d - e + f) mod 7) + 1
set wd to "月火水木金土日" display dialog y & "年" & m & "月" & d & "日は、" & text w thru w of wd & "曜日です。" end run
on inputdate() text returned of (display dialog "曜日を知りたい年月日を数字8ケタで入力 例)20000918" default answer "") end inputdate
--dat2行きになってしまったログを通常のスレッド形式で読む --DAT2HTML(win用)のアップルスクリプト版です。 tell application "iCab" set currenturl to URL of window 1 set currenturl to MT Replace currenturl search "key=" replace "key=../dat2/" OpenURL currenturl end tell
property MPEGHead : {0, 0, 1, 186, 33, 0, 1, 0, 9, 128, 27, 145, 0, 0, 1, 187, 0, 9, 128, 27, 145, 1, 225, 255, 224, 224, 46, 0, 0, 1, 190, 8, 243, 15} on open FileList tell application "Finder" repeat with AktObj in FileList set TempStr to (ASCII character 0) repeat with x from 2 to (count of MPEGHead) by 1 set TempStr to TempStr & (ASCII character (item x of MPEGHead as integer)) end repeat set creator type of AktObj to "TVOD" set file type of AktObj to "MPEG" set OpnHndl to open for access file AktObj with write permission write TempStr to OpnHndl starting at 0 close access OpnHndl end repeat end tell end open
>>31 ありがとうございます。AppearanceChangerというAppleScript http://www.vector.co.jp/soft/mac/util/se099025.html を以下のように改造して、FinderPopのメニューに登録して 快適に使っています。 on open obj tell application "アピアランス" set picture file of monitor 1 to no picture set picture file of monitor 1 to obj set picture positioning of monitor 1 to tiled end tell end open tell application "Finder" set visible of process "アピアランス" to false end tell
すみません、end openを最後にしないとダメでした。 on open obj tell application "アピアランス" set picture file of monitor 1 to no picture set picture file of monitor 1 to obj set picture positioning of monitor 1 to tiled end tell tell application "Finder" set visible of process "アピアランス" to false end tell end open
>36 こうすると、最初から「アピアランス」コンパネを表示しませんよ。 --- on open obj launch application "アピアランス" tell application "アピアランス" set picture file of monitor 1 to no picture set picture file of monitor 1 to obj set picture positioning of monitor 1 to tiled end tell quit application "アピアランス" end open ---
ビデオプレーヤに話しかけるとダメなようなので,Finderにビデオプレーヤを 起動するように命令するようにしたらうまくいきました.アップルメニューに ビデオプレーヤのエイリアスが入ってるとして, tell application "Sound Scripting" set sound input source to "CD-TV-ビデオ" end tell tell application "Finder" activate select file "Apple ビデオプレーヤ" of folder "アップルメニュー" of folder "システムフォルダ" of startup disk open selection end tell
--選択範囲の語句でgoogle検索(改訂) tell application "iCab" tell window 1 set surl to selection set AppleScript's text item delimiters to " " set lsurl to every text item of surl set AppleScript's text item delimiters to "+" set surl to lsurl as text set google to "http://www.google.com/search?num=30&hl=ja&safe=off&lr=&q=" OpenURL (google & surl) toWindow 0 end tell end tell
tell application "iCab" tell window 1 set surl to selection set AppleScript's text item delimiters to " " set lsurl to every text item of surl set AppleScript's text item delimiters to "+" set surl to lsurl as text set hon to "http://sangenjaya.arc.net.my/cgi-bin/senttra_dispatch.cgi?pair=EJ&sent=" OpenURL (hon & surl) toWindow 0 end tell end tell end tell
tell application "iCab" tell window 1 set surl to selection set AppleScript's text item delimiters to " " set lsurl to every text item of surl set AppleScript's text item delimiters to "%0D%0A" set surl to lsurl as text set AppleScript's text item delimiters to " " set lsurl2 to every text item of surl set AppleScript's text item delimiters to "+" set surl to lsurl2 as text set hon to "http://sangenjaya.arc.net.my/cgi-bin/senttra_dispatch.cgi?pair=EJ&sent=" OpenURL (hon & surl) toWindow 0 end tell end tell
>60 --- tell application "Outlook Express" set fldnm to name of every ヌclass cFldネ set foltotxt to choose from list fldnm with prompt "テキスト書き出しを行うフォルダを選択して下さい。" with multiple selections allowed end tell tell application "Finder" set dist to choose folder with prompt "出力されたテキストを保存する場所を指定して下さい。" end tell
repeat with k in foltotxt open for access file ((dist as text) & (k as text)) with write permission returning FL tell application "Outlook Express" set eof FL to 0 set MailCount to count ヌclass msg ネ of ヌclass cFldネ (k as text) repeat with i from 1 to MailCount set s to "From ???@??? Sat Dec 11 20:43:11 1999" & return set sb to "Subject: " & (ヌclass subjネ of ヌclass msg ネ i of ヌclass cFldネ (k as text)) & return set sd to ヌclass sndrネ of ヌclass msg ネ i of ヌclass cFldネ (k as text) set fr to "From: " & ヌclass dspnネ of sd & "<" & ヌclass addrネ of sd & ">" & return set tm to ヌclass timsネ of ヌclass msg ネ i of ヌclass cFldネ (k as text) set y to year of tm set m to text from character 1 to 3 of (month of tm as text) set d to day of tm set w to text from character 1 to 3 of (weekday of tm as text) set t to time string of tm set tt to "Date: " & w & ", " & d & " " & m & " " & y & " " & t set ct to ヌclass ctntネ of ヌclass msg ネ i of ヌclass cFldネ (k as text) write s & sb & fr & tt & return & return & ct & return to FL end repeat close access FL end tell end repeat display dialog "テキスト書き出しが完了しました。" ---
tell application "アピアランス" set picture file of monitor 1 to alias "Macintosh HD:画像フォルダ:デスクトップピクチャ:" set picture positioning of monitor 1 to tiled quit end tell
ってことになります。 1.に対しては、Fileのindexを使用すると良いでしょう。 スクリプト編集プログラムで、「制御」メニューから「結果」と「履歴」のウインドウを開いて --- tell application "Finder" set a to choose folder get index of every file of a end tell --- を実行すると参考になるかも。
これだけではなんなので、5秒おきにデスクトップピクチャを変更するスクリプトを作ってみました。 あとは、どうやって順番や現在のピクチャを保持して、 それを反映させるかを考えてもらえれば...。 極力わかりやすく書いたつもりですけど、わからんかったら聞いて下さいね。 --- tell application "Finder" set theFolder to choose folder set FileList to every file of theFolder end tell
repeat with i in FileList tell application "Finder" set theFile to i as alias end tell tell application "アピアランス" set picture file of monitor 1 to theFile set picture positioning of monitor 1 to tiled end tell delay 5 end repeat
property MyData : 1 tell application "Finder" set theFolder to folder "Macintosh HD:画像フォルダ:デスクトップピクチャ:" set PictIndex to index of every file of alias "Macintosh HD:画像フォルダ:デスクトップピクチャ:" end tell
set MyData to MyData + 1 tell application "Finder" set theFile to item MyData of theFolder as alias end tell tell application "アピアランス" set picture file of monitor 1 to theFile set picture positioning of monitor 1 to tiled end tell
>74 確かに、 --- on open a tell application "Finder" display dialog (alias of (info for a)) as text end tell end open -- でエイリアスをドラッグ&ドロップすると「False」になってしまいますね。 なにか裏技あるんでしょうか...
property MyData : 1 tell application "Finder" set theFolder to folder "Macintosh HD:一時置き場:デスクトップピクチャ:" set PictIndex to index of every file of alias "Macintosh HD:一時置き場:デスクトップピクチャ:" set PictIndex to number of PictIndex end tell
set MyData to MyData + 1 if MyData > PictIndex then set MyData to 1 end if 以下同様
tell application "Internet Explorer" set surl to selected text set AppleScript's text item delimiters to " " set lsurl to every text item of surl set AppleScript's text item delimiters to "+" set surl to lsurl as text set google to "http://www.google.com/search?num=30&hl=ja&safe=off&lr=&q=" OpenURL (google & surl) toWindow 0 end tell
>96 何度も使えば使うほど楽になる、 ドラッグ&ドロップで指定ディレクトリにファイルをアップロードするスクリプト。 アップロードするファイルも記憶させて方が楽なんだろうか... --- property URLList : {} property theLastURL : "ftp://" on open (theFile) set theDialog to display dialog "アップロードするディレクトリを指定して下さい" default answer theLastURL buttons {"リストから選択", "キャンセル", "OK"} default button "OK" set theButton to button returned of theDialog set theURL to text returned of theDialog if theButton is "リストから選択" then set theURL to choose from list URLList else set the end of URLList to theURL end if set theFile to choose file tell application "URL Access Scripting" try upload theFile to theURL replacing yes with progress on error errmes number errNo display dialog (errNo as text) & ":" & errmes end try end tell set theLastURL to theURL end open ---
鬱だ。 ドラッグ&ドロップしてるのに、ファイルの在所を尋ねてしまっている... ↓が正しいです。 --- property URLList : {} property theLastURL : "ftp://" on open (theFile) set theDialog to display dialog "アップロードするディレクトリを指定して下さい" default answer theLastURL buttons {"リストから選択", "キャンセル", "OK"} default button "OK" set theButton to button returned of theDialog set theURL to text returned of theDialog if theButton is "リストから選択" then set theURL to choose from list URLList else set the end of URLList to theURL end if tell application "URL Access Scripting" try upload theFile to theURL replacing yes with progress on error errmes number errNo display dialog (errNo as text) & ":" & errmes end try end tell set theLastURL to theURL end open
長々とすみません。 エラー回避と、リストに多重登録されるバグをFixしたもの。 --- property URLList : {} property theLastURL : "ftp://" on open (theFile) set theDialog to display dialog "アップロードするディレクトリを指定して下さい" default answer theLastURL buttons {"リストから選択", "キャンセル", "OK"} default button "OK" set theButton to button returned of theDialog set theURL to text returned of theDialog if theButton is "リストから選択" then try set theURL to choose from list URLList end try else set the end of URLList to theURL end if tell application "URL Access Scripting" try upload theFile to theURL replacing yes with progress on error errmes number errNo display dialog (errNo as text) & ":" & errmes end try end tell set flag to false repeat with i in URLList if i is theLastURL then set flag to true exit repeat end if if flag is false then set theLastURL to theURL end repeat end open
申し訳ありません。 今度こそバグフィックス... --- property URLList : {} property theLastURL : "ftp://" on open (theFile) set theDialog to display dialog "アップロードするディレクトリを指定して下さい" default answer theLastURL buttons {"リストから選択", "キャンセル", "OK"} default button "OK" set theButton to button returned of theDialog set theURL to text returned of theDialog if theButton is "リストから選択" then try set theURL to choose from list URLList end try else set flag to false repeat with i in URLList if i is theLastURL then set flag to true exit repeat end if end repeat if flag is false then set the end of URLList to theURL end if tell application "URL Access Scripting" try upload theFile to theURL replacing yes with progress on error errmes number errNo display dialog (errNo as text) & ":" & errmes end try end tell set theLastURL to theURL end open
tell application "Finder" display dialog "コンピュータを今システム終了してもよろしいですか?" buttons {"再起動", "キャンセル", "システム終了"} default button "システム終了" with icon 2 giving up after 50 if button returned of result = "再起動" then restart ---else if button returned of result = "スリープ" then ---sleep else if button returned of result = "システム終了" then shut down else if gave up of result is true then ---(ダイアログを閉じる) end if end tell
finderのウインドウを整列するスクリプト。 -- tell application "Finder" activate set WindowList to every window set WindowNumber to count items of WindowList repeat with i from 1 to WindowNumber tell item i of WindowList set position to {5 * i, 20 + 20 * i} open end tell end repeat end tell
tell application "Finder" select file "世界地図について" of folder "世界地図コントロールパネル" of folder "Apple エクストラ" of folder "Applications (Mac OS 9)" of startup disk open selection end tell
on run set AppleScript's text item delimiters to ":" tell application "Finder" activate copy selection to x end tell repeat with i in x set Filelist to {i} my GetItem(i) my Arrange(Filelist) end repeat end run
on Arrange(wd) tell application "Finder" repeat with j in wd open j set a to (j as alias) as text set i to (count items of text items of a) - 1 set position of window of j to {5 * i, 20 + 20 * i}
end repeat end tell end Arrange
on GetItem(Target_F) tell application "Finder" set getItems to every folder in Target_F repeat with n in getItems set end of Filelist to n my GetItem(n) end repeat end tell end GetItem
197には致命的な欠陥がありました。 アプリケーション形式で保存すると、フォルダを選択することができない...(^^; これを解消するために、ドラッグ&ドロップで実行するように変えました。 また、フォルダが開きすぎるんで、フォルダを20個開いたらウインドウを閉じるようにしました。 --- global Filelist
on open (x) set AppleScript's text item delimiters to ":" repeat with i in x set Filelist to {i} my GetItem(i) my Arrange(Filelist) end repeat
end open
on Arrange(wd) set ct to 0 tell application "Finder" close every window repeat with j in wd open j set a to (j as alias) as text set i to (count items of text items of a) - 1 set position of window of j to {5 * i, 20 + 20 * i} set ct to ct + 1 if ct mod 20 = 0 then close every window end repeat close every window end tell end Arrange
on GetItem(Target_F) tell application "Finder" set getItems to every folder in Target_F repeat with n in getItems set end of Filelist to n my GetItem(n) end repeat end tell end GetItem
インストール&リスタートすると一発目はフリーズするかもしんない。 これはすでに「コンテクストメニュー機能拡張」が入っているのに インストーラが「Contextual Menu Extension」を入れてしまうため。 スペースバー起動で「Contextual Menu Extension」を外しましょう。
で、クリッカブルURL非対応のアプリでURLを選択し、右クリック (あるいはcontrol+クリック)すると、そのURLをアプリでどう処理するかを 選択できます。選択肢として表示させるアプリ一覧はApple Data Detectors コントロールパネルで編集可能。
on run set XMin to text returned of (display dialog "ウインドウの横幅の最小値を設定して下さい。" default answer XMin) set YMin to text returned of (display dialog "ウインドウの縦幅の最小値を設定して下さい。" default answer YMin) set XMAX to text returned of (display dialog "ウインドウの横幅の最大値を設定して下さい。" default answer XMAX) set YMax to text returned of (display dialog "ウインドウの下限を設定して下さい。" default answer YMax) end run
on open (x) tell application "Finder" set WL to every window end tell set AppleScript's text item delimiters to ":" repeat with i in x set Filelist to {i} my GetItem(i) my Arrange(Filelist) end repeat tell application "Finder" open WL end tell end open
on Arrange(wd) set ct to 0 tell application "Finder"
repeat with j in wd open j set a to (j as alias) as text set i to (count items of text items of a) - 1 set zoomed of window of j to true set bd to bounds of window of j set bdx to (item 3 of bd) - (item 1 of bd) set bdy to (item 4 of bd) - (item 2 of bd)
--下限の設定 if bdy + 20 + 20 * i < YMax then if bdy < YMin then set yy to YMin + 20 + 20 * i else set yy to bdy + 20 + 20 * i end if else set yy to YMax end if
if bdx + 5 * i < XMAX then if bdx < XMin then set xx to XMin + 5 * i else set xx to bdx + 5 * i end if else set xx to XMAX end if
set bounds of window of j to {5 * i, 20 + 20 * i, xx, yy} set ct to ct + 1 if ct mod 20 = 0 then close every window end repeat close every window end tell end Arrange
on GetItem(Target_F) tell application "Finder" set getItems to every folder in Target_F repeat with n in getItems set end of Filelist to n my GetItem(n) end repeat end tell end GetItem
--過去ログメニュー表示 tell application "iCab" set currenturl to URL of window 1 set AppleScript's text item delimiters to "/i/" set urllist to every text item of currenturl set currenturl to (item 1 of urllist & "/subback.html") as text OpenURL currenturl toWindow 0 end tell
--前10レス表示 tell application "iCab" set currenturl to URL of window 1 OpenURL (currenturl & "&ls=20") end tell
--前50レスを通常形式で表示 tell application "iCab" try set currenturl to URL of window 1 if currenturl contains "&ls=" then set AppleScript's text item delimiters to (text -1 thru -6 of currenturl) set urllist to every text item of currenturl set currenturl to (item 1 of urllist & item 2 of urllist) as text end if if currenturl contains "imode=true&" then set AppleScript's text item delimiters to "imode=true&" set urllist to every text item of currenturl set currenturl to (item 1 of urllist & item 2 of urllist) as text end if set currenturl to (currenturl & "&ls=50") as text OpenURL currenturl end try end tell
--レス1-50を通常形式で表示 tell application "iCab" try set currenturl to URL of window 1 if currenturl contains "&ls=" then set AppleScript's text item delimiters to (text -1 thru -6 of currenturl) set urllist to every text item of currenturl set currenturl to (item 1 of urllist & item 2 of urllist) as text end if if currenturl contains "imode=true&" then set AppleScript's text item delimiters to "imode=true&" set urllist to every text item of currenturl set currenturl to (item 1 of urllist & item 2 of urllist) as text end if set currenturl to (currenturl & "&st=1&to=50") as text OpenURL currenturl end try end tell
--レスxx-yyを通常形式で表示 tell application "iCab" try set currenturl to URL of window 1 if currenturl contains "&ls=" then set AppleScript's text item delimiters to (text -1 thru -6 of currenturl) set urllist to every text item of currenturl set currenturl to (item 1 of urllist & item 2 of urllist) as text end if if currenturl contains "imode=true&" then set AppleScript's text item delimiters to "imode=true&" set urllist to every text item of currenturl set currenturl to (item 1 of urllist & item 2 of urllist) as text end if try set xxyy to text returned of (display dialog "レス範囲を指定(xx-yy)" default answer "" default button "OK") set AppleScript's text item delimiters to "-" set xxyylist to every text item of xxyy set xx to (item 1 of xxyylist) as text set yy to (item 2 of xxyylist) as text set currenturl to (currenturl & "&st=" & xx & "&to=" & yy) as text OpenURL currenturl end try end try end tell
>213-215 さん 素晴らしいですね。 「レスxx-yyを通常形式で表示」を、IE用に移植してみました。 これ、むちゃくちゃ便利ですね。 --- tell application "Internet Explorer" set currenturl to item 1 of (GetWindowInfo (item 1 of (ListWindows))) if currenturl contains "&ls=" then set AppleScript's text item delimiters to (text -1 thru -6 of currenturl) set urllist to every text item of currenturl set currenturl to (item 1 of urllist & item 2 of urllist) as text end if try set xxyy to text returned of (display dialog "レス範囲を指定(xx-yy)" default answer "" default button "OK") set AppleScript's text item delimiters to "-" set xxyylist to every text item of xxyy set xx to (item 1 of xxyylist) as text set yy to (item 2 of xxyylist) as text set currenturl to (currenturl & "&st=" & xx & "&to=" & yy) as text OpenURL currenturl toWindow 0 end try end tell
>>215-216 改訂。1個目のend ifの後に if currenturl contains "&st=" then set AppleScript's text item delimiters to "&st=" set urllist to every text item of currenturl set currenturl to (item 1 of urllist) as text end if を入れれば再指定できるようになります。
--選択した語句を翻訳 tell application "iCab" tell window 1 set slword to selection set AppleScript's text item delimiters to " " set slword to every text item of slword set AppleScript's text item delimiters to "+" set slword2 to every text item of slword set slword to slword2 as text set hon to ("http://www.odn.ne.jp/cgi-bin/dictionary/dicindex.cgi?qt=" & slword & "&mode=EJ") OpenURL hon toWindow 0 end tell end tell
>>9さんのをちょっといじってネトモで韓日翻訳。 朴ってゴメンネ。 tell application "iCab" Activate set currenturl to URL of window 1 set hon to "http://www.netomo.com/cgi-bin/transkj.cgi?" OpenURL (hon & currenturl) toWindow 0 end tell
279とは別人です。 手元にネスケ6がないのだけど、最近のFizzillaだと tell application "Mozilla" set all_window to every window set uu to URL of (first item of all_window) display dialog uu end tell てな感じでウインドウのリストを得てURLも取得できるな。
tell application "Jedit3" activate tell document 1 replace "<A HREF={http://.[a-zA-Z0-9/.]}>{.+}</A>" to "\1 \2" in selection with grep end tell end tell
Script DebuggerのExplorerで調べました。 Class Windowは用語辞書に載ってるにもかかわらず、ASでは拾えない。 AEでもちょっと調べたけどダメっぽい。多分無理です。
ネスケ6は用語辞書にこんなこと書いてた、これが辞書か・・・(ーー alert application type class -- Most of the alerts will be sent to this application using yet unspecified AE interface. We need a few alert boxes: alert, confirm and notify. Any ideas on how to design this event? mailto:[email protected]. Iユd like to conform to the standard.
便乗質問させてください。 282さんのスクリプトで、 <A HREF= の大文字小文字を区別しないで置換するにはどうしたらよいのでしょうか? 一応 replace "<A HREF={http://.[a-zA-Z0-9/.]}>{.+}</A>" to "\1 \2" in selection with grep without case sensitive
tell application "Finder" try delete file "History.html" of folder "Explorer" of folder "初期設定" of folder "システムフォルダ" of startup disk empty trash on error beep --ここにエラー時の処理。 end try end tell
tell application "Finder" activate select file "イメージファイル.img" of folder "パス" of startup disk open selection select file "アプリの名前" of folder "パス" of startup disk open selection end tell
tell current application set surl to the clipboard as string end tell tell application "iCab" tell window 1 set AppleScript's text item delimiters to " " set lsurl to every text item of surl set AppleScript's text item delimiters to "+" set surl to lsurl as text set google to " http://www.google.com/search?num=30&hl=ja&safe=off&lr=&q=" OpenURL (google & surl) toWindow 0 end tell end tell
tell application "Finder" set aProcess to name of every process end tell set aList to choose from list aProcess with prompt ツ "終了するアプリケーションを選択:" OK button name "終了"
>>357 OSA MenuとかFinderPopに入れて使うつもりなんで、この場合はFinderを最前にできそうにないです…。 で、ageがわりに>>353で作ってたスクリプトでも書いてみようかと思うんですが、これが全然 おもしろくないしどこにでもありそうだし、しかもクソ長いっていう。 漏れ、厨っすか?やっぱり。ついでにまたお知恵を拝借できたらって下心もあるので、スレが 沈んでた時にでもなんか助言くださったり罵倒するなり放置して一言「age」なりしてくだされば。
起動中のプロセスを個別にか全部いっぺんに終了して、全部終了した時はついでにシステム終了もします。 文、省略されるだろうから興味なければ見なくてすむように後ろに書いときます。 ところでともだちがシステム終了の前に全アプリを終了しろっつって Command+Tab、Command+Q 繰り返してたんで全プロセス終了後システム終了ってしてみたんですが、コレって意味あるんですかね? あと、name of every processで当のアプレット拾っちゃった時のために if aName as text is not "アプレット名" て書いてみたんですけど、もうちょっとスマートな記述、 ないもんでしょうか。
tell application "Finder" set aProcess to name of every process end tell
set aList to choose from list aProcess with prompt ツ "終了するアプリケーションを選択:" cancel button name "全部終了" OK button name "終了" ツ with multiple selections allowed
if aList is not false then repeat with aName in aList try with timeout of 10 seconds quit application aName end timeout on error end try end repeat
else repeat with aName in aList if aName as text is not "アプレット名" then try with timeout of 10 seconds quit application aName end timeout on error end try end if end repeat
tell application "Finder" display dialog "コンピュータを今システム終了してよろしいですか?" as text buttons ツ {"キャンセル", "再起動", "システム終了"} default button 3 with icon 2
if button returned of result is "システム終了" then shut down else if button returned of result is "再起動" then restart end if end tell end if
tell application "Finder" activate tell folder "0" try set label index of folder "A" to 2 end try try set label index of folder "B" to 2 end try end tell end tell
レスが付かないので、風邪で寝込みながら自分で作ってみた。 (但し今更HyperTalkなり) on opencard global gStart,gEnd,gCount put 1 into gCount put the seconds into gStart end opencard
on Idle global gStart,gEnd,gCount put gStart+5 into gEnd get the seconds if it > gEnd then setdate gStart put gCount&"回目の巻き戻し" put gCount+1 into gCount else end if end Idle
>>450 これではアカンの??? tell application "Internet Explorer" Activate set i to 0 repeat while i = 0 OpenURL "http://www.yahoo.co.jp/" delay 1 end repeat end tell
久しぶりに来てみました。 >>474 --- tell application "Sound Scripting" set v to sound volume if v > 0 then set sound volume to 0 else set sound volume to 1 end if end tell --- です。
ちなみに、音量を初期設定フォルダにファイルとして保存するスクリプトと 保存された音量に復元するスクリプト↓ --音量を保存して無音化 --「起動項目フォルダ」に入れる set f to (((path to preferences folder) as text) & "Sound Volume preference") as text set ff to open for access file f with write permission tell application "Sound Scripting" set v to sound volume as string write v to ff set sound volume to 0 end tell close access file f beep
--音量を復元 set f to (((path to preferences folder) as text) & "Sound Volume preference") as text set ff to open for access file f tell application "Sound Scripting" set sound volume to read ff end tell close access file f beep
476って、あまりにも腐れスクリプトなんで書き直しました。 音量が1以上なら、現在のボリュームをスクリプトに保存して音量を0にし、 音量が0なら、スクリプトに保存された音量に復元するスクリプトです。 --- property vv : 7 tell application "Sound Scripting" set v to sound volume if v > 0 then set vv to v set sound volume to 0 else set sound volume to vv end if end tell
set theApp to choose file with prompt "select" of type "APPL" as text set AppleScript's text item delimiters to {":"} last text item of (theApp as text) tell theApp launch quit end tell
>>502 メーラには送らないけれど、 クリップボードにURLとタイトルを保存するものなら --- tell application "Internet Explorer" set a to "" repeat with xx in ListWindows set q to GetWindowInfo xx set a to a & item 2 of q & return set a to a & "<" & item 1 of q & ">" & return end repeat end tell set the clipboard to a ---
>>504 --- tell application "Netscape Communicator (tm)" set a to "" repeat with xx in list windows set q to get window info xx set a to a & item 2 of q & return set a to a & "<" & item 1 of q & ">" & return end repeat end tell set the clipboard to a --- でどうでしょう。 びみょーにソースが違う...
これ、FMでのURL自動取り込み、ネスケ変更できない? try tell application "Internet Explorer" set infolist to GetWindowInfo of -1 end tell
set urlinfo to first item of infolist set titleinfo to second item of infolist
tell application "ファイルメーカー Pro" set cell "adoresu" of current record of database "URL_locator.fmj" to urlinfo set cell "taitoru" of current record of database "URL_locator.fmj" to titleinfo end tell on error beep display dialog "Internet ExplorerでWebベージを開いてからもう一度スクリプト実行して下さい。" buttons {"OK"} default button "OK" with icon note end try
>>501 実は、そんな感じのスクリプトを、ここで聞く前に試したんですが無理でし た。 set a to (choose file with prompt "select") as string tell application a launch quit end tell こう書くと、Finderが終了してしまいますし、そもそも取得したパス上に あるハズのアプリケーションが起動しません。また、「はじめの1回は場所 を聞いてくるが、次回以降は聞いて来ない」方法は使いたく無いのです。 常に毎回アプリケーションの場所を聞いてくる様にしたいので。それから 前回の聞き方に対しては納得しました。申し訳ありませんでした。
tell application "Netscape Communicator (tm)" set a to list windows set infolist to get window info item 1 of a end tell
set urlinfo to first item of infolist set titleinfo to second item of infolist
tell application "ファイルメーカー Pro" set cell "adoresu" of current record of database "URL_locator.fmj" to urlinfo set cell "taitoru" of current record of database "URL_locator.fmj" to titleinfo end tell on error beep display dialog "Internet ExplorerでWebベージを開いてからもう一度スクリプト実行して下さい。" buttons {"OK"} default button "OK" with icon note end try --- で恐らく動作すると思います。
tell application "Finder" activate set SelectWindow to {"application", "file"} choose from list SelectWindow with prompt "select mode:" set res to result if res is in "application" then set theApp to (choose file with prompt "select app: ") as string tell application theApp launch quit end tell end if end tell
tell application "Finder" activate set SelectWindow to {"application", "file"} choose from list SelectWindow with prompt "select mode:" set res to result end tell
if res is in "application" then activate set theApp to (choose file with prompt "select app: ") as string tell application theApp launch quit end tell end if
--- set theList to {} tell application "Internet Explorer" set t to (GetSource) as text end tell set AppleScript's text item delimiters to "br>" set s to text items of t set AppleScript's text item delimiters to "<" repeat with i from 1 to count items of s set x to item i of s if x contains "ttp" then if text 1 thru 3 of x is "ttp" then
set x to item 1 of text items of x set the end of theList to (("h" & x) as text) end if end if end repeat
set theURL to choose from list theList tell application "Internet Explorer" OpenURL theURL toWindow 0 end tell
改良版。 ローカルに保存し、ttpで始まる行を補完してリンクタグを付ける加工をして その加工したファイルをIEで開きます。 --- tell application "Internet Explorer" set a to GetWindowInfo -1
set a to item 1 of a OpenURL a to file "TargetURL.temp"
set IEPath to path to application "Internet Explorer" as text set AppleScript's text item delimiters to "Internet Explorer" set IEPath to item 1 of text items of IEPath set thefile to (IEPath & "TargetURL.temp")
set fh to open for access file thefile set ct to read fh close access fh end tell set theList to {}
set AppleScript's text item delimiters to "br>" set s to text items of ct set AppleScript's text item delimiters to "<" repeat with i from 1 to count items of s set x to item i of s if x contains "ttp" then if text 1 thru 3 of x is "ttp" then set theURL to item 1 of text items of (("h" & x)) set the item i of s to "<a href=\"" & theURL & "\">" & theURL & "</a><" end if end if end repeat set AppleScript's text item delimiters to "br>"
set fh to open for access file thefile with write permission write (s as text) to fh close access fh
tell application "Internet Explorer" ShowFile file thefile end tell
tell application "Finder" activate select file " AirMac" of folder "アップルメニュー" of folder "システムフォルダ" of startup disk open selection select file "Netscape Communicat" of folder "internet" of folder "アップルメニュー" of folder "システムフォルダ" of startup disk open selection end tell
Mac OS X(10.1.1)のAppleScript1.7にてファイルネームの答え合わせが出来ません。 例えば、拡張子rmが付いているファイルにfile type"PNRA"とcreator type"PNst"を setしたいのですが、うまくいきません。 例えば以下のドロップレットです。
on open Drop_List repeat with Obj in Drop_List tell application "Finder" set Obj_Name to name of Obj set Check_Name to characters -1 thru -2 of Obj_Name if Check_Name = "rm" then set file type of Obj to "PNRA" set creator type of Obj to "PNst" else activate display dialog "RealファイルをDropしてください" end if end tell end repeat end open
Mac OS 9.2.1だと問題ありません。 また、ドロップレットにせずにrmファイルを直接指定してやる方法で アプレットにすれば問題なしなんです。 使い物にならないですけど。 なぜ Check_Name = "rm" に失敗するのでしょうか? Check_Nameをdisplay dialogすると、rm を表示してます。
>>544 うおぉぉぉぉ!!ありがとうございます。 すみません、間違えていました。 5行目の下に実は、 set Check_Name to Check_Name as text という行が抜けていました。これだと9.2.1では動くのですが、Mac OS Xではダメです。 でも、charactersをtextに変えるとMac OS Xでも無事に動きました。 本当にありがとうございました。
on open Drop_List repeat with Obj in Drop_List if (Obj as text) ends with ":" then display dialog "folder" else display dialog "file" end if end repeat end open
Mac OS X(10.1.1) AppleScript 1.7では、何をドロップしても"file"になります。 前件と同様の理由でしょうか。
--選択したURLを開く IE用 tell application "Internet Explorer" set surl to selected text if surl contains "ttp://" then set AppleScript's text item delimiters to "ttp://" set surl to text item 2 of surl end if OpenURL surl toWindow 0 end tell
--選択したURLを開く iCab用 tell application "iCab" tell window 1 set surl to selection if surl contains "ttp://" then set AppleScript's text item delimiters to "ttp://" set surl to text item 2 of surl end if OpenURL surl toWindow 0 end tell end tell
>>549 遅レスですが‥ 3行めの Obj as text は string クラスの unicode text みたいです だから比較する相手の ":" も as unicode text してやると正常に動作します 直接クラスがえしてもいいんですが まず変数に入れておく例を書いときます
property text_item : (":" as Unicode text) on open Drop_List repeat with Obj in Drop_List if (Obj as text) ends with text_item then display dialog "folder" else display dialog "file" end if end repeat end open
いま AppleScriptStudio でいろいろ遊んでます チュートリアルの Watson がまともに動いてくれなくて いきなりつまずきましたが 文字列の比較のところに as Unicode text を かましてやると動くようになりました どうも日本語環境特有の問題のようです
fetch4.01のFetch Example Scriptsに下のようなサンプルがありましたが、 ドロップではなくダブルクリックなど起動することでファイルをアップさせるように するには、どこをどうかえればいいですか?
property gDesturl : ""
on specify_destination() set dialog_reply to display dialog "Enter Destination URL in format:" & return & ツ " ftp://[user[:password]@]host/path" & return & ツ "Where [...] is optional." default answer gDesturl if button returned of dialog_reply = "OK" then set gDesturl to text returned of dialog_reply end if end specify_destination
on open doc if gDesturl = "" then specify_destination() end if if gDesturl ュ "" then
with timeout of 60000 seconds tell application "Fetch 4.0.1" put into url gDesturl item doc -- quit end tell end timeout end if end open
>>585 Fetch 使ってないんで検証できませんが多分これで大丈夫 ダブルクリックするとアップするファイルを尋ねてくるので教えてやって下さい sample から on open ~ end open の部分をそのまま付け足しておくと ドロップレットとしても使えるので好みでどうぞ
property gDesturl : ""
on specify_destination() set dialog_reply to display dialog "Enter Destination URL in format:" & return & ツ " ftp://[user[:password]@]host/path" & return & ツ "Where [...] is optional." default answer gDesturl if button returned of dialog_reply = "OK" then set gDesturl to text returned of dialog_reply end if end specify_destination
set up_file to choose file if gDesturl = "" then specify_destination() end if if gDesturl ュ "" then with timeout of 60000 seconds tell application "Fetch 4.0.1" put into url gDesturl item up_file end tell end timeout end if
if gDesturl = "" then initialize() end if repeat set initialize_info to display dialog "destination : " & gDesturl & return & "file path : " & (up_file as text) ツ buttons {"reset", "OK"} default button 2 if button returned of initialize_info = "reset" then initialize() end if if button returned of initialize_info = "OK" then exit repeat end repeat with timeout of 60000 seconds tell application "Fetch 4.0.1" put into url gDesturl item up_file end tell end timeout
on specify_destination() set dialog_reply to display dialog "Enter Destination URL in format:" & return & ツ " ftp://[user[:password]@]host/path" & return & ツ "Where [...] is optional." default answer gDesturl if button returned of dialog_reply = "OK" then set gDesturl to text returned of dialog_reply end if end specify_destination
on initialize() set up_file to choose file specify_destination() end initialize
>>592 確認のダイアログを出さない方がいいのなら repeat ~ end repeat をごっそり削除するだけでいいです でもこれだと将来、変更の必要がでたときに対応できませんよ
というわけで 自動的にアップもするし変更も出来るパターンもつくりました repeat ~ end repeat の部分を下と入れ替えて下さい
repeat set initialize_info to display dialog "destination : " & gDesturl & return & "file path : " & (up_file as text) ツ buttons {"reset", "OK"} default button 2 giving up after 5 if button returned of initialize_info = "reset" then initialize() end if if gave up of initialize_info is true then exit repeat if button returned of initialize_info = "OK" then exit repeat end repeat
>>593 OS X でコメントを書き換えるスクリプト ドロップレット、ScriptMenu 両方で使えます ScriptMenu のほうは Finder で選択後、メニューから実行 フォルダはその中のファイルもすべて さらにその中にフォルダがある場合もその中まで徹底的に書き換えます
main()
on open drop_items tell application "Finder" set selection to drop_items as list end tell main() end open
on main() with timeout of 600 seconds tell application "Finder" activate set user_reply to display dialog " (´-`).。oO(コメント‥)" default answer "NO COMMENT" set text_reply to text returned of user_reply my set_comment(selection, text_reply) end tell end timeout end main
on set_comment(item_list, c_words) tell application "Finder" repeat with i in item_list if class of i is document file then set comment of i to c_words end if if class of i is folder then my set_comment(items of i, c_words) end if end repeat end tell end set_comment
property google_url : "http://www.google.com/search?q=cache:" tell application "Internet Explorer" Activate set the_url to 1st item of (GetWindowInfo -1) set the_url to google_url & the_url OpenURL the_url toWindow 0 end tell
set proxylist to alias "Macintosh HD:proxy list" open for access proxylist set plist to read proxylist using delimiter return close access proxylist set newproxy to (choose from list (plist)) tell application "ICScriptor" SetICPreference HTTP proxy host to newproxy end tell
tell application "ICScriptor" if (GetICPreference Web helper) is {fileCreator:"iCAB", fileName:"iCab"} then SetICPreference Web helper to {fileCreator:"MSIE", fileName:"Internet Explorer"} (display dialog "標準ブラウザがIEに変わりました" giving up after 1) else if (GetICPreference Web helper) is {fileCreator:"MSIE", fileName:"Internet Explorer"} then SetICPreference Web helper to {fileCreator:"iCAB", fileName:"iCab"} (display dialog "標準ブラウザがiCabに変わりました" giving up after 1) end if quit end tell
tell application "iTunes" set inf to current track set a to name of inf set b to genre of inf set c to kind of inf set d to comment of inf set e to address of inf end tell display dialog "[Station] " & a & return & "[Genre] " & b & return & "[Kind] " & c & return & "[Comment] " & d & return & "[url] " & e as string
tell application "Internet Explorer" Activate set i to 0 repeat while i < 10 OpenURL "http://www.yahoo.co.jp/" + i delay 1 i = i + 1 set t to (GetSource) as text tell application "Jedit3" tell document 1 insert "######" at beginning of document 1 insert t at selection end tell end tell end repeat end tell
set myRepeatTime to text returned of (display dialog "付け加える回数" default answer "10") theAddText(myRepeatTime) on theAddText(myRepeatTime) set myOrigText to text returned of (display dialog "最初の文字列" default answer "663は") set myRepeatText to text returned of (display dialog "付け加える文字列" default answer "神!") set {add, orig, rep} to {"", "myOrgText", ""} repeat myRepeatTime times set {add, orig, rep} to {add & myOrigText & rep & return, myOrigText, rep & myRepeatText} end repeat add end theAddText display dialog result
tell application "iTunes" tell library playlist 1 set n to number of tracks repeat with i from 1 to n set artistStr to (artist of track i) as text set albumStr to (album of track i) as text set orgFile to location of track i my moveMusicFile(orgFile, artistStr, albumStr) end repeat end tell end tell
(* orgFile を musicLibPath:artistStr:albumStrに移動 *) to moveMusicFile(orgFile, artistStr, albumStr) tell application "Finder" if my bytelength(artistStr) > 31 then my extract(artistStr, 31) if my bytelength(albumStr) > 31 then my extract(albumStr, 31) set artistPath to musicLibPath & artistStr & ":" if not (folder artistPath exists) then make new folder at folder musicLibPath with properties {name:artistStr} end if set albumPath to artistPath & albumStr & ":" if not (folder albumPath exists) then make new folder at folder artistPath with properties {name:albumStr} end if move orgFile to folder albumPath end tell end moveMusicFile
to extract(str, bytelen) set b to "" repeat with i from 1 to bytelen set c to b & (character i of str) if my bytelength(c) > bytelen then exit repeat set b to c end repeat return b end extract
(* 文字列のbyte長を得る。なぜ標準でできない! *) to bytelength(theStr) set the clipboard to theStr item 2 of item 1 of (clipboard info for strings) end bytelength
最後の計算結果の少数第二位を四捨五入して、少数第一位までの表記にしたいんですけど、どうすればよろしいでしょーか -------------------------- on hndl() display dialog "記録媒体の容量と価格を以下の書式に従って入力し、容量の単位をツ 選択してください。" & return & "例:40/10000 (容量[GB]/円)" default answer ツ "容量/価格" buttons {"キャンセル", "単位MB", "単位GB"} default button 3 with icon 1 set rst to result set br to (button returned of rst) set tr to (text returned of rst) set AppleScript's text item delimiters to "/" text items of tr set rst to result set siz to item 1 of rst as number set yen to item 2 of rst as number if br is "単位GB" then set byt to ((siz * 1000) * 1000) * 1000 set gb to ((byt / 1024) / 1024) / 1024 set ans to (yen / gb) display dialog "1GB単価 : " & ans & return & "(" & gb & ")" buttons {"Reset", "OK"} ツ default button 1 if button returned of result is "Reset" then hndl() end if else if br is "単位MB" then set byt to ((siz * 1000) * 1000) set mb to ((byt / 1024) / 1024) set ans to (yen / mb) display dialog "1MB単価 : " & ans & return & "(" & mb & ")" buttons {"Reset", "OK"} ツ default button 1 if button returned of result is "Reset" then hndl() end if end if
on run choose file with prompt "ThreadOgre の結果ファイルを選んで下さい。" set readFile to result open for access readFile read readFile set readData to result set lastDelim to AppleScript's text item delimiters set AppleScript's text item delimiters to " " set dataList to text items of readData set wantData to chushutsu(dataList) as string set AppleScript's text item delimiters to lastDelim close access readFile tell application "Finder" make file with properties {name:"LVUPresult.txt", creator type:"YoED"} set makeFile to result open for access makeFile with write permission write wantData to makeFile close access makeFile end tell end run
on chushutsu(dataList) set i to 1 set wantData to "" repeat try set pText to item i of dataList on error exit repeat end try try set topLineQst to text from character 1 to character 42 of pText as string on error end try try set topLineAns to "<TR><TD>体力(HP)</TD><TD><SPAN class=\"even\">" as string if topLineQst = topLineAns then set wantData to wantData & pText & return log "wantData = " & wantData end if on error end try set i to i + 1 end repeat return wantData end chushutsu
>>678 整数への四捨五入は「round」でちかい事ができる。OS9.1以降ならround as taught in schoolで。 小数点以下第一位を求めるなら単純に十倍して丸めてから1/10に」すればいいんじゃない? set ans to (round ((yen / gb) * 10) as taught in school) / 10
コレ生まれて初めて作ったASです。(コレもスレ違いか、、) tell application "Finder" activate open folder "Temporary Files" of folder "Explorer" of folder "初期設定" of folder "システムフォルダ" of startup disk end tell
君は下から8行目でset wantData to wantData & pText & returnとやってるよ。 だから、wantDataにはpTextまるまる入ってるよね? そのptextは、item i of dataListなので、改行で区切ったアイテムがそうじゃん。 つーことで、欲しいデータを書けば、取り出し方を達人の方々が教えてくれるかも。
あと、前半でなぜいちいちresultってゆーふーに2行に分けて書くの? choose file with prompt "ThreadOgre の結果ファイルを選んで下さい。" set readFile to result ↓ set readFile to choose file with prompt "ThreadOgre の結果ファイルを選んで下さい。"
read readFile set readData to result ↓ set readData to read readFile
よかったね、四捨五入できて。漏れなんかより>>685さんが抜けてるぞ! デフォルトは{""}ですゴメソ。setすると再起動するまでそのままなんだと。 んで、他のスクリプトにまで影響するのでやっかいなんだと。 例えばこんなスクリプトを書いてるとするじゃん。 set alist to {"私は", "ど素人", "です"} alist as text -->"私はど素人です" ←普通はこうなるよね
君のスクリプトを実行した後だと、 set alist to {"私は", "ど素人", "です"} alist as text -->"私は/ど素人/です" ←こうなっちゃうじゃん
だから、使った物は片づけろってこった。 最初にset |変数| to AppleScript's text item delimiters とやっとく。 んで、変えたりしてごにょごにょとやる。 最後にset AppleScript's text item delimiters to |変数| とやる。 >>679さんがちゃんとやってるので参考にしてみてちょ。
なんで2行にわけてるか、それは知らないからです。 『AppleScriptリファレンス』と『AppleScriptでゼンマイびゅんびゅん!!』という本の サンプルスクリプトを見つつ書いているのですが、そのような略した書き方は知りませんでした。 今日はじめて if (条件)then (実行命令)などと end if を略した形を知ったばかりです。 プログラムの簡略化はまったく考えてなかったので、そのような書き方があったのかと感心してます。 どうもありがとうございます。
on chushutsu(dataList) set wantData to "" set topLineAns to "<TR><TD>体力(HP)</TD><TD><SPAN class=\"even\">" repeat with i from 1 to (count of dataList) set pText to item i of dataList if (count characters in pText) > 42 then set topLineQst to text from character 1 to character 42 of pText if topLineQst = topLineAns then set wantData to wantData & pText & return end if end if end repeat return wantData end chushutsu
--あと、よけいなお世話だけど open for access は --try 構文で挟んどいた方がいいと思うよ、というわけで実行部分
on run set readFile to choose file with prompt "ThreadOgre の結果ファイルを選んで下さい。" set readData to open for access readFile try set dataList to read readData as string using delimiter {ASCII character 10} end try close access readFile set wantData to chushutsu(dataList) tell application "Finder" set makeFile to make file with properties {name:"LVUPresult.txt", creator type:"YoED"} end tell set h_file to open for access makeFile as alias with write permission try write wantData to h_file end try close access h_file end run
set theStartStr to "<TR><TD>体力(HP)</TD><TD><SPAN class=\"even\">" set theFile to choose file with prompt "ThreadOgre の結果ファイルを選んで下さい。" set kaigyo0 to ASCII character 13 --読み込みファイルの改行コード set kaigyo1 to ASCII character 13 --書き出しファイルの改行コード set fh to open for access theFile set buf to "" (*読み込み*) repeat try set aLine to read fh before kaigyo0 on error exit repeat end try if aLine starts with theStartStr then set buf to buf & aLine & kaigyo1 end repeat close access fh
(*結果の書き出し*) set newFile to choose file name default name "LVUPresult.txt" --Mac OS 9.0以前では「choose file name」→「new file」 try set fh to open for access newFile with write permission write buf to fh on error close access fh end try close access fh
set kaigyo0 to ASCII character 13 --読み込みファイルの改行コード は set kaigyo0 to ASCII character 10 --読み込みファイルの改行コード にしてください。 わたしの環境では改行コードがCRだったので(ダウンロード環境のせい)、 それで作ってて最後に直そうとしてわすれてた。
on open dropItems tell application "Finder" repeat with obj in dropItems --〜 objを操作する命令 〜 end repeat --〜 ファイル単位でくり返さない命令はここに 〜 end tell end open
701さんのはオーケーでしたが、699さんの方は上手くいきませんでした。 set dataList to read readData as string using delimiter {ASCII character 10}のところで、 エラーが出て、読み込まないまま処理がつづいてしまうようです。 tryを取り外して実行させてみると、「メモリが足りません」とエラー表示。 ドロップレットのメモリサイズを8192Kにしてもダメでした。
on open drp tell application "Finder" if cpy is "コピー" then set icn to icon of item 1 of drp set cpy to "ペースト" set name of (path to me) to cpy else if cpy is "ペースト" then repeat with x in drp set icon of x to icn end repeat set cpy to "コピー" set name of (path to me) to cpy end if end tell end open
tell application "Finder" set cpy to "コピー" set name of (path to me) to cpy end tell ----------------------------- 1.名前が"コピー"の時にドロップするとアイコンをコピーし、名前が"ペースト"になります。 2.名前が"ペースト"の時にドロップすると1.のアイコンをペーストし、"コピー"に戻ります。 注) いったんコピーしてまうとペーストしか出来なくなりますが、 普通にダブルクリックして起動すると"コピー"に戻せます。
tell application "Finder" repeat 10 times open (folders of entire contents of system folder whose name contains "A") close (folders of entire contents of system folder whose name contains "A") end repeat end tell
tell application "Finder" activate select file "仕事用のエイリアス" of folder "HD" of startup disk open selection delay 1 close container window of disk "仕事用" end tell tell application "起動ディスク" activate delay 2 set startup disk alias to alias "仕事用:" end tell tell application "Finder" restart end tell
(1) 既存のテキストと書き込みたいテキストを書き込む tell application "Finder" set sampleFile to file "sample.txt" of desktop --書き込みたいファイル set kakikoText to "ABC" --書き込みたいテキスト set sampleFile to open for access sampleFile with write permission --書き込み可にする set sampleText to read sampleFile --テキスト内容を確保 try write sampleText & kakikoText to sampleFile --テキストに元のものと書き込みたいものを書く close access sampleFile --ふつうに閉じる on error close access sampleFile --エラーが出ても閉じる end try end tell
(2) 書き込みたいテキストを書き込む tell application "Finder" set sampleFile to file "sample.txt" of desktop --書き込みたいファイル set kakikoText to "ABC" --書き込みたいテキスト set sampleFile to open for access sampleFile with write permission --書き込み可にする try write kakikoText to sampleFile --テキストに書き込みたいものを書く close access sampleFile --ふつうに閉じる on error close access sampleFile --エラーが出ても閉じる end try end tell
(2) のものだと、テキストの最初に上書きされてしまいます。
(3) 既存のテキストを読んでおいて、テキストを書き込む tell application "Finder" set sampleFile to file "sample.txt" of desktop --書き込みたいファイル set kakikoText to "ABC" --書き込みたいテキスト set sampleFile to open for access sampleFile with write permission --書き込み可にする read sampleFile --テキストをとりあえず読む try write kakikoText to sampleFile --テキストに書き込みたいものを書く close access sampleFile --ふつうに閉じる on error close access sampleFile --エラーが出ても閉じる end try end tell
set sampleFile to open for access sampleFile with write permission --書き込み可にする try set eofPos to get eof sampleFile write kakikoText starting at ( eofPos +1 ) to sampleFile close access sampleFile 以下同文。
tell application "Finder" --フォルダリスト作成 set launchItems to every item of (path to (launcher items folder)) as list set launchItemsList to "" set lastDelim to AppleScript's text item delimiters set AppleScript's text item delimiters to ":" repeat with launchItem in launchItems set launchItems to last text item of (launchItem as text) set launchItemsList to launchItemsList & launchItems as list end repeat set AppleScript's text item delimiters to lastDelim --フォルダリスト選択 set selectItem to choose from list launchItemsList default items (first text item of launchItemsList) try open file (selectItem as text) of (path to (launcher items folder)) on error end try end tell
set current_folder to choose folder set this_name to choose from list (list folder current_folder without invisibles) set this_path to (current_folder as string) & this_name tell application "Finder" activate try open item (this_path) on error error_message display dialog error_message buttons {"OK"} default button 1 end try end tell
open を try で挟むのはそれでいいんじゃないの キャンセル押したらそのまま終了するだけだし 開けない場合は Finder がエラー表示してくれる
ええと、AppleScript1.6 だとこんな感じで良いスか --フォルダリスト作成 set launchItems to list folder (path to (launcher items folder)) without invisibles --フォルダリスト選択 set selectItem to choose from list launchItems default items (first text item of launchItems) if selectItem is not false then tell application "Finder" to open file (selectItem as text) of (path to (launcher items folder)) end if
tell application "Internet Explorer" set The_URL to selected text if The_URL starts with "http" then set The_URL to The_URL else if The_URL starts with "ttp" then set The_URL to "h" & The_URL else if The_URL starts with "tp" then set The_URL to "ht" & The_URL else set The_URL to "http://" & The_URL end if set A_Window to OpenURL The_URL toWindow 0 Activate A_Window end tell
起動しているアプリのメモリ変更をしたい時に使ってるものです。 参考「アップルスクリプトでゼンマイびゅんびゅん」 まだまだ初心者レベルなんで、突っ込み所があったら 指摘して下さい。 tell application "Finder" set theApp to every application process choose from list theApp with prompt "どのアプリのメモリを変更する?" set res to result set memApp to (file of item 1 of res) set memNum to total partition size of memApp set memNum to (memNum div 1024) display dialog name of memApp & "のメモリ割当て量は?" default answer memNum set memNum to text returned of result end tell set memApptem to name of memApp try tell application memApptem activate quit end tell quit end try delay 3 tell application "Finder" activate set total partition size of memApp to (memNum as number) display dialog "メモリ変更したよん" open memApp end tell
to get_free(theItem) /* theItem : reference of file , folder etc. */ tell application "Finder" set freesize to free space of (disk of theItem) end tell return freesize end get_free
ドロップレットで... 1.existsを使ってFolderに同じ名前があったら上書きを尋ねる。 YES→move added_items to aFolder with replacing NO→止める
2.set freesize to free space of (disk of theItem)と If で、 ディスクの方の容量が特定の容量以下になったら display dialogで「何メガ以下です」みたいな警告を 発して止める。容量があればmove added_items to aFolder
and や or でのオペランドは2つまでじゃないですよね? 3つ以上使っても動いているようですが、そういう場合の簡潔な書き方を教えてください。 10個か20個、いや100個くらいやりたいので膨大な量になります。
--例 set aNumber to text returned of (display dialog "1〜10の好きな数字をどうぞ" default answer "") if aNumber = "2" or aNumber = "5" or aNumber = "9" display dialog "大当たり" else display dialog "残念はずれ" end
こんな感じのを、行数を短くする為に if aNumber = ("2" or "5" or "9") みたいに書きたいのです。方法というか書き方はありますか?
set aNumber to text returned of (display dialog "1〜10の好きな数字をどうぞ" default answer "") set kotaearu to 0 set atari to {2, 5, 9} repeat set kotaearu to kotaearu + 1 if aNumber = (item kotaearu of atari) as string then display dialog "大当たり" exit repeat else if kotaearu = 3 then display dialog "残念はずれ" exit repeat end if end repeat
set aNumber to text returned of (display dialog "1〜10の好きな数字をどうぞ" default answer "") as number if {2, 5, 9} contains aNumber then display dialog "大当たり" else display dialog "残念はずれ" end if
リスト内の要素にマッチングする時はcontainsを使うと楽できます。 クラスがあってないとハズレになるので注意(cf.1行目のas number
2行目を「if aNumber is in {2, 5, 9} then」とする書き方もあって、 こちらだと771に近い感じっす。
set orgFile to choose file of type {"MPEG3", "MPEG"} set dstFile to choose file name default name "test.aif" tell application "QuickTime Player" set theMovie to open orgFile export theMovie to dstFile as AIFF end tell
いろいろ手を抜いてるけど、骨組みだけはこんな感じ。 Mac OS 9.0まではchoose file name→new file
>>806 Finder に起動中の process を尋ねて目的のものがあるか比較する というのでどうでしょう
on launchFlag(app_name) set launch_flag to false tell application "Finder" set app_list to every process that file type is "APPL" if app_list contains {process app_name} then set launch_flag to true end tell return launch_flag end launchFlag
app_name が起動中なら true を、違えば false を返します
--例:IE の場合 set app_name to "Internet Explorer" launchFlag(app_name)
tell application "Finder" repeat with i from 1 to 3 set TheFile to (path to desktop folder as string) & "file" & i as alias set TheFolder to (path to desktop folder as string) & "folder" & i as alias move TheFile to TheFolder end repeat end tell
QuickeysのScriptingToolsの中にAppleEventって項目があって、 そこで設定したらいいと思うんだけど、AppleEventのダイレクトパラメータの 階層が深くなると、どうやって設定していいかわからないんです。 REALBasicとかだといくらでも階層を深くしていけるんですが、 Quickeysで階層を深くしていくにはどうしたらいいんでしょうか? AppleScriptなら812で書いたような tell application "QuarkXPress3.3" tell print setup set printer type to "OKI MicroLine" end tell end tell とするだけなんですが・・・
>>817 もう夜も遅いので検証してないが‥ そのスクリプトだとコンパイル時に存在していないオブジェクト ーこの場合はフォルダ を as alias することになるから無理なんじゃないか? フォルダをつくるのはたぶん Finder の make 命令使うんでしょ>816 だったら as alias しないでクラスは Finder の参照のまま 処理すればいいと思う
tell application "Finder" try if text returned of (display dialog "password:" default answer "" buttons "OK") is not "xxxxxx" then shut down on error shut down end try end tell
set SYSpath to path to system folder as string set cp to SYSpath & "クリップボード" set the clipboard to "こんにちは!" tell application "Finder" activate select file cp open selection delay 1 close clipboard end tell
set ABC to choose file set Write_Data to the clipboard set Open_Text to open for access ABC with write permission try set eof Open_Text to 0 write Write_Data to Open_Text close access Open_Text on error close access Open_Text end try
property ABC : "" -- if ABC = "" then set ABC to choose file set Write_Data to the clipboard set Open_Text to open for access ABC with write permission try set eof Open_Text to 0 write Write_Data to Open_Text close access Open_Text on error close access Open_Text end try
ただ、Filemakerでスクリプ記述欄で実行(OK押します)しますと write Write_Data to Open_Text行のWrite_Dataの部分が選択されて 「"end of line,etc."と書くべきところに"identifier"と書かれています。 (エラー-2741).」とエラーが返ってくるんですが、なぜでしょう...??
まず、>>873のヤシをScriptEditerで保存する。実際に実行もしてみる。 つぎに、ファイルメーカーの例の場所に以下を記述する。 property Cur_Script : "" if Cur_Script = "" then set Cur_Script to choose file run script Copy_Script
>>853 禿げしく亀ですが、 Internet Explorer用で作ってみますた。 java scriptを使ってるのでjava scriptはonで。 Script Editerに以下をコピペし、フォーマットを"アプリケーション"で保存すること。 その時「実行後、自動的に終了しない」のチェックを必ず入れること。
global Target_Window tell application "Internet Explorer" to set Target_Window to first item of (ListWindows) on idle tell application "Internet Explorer" do script "javascript:location.reload(true)" window Target_Window end tell return 180 end idle
tell application "Finder" activate set FileMOV to (choose file with prompt "movファイルを選択してください") set FileMP3 to (choose file with prompt "mp3ファイルを選択してください") end tell tell application "QuickTime Player" activate end tell
tell application "Finder" activate set FileMOV to (choose file with prompt "movファイルを選択してください") set FileMP3 to (choose file with prompt "mp3ファイルを選択してください") end tell
tell application "QuickTime Player" activate open FileMOV open FileMP3 select all FileMP3 copy FileMP3 <-この部分でエラーがでます。全てを選択してコピーしたいのですがどうすればいいでしょうか add FileMOV with scaled end tell
>890 漏れもあんまし詳しくないんだけど、多分これで動くはず。 確認できる環境じゃないんで動かなかったらごめん。 set FileMOV to choose file with prompt "movファイルを選択してください" set FileMP3 to choose file with prompt "mp3ファイルを選択してください" tell application "QuickTime Player" activate open FileMP3 select all FileMP3 copy movie 1 open FileMOV add movie 1 with scaled end tell
save: Save a movie save reference -- the movie to save [in alias] -- the file in which to save the movie [as self contained] -- the desired type of the file
tell application "QuickTime Player" launch activate stop every movie close every movie saving no
open (choose file with prompt "mp3ファイルを選択") tell movie 1 select all copy close end tell
open (choose file with prompt "movファイルを選択") tell movie 1 set MovFile to the name add with scaled save in file (MovFile & "_new") as self contained end tell
tell application "Finder" activate display dialog "最近どうよ?" buttons {"はい", "いいえ"} default button 1 set User_Answer to button returned of result if User_Answer is "はい" then --これで処理は終わる else if User_Answer is "いいえ" then --また「最近どうよ」に戻りたい end if end tell
repeat display dialog "最近どうよ?" buttons {"はい", "いいえ"} default button 1 set User_Answer to button returned of result if User_Answer is "はい" then exit repeat end if end repeat
set i to 0 repeat set i to i + 1 display dialog "羊が" & i & "匹" buttons {"もう寝る"} default button 1 giving up after 2 if button returned of result is "もう寝る" then exit repeat end if end repeat
on GetYes() tell application "Finder" activate display dialog "最近どうよ?" buttons {"はい", "いいえ"} default button 1 set User_Answer to button returned of result if User_Answer is "はい" then return else if User_Answer is "いいえ" then my GetYes() end if end tell end GetYes
on open fileList repeat with oneFile in fileList set allInfo to info for oneFile set isFolder to allInfo's folder set fileName to nameFromPath of (oneFile as string) given isFolder:isFolder if fileName is not "" then if isFolder then display dialog "残念ながらフォルダは変換できません。" buttons {"OK"} default button 1 else if allInfo's file type is "TEXT" then tell application "Jedit4" open oneFile save document 1 kanji type Euc lf type unix close document 1 end tell else (以下略)
save document 1 kanji type Euc lf type unix as Jedit4 ですと、最初にTextEditなど違うアプリでファイルが開いてしまうので tell application "Jedit4" open oneFile ここでエラーが出てしまいました。(私だけかな?)
さらに踏み込んで、 自動判断で接続していないときは接続、接続しているときは切断、というスクリプト。 なおConnectStateの値は、0が接続されていない状態、1が接続作業中、2が接続中。 if (ConnectState) is 1 then〜end ifの4行は自動でブラウザを立ち上げるときに きちんと接続が完了してから立ち上げるようにするための記述なので、省いてもよい。
tell application "フレッツ接続ツール" if (ConnectState) is 0 then considering application responses Connect end considering if (ConnectState) is 1 then repeat until (ConnectState) is not 1 end repeat end if else if (ConnectState) is 2 then considering application responses Disconnect end considering if (ConnectState) is 1 then repeat until (ConnectState) is not 1 end repeat end if if (ConnectState) is 0 then quit end if end tell
set source_folder to ((path to preferences) as text) & "Explorer:Temporary Files:" tell application "Finder" set file_list to every item of folder source_folder if file_list is {} then activate display dialog "ありませんでした" giving up after 2 else duplicate file_list to desktop end if end tell
on open drp --串リストのファイルをドロップして登録に変更 set proxylist to drp display dialog "登録しました..." buttons {"確認"} default button 1 giving up after 1 end open
open for access proxylist set plist to read proxylist using delimiter return set plist to reverse of plist --後から追加したモノが上に来るように変更 close access proxylist set newproxy to (choose from list (plist) with empty selection allowed) if newproxy is {} then --未選択でOKにするとプロキシーを解除できるに変更 tell application "ICScriptor" SetICPreference use HTTP proxy without to quit end tell else tell application "ICScriptor" SetICPreference HTTP proxy host to newproxy SetICPreference use HTTP proxy with to quit end tell end if
try tell application "Finder" open cmi end tell on error set cmi to choose file with prompt "\"Copy My IP\"はどこですか?" tell application "Finder" open cmi end tell end try
set crip to the clipboard as "TEXT" if tmpip is "" then set tmpip to crip set tmpdt to current date display dialog "- 初期登録 -" & return & "IP: " & tmpip & return ツ & " (" & tmpdt & ")" as string buttons {"OK"} default button 1 with icon 1 else if crip is tmpip then display dialog "- 変化ありません -" & return & "現在: " & crip & return ツ & " (" & (current date) & ")" & return & "登録: " & tmpip & return & " (" & tmpdt & ")" ツ as string buttons {"OK"} default button 1 with icon 1 giving up after 3 else display dialog "= 変わってます =" & return & "現在: " & crip & return ツ & " (" & (current date) & ")" & return & "登録: " & tmpip & return & " (" & tmpdt & ")" ツ as string buttons {"OK"} default button 1 with icon 2 set tmpip to crip set tmpdt to current date end if
Help Viewerの表示ファイルを、IEに渡して表示するためのスクリプト。 -- tell application "Help Viewer" to set theFile to current file tell application "Internet Explorer" to open theFile -- ドリの体験版落としたら、ヘルプがHelp Viewer表示になってて萎えたので…。
on idle set Aptext to "" tell application "Finder" set Aplist to every process that file type is "APPL" and frontmost is true if Aplist /= {} then set Aptext to (name of file of item 1 of Aplist) as string end if end tell
if Aptext = "Mozilla" then ---使っているブラウザ名 tell application "作業環境マネージャ" if current location /= location "web" then ---ブラウジングの環境名 activate set current location to location "web" ---ブラウジングの環境名 end if end tell tell application "Mozilla" activate end tell
else if Aptext = "Eudora" then ---使っているMailer名 tell application "作業環境マネージャ" if current location /= location "mail" then ---メールの環境名 activate set current location to location "mail" ---メールの環境名 end if end tell tell application "Eudora" activate end tell
else ---その他の場合 tell application "作業環境マネージャ" if current location /= location "normal" then ---そのたの環境名 activate set current location to location "normal" ---そのたの環境名 end if end tell end if
return 1
end idle --アプリケーション化する時に「実行後、自動的に終了しない」のチェックボックスにチェックをしておく必要がある。 --保存:classicアプリケーション【実行後、自動的に終了しない】
tell application "Finder" set file_list to selection as list repeat with the_file in file_list set name of the_file to "test" move the_file to trash end repeat end tell
--応用 repeat set Vol_Level to text returned of (display dialog ツ "0〜7までの数字を入力して音量調節します" default answer "" with icon 1) try set Vol_Number to Vol_Level as number if Vol_Number ウ 0 and Vol_Number イ 7 then if Vol_Level does not contain "." then exit repeat end if end try end repeat set volume Vol_Number
set file_index to 0 tell application "Finder" set file_list to selection as list repeat with the_file in file_list set file_index to file_index + 1 set name of the_file to "test" & file_index move the_file to trash end repeat end tell
tell application "Finder" set file_list to selection set iend to count of file_list repeat with i from 1 to iend set the_file to item i of file_list as alias set name of the_file to "test_" & i move the_file to trash end repeat end tell
repeat with 〜 in 〜の使い方を理解したので別バージョンにしてみました。 何故エイリアス値にすれば上手くいくのかは理解できませんでしたw
tell application "Finder" set file_list to selection repeat with the_file in file_list set the_file to the_file as alias set name of the_file to "~" & name of the_file move the_file to trash end repeat end tell