if [ $SMODE = true ]; then STDOUT="curllog.$$" fi for url in "${@:-`pbpaste`}" do case $url in http*) : ;; *) echo "$url is not URL" 1>&2 echo "$USAGE" 1>&2 continue ;; esac # set file extension and url # site=`echo "$url" | sed 's/\(^h.*[^0-9]\)[0-9][0-9]*\....$/\1/'` ext=`echo "$url" | sed 's/^h.*\.\(...$\)/\1/'` # #set file number lnum=`echo "$url" | sed 's/^h.*[^0-9]\([0-9][0-9]*\)\....$/\1/'` if [ "$fnum" = "" ]; then case $lnum in [0-9]) fnum=1 ;; [0-9][0-9]) fnum=01 ;; [0-9][0-9][0-9]) fnum=001 ;; [0-9][0-9][0-9][0-9]) fnum=0001 ;; *) echo "Error: Unexpected file number " 1>&2 exit 1 ;; esac fi if [ -z $refer ]; then curl -L -O $site\[$fnum-$lnum\].$ext else curl -e $refer -O $site\[$fnum-$lnum\].$ext fi # clear first file number fnum= done > $STDOUT 2>&1 exit
if Download_Folder is "" then set Download_Folder to choose folder with prompt "ダウンロードファイルを保存するフォルダを指定してくれ" set Download_Folder to POSIX path of Download_Folder end if if Command_Pass is "" then set Command_Pass to choose file with prompt "連番ダウンロードスクリプトを選択してくれ" set Command_Pass to POSIX path of Command_Pass end if
set MainURL to the clipboard set choiceList to {"簡単連番ダウンロード", "ユーザ定義ダウンロード", "ユーザ定義設定"} set DownMethod to choose from list choiceList set DownMethod to DownMethod as text if DownMethod is "簡単連番ダウンロード" then set Command_Str to Command_Pass & " " & MainURL
else if DownMethod is "ユーザ定義ダウンロード" then set Option_Str to "" if Background_Flag is "Yes" then set Option_Str to " -s " if Reffer_Flag is "Yes" then display dialog "HTTP Reffererを入力してください" default answer (the clipboard) set Option_Str to Option_Str & "-r " & text returned of result & " " end if if Firstnumber_Flag is "Yes" then display dialog "連番の最初の数字を入力してください" default answer "01" set Option_Str to Option_Str & "-n " & text returned of result & " " end if set Command_Str to Command_Pass & " " & Option_Str & MainURL
else if DownMethod is "ユーザ定義設定" then display dialog "HTTP Refeferを使用しますか?" buttons {"Yes", "No", "キャンセル"} set Reffer_Flag to button returned of result display dialog "バックグラウンドで使用しますか?" buttons {"Yes", "No", "キャンセル"} set Background_Flag to button returned of result display dialog "連番の最初の数字を指定しますか?" buttons {"Yes", "No", "キャンセル"} set Firstnumber_Flag to button returned of result return else return end if tell application "Terminal" to do script with command "cd " & Download_Folder & ";" & Command_Str
tell application "Internet Explorer" set this_text to selected text end tell set unix_return to (ASCII character 10) set mac_return to (return) set old_delimiter to AppleScript's text item delimiters set AppleScript's text item delimiters to mac_return set text_items to every text item of this_text set AppleScript's text item delimiters to unix_return set this_text to text_items as text set AppleScript's text item delimiters to old_delimiter set save_text to choose file name try set h_file to open for access save_text with write permission write this_text to h_file end try close access h_file
set aPath to POSIX path of save_text tell application "Terminal" do script with command "perl -pi -e 's/[0-9]+.*ID.*//g' " & aPath & "; chmod 755 " & aPath end tell
set aPath to POSIX path of save_text tell application "Terminal" do script with command "perl -pi -e 's/^[0-9]+.*ID.*//g' " & aPath & "; chmod 755 " & aPath end tell
Mac OS X用に書かれたconfigureのサブスクリプトを置きかえるという cp /usr/libexec/config.sub . cp /usr/libexec/config.guess . を実行してもNo such file or directoryと言われてしまいます。 最後のピリオド省いてみたり色々やっているのですが、、、。 完全Terminal厨房(同時にOS Xも最近入れたばかり)なので 困ってます。 シャーロックでusrで検索しても何も見つからないし、、、。 どなたか教えていただけないでしょうか?
configuring for GNU Wget 1.8.1 checking host system type... powerpc-apple-darwin5.2 checking whether make sets ${MAKE}... no checking for a BSD compatible install... /usr/bin/install -c checking for gcc... no checking for cc... no configure: error: no acceptable cc found in $PATH
>>117 shell script の中で osascript 呼ぶようにすりゃいいんじゃない? 例えば、こんな感じで。 #!/bin/sh # setcomment -c hoge hage で hage に hoge ってコメントをつける。 # けっこう手抜き。 while [ $# -ne 0 ] do case "$1" in -c) shift;comment="$1";; *) posixpath="$1";; esac shift done case "$posixpath" in /*) ;; *) posixpath="$PWD/$posixpath";; esac /usr/bin/osascript <<END set posix_path to "$posixpath" set the mac_path to POSIX file posix_path tell application "Finder" to set comment of mac_path to "$comment" END #!/bin/sh while [ $# -ne 0 ] do case "$1" in -c) shift;comment="$1";; *) posixpath="$1";; esac shift done case "$posixpath" in /*) ;; *) posixpath="$PWD/$posixpath";; esac /usr/bin/osascript <<END set posix_path to "$posixpath" set the mac_path to POSIX file posix_path tell application "Finder" to set comment of mac_path to "$comment" END
日本語と英語以外の言語リソースを削除(シェルスクリプト) 引数にパスを指定 ( 例: /Applications/OmniWeb.app ) 実行は自己責任でお願いします。 ---------------------------------------------------- #!/bin/sh reslist="da de el fr is it ko nl no pt pt_BR ru zh_CN zh_TW"
if [ $# -le 0 ]; then echo "Usage : $0 <path>"; exit 1; fi ;
for res in $reslist do echo searching $res.lproj... find $1 -name \*$res.lproj -exec rm -rf {} \; done ----------------------------------------------------
on idle tell application "Finder" set ProcList to name of every process end tell if ProcList does not contain "hoge" then tell application "hoge" activate end tell delay 10 end if return 30 end idle
property Cache_Folder : {} if Cache_Folder = {} then set Cache_Folder to choose folder with prompt "j2ch-cacheフォルダを選択してください" set Old_Delimiters to AppleScript's text item delimiters set Cache_Path to Cache_Folder as text set AppleScript's text item delimiters to ":" as Unicode text set Path_List to text items 1 thru -2 of Cache_Path repeat with A in Path_List set contents of A to A & "/" end repeat set Full_Path to ("'/Volumes/" & Path_List as text) & "/bin'" set AppleScript's text item delimiters to Old_Delimiters tell application "Terminal" to do script with command "cd " & Full_Path & return & "./j2ch-cache.sh"
property Cache_Folder : {} if Cache_Folder = {} then set Cache_Folder to choose folder with prompt "j2ch-cacheフォルダを選択してください" set Cache_Path to Cache_Folder as text set Cache_Path to "'" & POSIX path of Cache_Path & "/bin'" tell application "Terminal" to do script with command "cd " & Cache_Path & return & "./j2ch-cache.sh"
だから、起動→Windowを閉じる→コマンドを実行 tell application "Terminal" activate close window 1 do script with command "cd <install-dir>/bin ;./j2ch-cache.sh" end tell で良いかと。
>>167 一応、position of every item of desktop とやると、 -->{xxx,yyy},{xxx,yyy},{xxx,yyy} とか返すみたいなので、出来るのかな?と思ったけど、どうやら Finderウインドウ上でのポジションみたいです。 デスクトップにあるアイテムの本当の場所のポジションという事かな。
>>196-197 あら、やだ。pwd使うと、返すのはカレントのパスだわね。 訂正ありがとう。フルパスをとる必要も無いか。 何故フルパスとらなきゃと思ったんだろう>私 で、レスついでにOS Xのメンテナンス用のApple Scriptを。 /etc/daily,weekly,monthly及びprebindingをするだけですが(要 system osax)
property passwdStr : "" set LF to ASCII character 10 set Cmd_Str to "sudo sh " if (passwdStr = "") then set passwdStr to askPassword if (passwdStr = "") then return end if
set mList to {"Daily メンテナンス", "Weekly メンテナンス", "Monthly メンテナンス", "システムの最適化"} set mMethod to choose from list mList set mMethod to mMethod as text if mMethod is "Daily メンテナンス" then set parm to "/etc/daily" else if mMethod is "Weekly メンテナンス" then set parm to "/etc/weekly" else if mMethod is "Monthly メンテナンス" then set parm to "/etc/monthly" else if mMethod is "システムの最適化" then set Cmd_Str to "sudo /usr/bin/update_prebinding -root " set optList to {"/(システム全部)", "/Applications(Appli Folderのみ)", "好きな場所"} set optPath to choose from list optList set optPath to optPath as text if optPath is "/(システム全部)" then set parm to "/" else if optPath is "/Applications(Appli Folderのみ)" then set parm to "/Applications" else if optPath is "好きな場所" then set parm to posixPath (choose folder with prompt "お選び下さい") with quotes end if else return end if
set Cmd_Str to Cmd_Str & parm & " <<++" & LF & passwdStr & LF & "++" system (Cmd_Str)
sub AS{ $para = `/usr/bin/osascript -e ' tell application "Finder" activate set Target_Dir to choose folder with prompt "検索対象のフォルダを選択してください" set Target_Dir to POSIX path of Target_Dir set Save_Dir to choose folder with prompt "保存するフォルダを選択してください" set Save_Dir to POSIX path of Save_Dir display dialog "対象にする拡張子と移動方法を選択してください。" default answer "jpg|jpeg" buttons {"Copy", "Move", "キャンセル"} set {ASuffix, AMethod} to {(text returned of result), (button returned of result)} display dialog "ファイルの先頭文字列を入力してください。" default answer "" set APrefix to text returned of result return {Target_Dir, Save_Dir, ASuffix, APrefix,AMethod} end tell '`; $para =~ s/\s//g; chomp $para; ($targetdir,$savedir,$suffix,$prefix,$Method) = split /\,/,$para; }
Internet Explorer ,NetScape ,Mozilla ,iCab ,Omniバージョンをそれぞれ、 作ってみました。へたれさんの連番展開スクリプトも呼び出せます。 あと、PerlでURL抜き出しスクリプトを書いたんで、URLをテキストとして 書いてあるページや、半角とかも逝けます。(w
>>213 えろすさんご苦労様です。AS_Downloaderいただきました。 ところが、関連スクリプトのインストーラーを実行すると「Can`t get ヌclass psxpネ of alias]という エラーが出ます。インストーラーのスクリプトを見ると三行目が「set Cur_Path to ヌclass psxpネ of Cur_Path」 と文字化けしています。AS_Downloaderのスクリプトを見ると同様に「ヌclass psxpネ」という文字化けが見えます。 どこか私のやり方がおかしいのでしょうか?
OS X だとリアルプレイヤー書類が白紙アイコンになりません? まっ、うちだけかもしれませんが‥ アイコン復活のスクリプトつくったので同じ障害の人は使ってみて ScriptMenu 専用です、Finder から選択後、実行 リアルプレイヤー書類(拡張子 "rm","ram")以外は無視するので 他のファイルと一緒に複数選択でも OK です 処理自体はファイルタイプとクリエータタイプを設定するだけのものです
tell application "Finder" set file_list to selection repeat with the_file in file_list set the_ext to name extension of the_file if the_ext is in {"rm", "ram"} then set {creator type of the_file, file type of the_file} to {"PNst", "PNRA"} end if end repeat end tell
>>244 できますですよ。ちょっと長いですが、どうぞ。 OS X、OS 9のパスはご自分の環境に 合わせて書き換えておいて下さい。あとOS 9のシステムフォルダをSystem Folderにしといた ほうがいいかもしれません。
set passwdStr to "" display dialog "パスワードを入力" default answer passwdStr buttons {"Ok", "Cancel"} default button 1 set passwdStr to text returned of result as string display dialog "起動IOSを選んで下さい" buttons {"OS X sub", "OS 9", "Cancel"} set startDisk to button returned of result if startDisk is "OS X sub" then try do shell script "/usr/sbin/bless -folder '/Volumes/OSXsub/System/Library/CoreServices' -setOF" password passwdStr with administrator privileges end try else if startDisk is "OS 9" then try do shell script "/usr/sbin/bless -folder9 '/Volumes/OS9HDD/System Folder' -setOF" password passwdStr with administrator privileges end try end if tell application Finder activate display dialog "今すぐ再起動しますか?" buttons {"Yes", "No"} set restartFlag to button returned of result if restartFlag is "Yes" then restart else return end if end tell
>>277 perlでも同じみたいっすね。shだとどうやって制御するんだろう‥。 それとAS_Downloader、iCabからだとURLを所得出来ませんでした。 IEと同じ方法でURLをとることが出来たので、 else if Current_Browser is "iCab" then tell application "iCab" to set Cur_URL to first item of (GetWindowInfo -1)
>>288 -- tell app "QT" to activate -- と書いて構文確認すると、"QT"はどこにありますか?と聞いてくるので、 Mac OS XのQuickTime Playerを選択してくだされ。 すると自動的に、 -- tell application "QuickTime Player" to activate -- と変換され、関連付けが完了します。 以降は普通に、app "QuickTime Player"と言えば、 Mac OS X用のQuickTime Playerを指す事になります。
set FileName to (choose file with prompt "ファイルを選択してください:") get_file_name(FileName as string)
on get_file_name(this_path) set old_delim to AppleScript's text item delimiters set AppleScript's text item delimiters to ":" set the item_list to every text item of this_path set AppleScript's text item delimiters to old_delim return last item of item_list end get_file_name
set FileName to (choose file with prompt "ファイルを選択してください:") get_file_name(FileName as string)
on get_file_name(this_path) set old_delim to AppleScript's text item delimiters set AppleScript's text item delimiters to ":" set PathList to text items 1 thru -2 of this_path set First_Name to last text item of this_path set PathList to (PathList as text) & ":" set AppleScript's text item delimiters to "." set NewName to (first text item of First_Name) & "_new.mov" set AppleScript's text item delimiters to old_delim set Reference_Save_File to PathList & NewName return Reference_Save_File end get_file_name
repeat stop every movie close every movie saving no
open (choose file with prompt "拡大縮小して追加するファイルを選択してください:") tell movie 1 select all copy end tell
set FileName to (choose file with prompt "元になるファイルを選択してください:") open FileName tell movie 1 add with scaled select none get_file_name(FileName as string) save in file ((FileName & "_new") as string) as self contained end tell
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 quit saving no end tell
on get_file_name(this_path) set old_delim to AppleScript's text item delimiters set AppleScript's text item delimiters to ":" set PathList to text items 1 thru -2 of this_path set First_Name to last text item of this_path set PathList to (PathList as text) & ":" set AppleScript's text item delimiters to "." set NewName to (first text item of First_Name) & "_new.mov" set AppleScript's text item delimiters to old_delim set Reference_Save_File to PathList & NewName return Reference_Save_File end get_file_name
>>311 まっ、いろいろやり方はあるだろうけど Finder に tell してみたらどうですか やっぱりいまいちご希望が理解できてない気もするが‥ クイックタイムの部分のエラーは考えてませんよ
--end tell 前の8行を以下の7行と入れ替え
set FileName to (choose file with prompt "元になるファイルを選択してください:") open FileName tell movie 1 add with scaled select none save in file (my save_ref(FileName)) as self contained end tell
--サブルーチンは以下の二つ、くっつけといてください
on save_ref(this_file) tell application "Finder" set container_path to (container of this_file) as text set old_name to name of this_file set new_name to my make_new_name(old_name, "_new.mov") return (container_path & new_name) end tell end save_ref
on make_new_name(file_name, add_char) set old_delim to AppleScript's text item delimiters set AppleScript's text item delimiters to "." set item_list to text items 1 thru -2 of file_name set file_name to (item_list as string) & add_char set AppleScript's text item delimiters to old_delim return file_name end make_new_name
あとAS_downloaderの中にあるscriptでwgetが入ると readmeに書いていただいてるので、それでOKだと思っていたんですが terminalを見ると cp: /sw/bin/wget: No such file or directory ということでwgetのインストールが失敗しているようなんですが どうしたらよいでしょうか?
>>356 OS X質問スレの人でしょうか?startup disk を変更するってのなら、 以前 >>246にのせたのがあります。ただちょっと長いので、 OS 9が一個しか無く、それで起動出来さえすれば好いならこんなんどうです? 注意点はOS 9のシステムフォルダのパスに日本語が含まれていると駄目なので、 半角英字に変更しておいてください。 ------------------------------ property sys9Path : {} property passwdStr : {} if (passwdStr is {}) then display dialog "パスワードを入力" default answer "" buttons {"Ok", "Cancel"} default button 1 set passwdStr to text returned of result as string if (passwdStr is "") then return end if if (sys9Path is {}) then set sys9Path to POSIX path of (choose folder with prompt "OS9のシステムフォルダを選択") if (sys9Path is {}) then return end if try set cmdStr to "sudo /usr/sbin/bless -folder9 " & "'" & sys9Path & "'" & " -setOF " do shell script cmdStr password passwdStr with administrator privileges end try display dialog "すぐに再起動しますか?" buttons {"Yes", "Cansel"} default button 1 set rFlag to button returned of result if rFlag is "Yes" then tell application "Finder" to restart else return end if
でもう一つ、PreferencePanesの項目を表示するには tell application "Finder" to open file "System:Library:PreferencePanes:DesktopPictures.prefPane:" of startup disk って感じです。ただ今の所 Apple Script対応ではないので、 各項目を変更するにはdefaults 等のコマンドを do shell script で呼び出すのがいいかと思います。
>>368 tell application "Finder" activate set place to choose folder with prompt "どこに作りますか?" make folder at place end tell これで一応、任意の場所にフォルダを作れるかな。 名前変更はその作ったフォルダを選択して set name of selection to "新しい名前" とすればいけるのかな。 今いちわからんので、次の人にまかした!
set A_Name to text returned of (display dialog "作成するフォルダの名前を入力" default answer "") set A_Place to choose folder with prompt "どこに作りますか?" tell application "Finder" to make folder at A_Place with properties {name:A_Name}
on run if Bigin_Date = "" then my Bigin_No_Smoking() else my Current_No_Smoking() end if end run
to Bigin_No_Smoking() display dialog App_Name & "禁煙開始に向けて設定します。" & return & ツ "いくつかの質問に答えてください。" buttons {"キャンセル", "設定する"} default button 2 with icon 1 set Bigin_Date to current date repeat set How_Many to text returned of (display dialog App_Name & ツ "【Q1】" & return & "1日にタバコを何本吸っていましたか?" default answer "" buttons {"本"} default button 1 with icon 1) try set Cigarette_Day to How_Many as number if Cigarette_Day ウ 1 and How_Many does not contain "." then exit repeat end try end repeat repeat set How_Much to text returned of (display dialog App_Name & ツ "【Q2】" & return & "1箱いくらのタバコを吸っていましたか?" default answer "" buttons {"円"} default button 1 with icon 1) try set Cigarette_Price to How_Much as number if Cigarette_Price ウ 1 and How_Much does not contain "." then exit repeat end try end repeat set Set_Menu to button returned of (display dialog App_Name & "【禁煙開始日時】" & return & Bigin_Date & return & return & ツ "1日の喫煙数:" & How_Many & "本" & return & "タバコの値段:1箱" & How_Much & "円" & return & return & ツ "上記設定でよろしいですか?" buttons {"やり直し", "禁煙開始"} default button 2 with icon 1) if Set_Menu = "やり直し" then my Bigin_No_Smoking() end Bigin_No_Smoking
to Current_No_Smoking() set K_Seconds to (current date) - Bigin_Date set ret to my Make_ymdhm(K_Seconds) set Dialog_1 to "禁煙時間 " & Y of ret & "年 " & mo of ret & "月 " & d of ret & "日 " & h of ret & "時間" & mi of ret & "分" set Dialog_2 to "吸わなかったタバコ " & K_Seconds div (86400 / Cigarette_Day) & "本" set Dialog_3 to "浮いたタバコ代 " & (round (K_Seconds div (86400 / Cigarette_Day)) * 12.5) & "円" set ret2 to my Make_ymdhm(K_Seconds div (86400 / Cigarette_Day) * 330) set Dialog_4 to "延びた寿命 " & d of ret2 & "日 " & h of ret2 & "時間" & mi of ret2 & "分" set Result_1 to button returned of (display dialog App_Name & Dialog_1 & return & Dialog_2 & return & Dialog_3 & return & Dialog_4 ツ buttons {"禁煙失敗", "OK"} default button 2 with icon 1) if Result_1 = "禁煙失敗" then set Delete_Data to button returned of (display dialog App_Name & "禁煙に失敗しましたか?" & return & ツ "残念ですが、今までのデータを消去します。" buttons {"消去しない", "消去する"} default button 1 with icon 1) if Delete_Data = "消去する" then set Bigin_Date to "" set Cigarette_Day to "" set Cigarette_Price to "" end if else set the clipboard to Dialog_1 & return & Dialog_2 & return & Dialog_3 & return & Dialog_4 end if end Current_No_Smoking
to Make_ymdhm(sec) set years to 60 * 60 * 24 * 365 set months1 to 60 * 60 * 24 * 30 set ret to {Y:0, mo:0, d:0, h:0, mi:0} set Y of ret to sec div years set mo of ret to (sec - (Y of ret) * years) div months1 set d of ret to (sec - (mo of ret) * months1 - (Y of ret) * years) div days set h of ret to (sec - (mo of ret) * months1 - (Y of ret) * years - (d of ret) * days) div hours set mi of ret to (sec - (mo of ret) * months1 - (Y of ret) * years - (d of ret) * days - (h of ret) * hours) div minutes return ret end Make_ymdhm
tell application "Finder" activate set A_Name to text returned of (display dialog "作成するフォルダの名前を入力" default answer "") set A_Place to choose folder with prompt "どこに作りますか?" make folder at A_Place with properties {name:A_Name} end tell
tell application "Internet Explorer" Activate set daimei to "goo [英和・和英辞典検索]" set tango to text returned of (display dialog daimei & return & return & ツ "調べたい単語は何ですか?" default answer "" buttons {"キャンセル", "OK"} default button 2) set docchi to button returned of (display dialog daimei & return & return & ツ "単語:" & tango & return & return & "この単語をどちらで検索しますか?" & return & return & "" buttons {"和英", "英和"}) if docchi = "和英" then OpenURL "http://dictionary.goo.ne.jp/cgi-bin/dict_search.cgi?MT=" & tango & "&sw=1" end if if docchi = "英和" then OpenURL "http://dictionary.goo.ne.jp/cgi-bin/dict_search.cgi?MT=" & tango & "&sw=0" end if end tell
tell application "Internet Explorer" Activate set daimei to "goo [英和・和英辞典検索]" display dialog daimei & return & return & "調べたい単語は何ですか?" default answer "" ツ buttons {"キャンセル", "和英", "英和"} default button 3 set {tango, docchi} to result as list set adress to "http://dictionary.goo.ne.jp/cgi-bin/dict_search.cgi?MT=" & tango if docchi = "和英" then OpenURL adress & "&sw=1" else OpenURL adress & "&sw=0" end if end tell
>>405 SCIMUI(Simplified Chinese Input Method User Interface)Serverは簡体字、 TCIMUI(Traditional Chinese Input Method User Interface)Serverは繁體字の インプットメソッドで、Kerberosはネットワーク認証システム。
>>410 AppleScriptじゃ駄目なの? Finderを隠すのは tell application "Finder" to set visible to false でできます 任意のアプリとなるとFinderにプロセスを隠してもらうといいです tell application "Finder" tell process "internet Explorer" to set visible to false end tell
OS XのIEはダウンロードファイルのコメント欄に 元URLを記入しないのでAppleScriptで作りますた iCabだとfindURLってコマンドがあって一発でURL取れるんですが IEには無いのでダウンロードマネージャの項目を利用してます 当然ダウンロードマネージャに記録されてないファイルには無効です Finderで選択後実行してください
property theFilePath : (path to preferences from user domain as string) & "Explorer:Downloads.html"
tell application "Finder" set downroadsInfo to my GetDownRoadsInfo() set fileLists to selection repeat with szFile in fileLists set fileName to name of szFile try set comment of szFile to my find_URL(fileName, downroadsInfo) end try end repeat end tell
on GetDownRoadsInfo() open for access file theFilePath try set downroadsInfo to read file theFilePath using delimiter {return} end try close access file theFilePath return downroadsInfo end GetDownRoadsInfo
on find_URL(fileName, sourceText) repeat with textItem in sourceText if fileName is in textItem then set the copyFlag to 0 set the outText to "" repeat with szChar in textItem set szChar to the contents of szChar if szChar is "\"" then set the copyFlag to copyFlag + 1 else if the copyFlag is 1 then set the outText to the outText & szChar as string else if the copyFlag is 2 then exit repeat end if end repeat return the outText end if end repeat end find_URL
--OS 9では以下のスクリプトは動いていましたが、 tell application "Finder" activate make new folder at folder "HD 2:temp" select folder "HD 2:temp:名称未設定フォルダ" set name of selection to "10000 1" as string --この文でエラー end tell
で、OS Xの selection なんですが move selection to trash とか delete selecton なんかは問題ないんですがFinderのitemとしての属性を変更しようとするとできない 要するに複数参照が利かないんですね set comment of selection to "こめんと" これ、無理 従って、いったん変数に入れて明示的に参照のリストに変えて、ひとつひとつ取り出す set theFiles to selection repeat with i in theFiles set comment of i to "こめんと" end repeat というわけ
set a to time of (current date) if a < 60 * 60 * 8 then display dialog "夜中" else if 60 * 60 * 8 < a and a < 60 * 60 * 12 then display dialog "朝" else if 60 * 60 * 12 < a and a < 60 * 60 * 18 then display dialog "昼間" else if 60 * 60 * 18 < a then display dialog "夜" end if
tell application "Finder" if not (exists theFolder) then set theFolder to (choose folder) end if set desktop picture to some file of entire contents of folder theFolder end tell --
set fileName to "スクリーン.pdf" set desktopPath to POSIX path of (path to desktop from user domain) do shell script "screencapture " & desktopPath & fileName
その1:Terminalを呼び出して処理 tell application "Terminal" do script with command "/bin/sh -c 'for i in *.aif;do mv \"$i\" `echo \"$i\"|sed \"s/ .*aif$/.aif/\"` ; done'" end tell
その2:Terminalなしで直接実行 do shell script "for i in *.aif;do mv \"$i\" `echo \"$i\"|sed 's/ .*aif$/.aif/'` ; done"
先生やTerminalスレのみなさんのおかげで、iTunesでエンコードしたAIFFを LAMEを使ってmp3を作成するスクリプトが自分なりにきれいにまとまりました。 CDDBを使わないのが条件、iTunesライブラリにゴミが残るなどの超自分仕様なので他の人には使いにくいとは思いますが… (普段は圧縮音楽スレのokunoさんのLet's encode with LAMEを使用)
do shell script "mkdir /Volumes/HD/DATA/Music/MP3/" do shell script "mv /Volumes/HD/DATA/Music/不明なアーティスト/不明なアルバム/*.aif /Volumes/HD/DATA/Music/MP3/" do shell script "rm -r /Volumes/HD/DATA/Music/不明なアーティスト/" do shell script "for i in /Volumes/HD/DATA/Music/MP3/*.aif;do mv \"$i\" `echo \"$i\"|sed 's/ .*aif$/.aif/'` ; done" with timeout of 1000000 seconds do shell script "for i in /Volumes/HD/DATA/Music/MP3/* ; do /usr/local/bin/lame --alt-preset standard --interch 0.0005 \"$i\" \"$i\".mp3 ; done" end timeout do shell script "rm /Volumes/HD/DATA/Music/MP3/*.aif" tell application "Finder" activate open folder "MP3" of folder "Music" of folder "DATA" of disk "HD" end tell
よく考えると、必要なのは do shell script "for i in /Volumes/HD/DATA/Music/MP3/* ; do /usr/local/bin/lame --alt-preset standard --interch 0.0005 \"$i\" \"$i\".mp3 ; done" だけだなぁ。
>477 info forの用語の中に"default application"というpropertyがありますが、 こいつはR/Oのようです。Finder/System Eventsの用語辞書の中にあるfileなどには このdefault applicationに相当するpropertyが無いようです。 ので、スクリプトで設定するのは無理かと........
んで、info forでdefault applicationをgetして、希望するアプリじゃなかったら 他ので開く.......とかいう消極的な方法しか思い付かないです(;´Д`)スマソ ちなみに、 tell application "Finder" open theFile using theApplication end tell でtheFileをtheApplicationで開く。theFileはリストでもOKです。
--- Application.applescript.orig Sat Oct 12 01:17:22 2002 +++ Application.applescript Mon Oct 14 05:58:02 2002 @@ -326,7 +326,18 @@ else set Cur_URL to "" end if - set Cmd_Str to "cd " & (item 4 of Tmp_Ref) & ";" & ((item 2 of Tmp_Ref) & " " & Cur_URL) + set tmp_cmd_str to item 2 of Tmp_Ref + if (tmp_cmd_str contains "++") then + set old_deli to AppleScript's text item delimiters + set AppleScript's text item delimiters to "++" + set Cmd_Str_1 to first text item of tmp_cmd_str + set Cmd_Str_2 to last text item of tmp_cmd_str + set AppleScript's text item delimiters to old_deli + set cmd_str_tmp to Cmd_Str_1 & " " & Cur_URL & " " & Cmd_Str_2 + else + set cmd_str_tmp to (Cmd_Str & " " & Cur_URL) + end if + set Cmd_Str to "cd " & (item 4 of Tmp_Ref) & ";" & cmd_str_tmp if ((item 5 of Tmp_Ref) as number) is 0 then set thePanel to load panel "downloding_panel" from nib "configpanel" set theSound to load sound "Submarine"
on run aif_exp(choose file with prompt "Choose text file") end run
on open drop_item set theFile to drop_item set file_num to count (item of drop_item) if file_num is 1 then aif_exp(drop_item) else display dialog "Sorry, only 1 file can be handled." end if end open
on aif_exp(source_file) set theInfo to info for source_file set theName to (name of theInfo) & ".aiff" open for access source_file try set theText to read source_file using delimiter ("#") as text on error set theSent to read source_file as text end try close access source_file try set theSent to item 1 of theText set theVoice to item 2 of theText end try set theAif to (choose file name with prompt "Saving file..." default name theName) try say theSent using theVoice saving to theAif on error say theSent saving to theAif end try end aif_exp
tell application "Internet Explorer" set winID to item 1 of (ListWindows) set winInfo to (GetWindowInfo winID) set targetURL to item 1 of winInfo end tell tell application "Finder" set saveFol to choose folder with prompt "ロケーションファイルを作成するフォルダを選択" set saveFileName to text returned of (display dialog "保存するファイル名を入力" default answer "" with icon note) make internet location file at saveFol to targetURL with properties {name:saveFileName} end tell
set theItem to selection on open theItem tell application "QuickTime Player" activate open theItem export movie 1 to (choose file name) as DV stream end tell end open
>>527 iMac使ったことないんだけど ジオメトリ調整をOSでソフトウェア的に処理してんの? 10.2のモニタ調整にはそういう項目は見当たらんが モニタをハードウェア的に直接いじってるなら AppleScriptでの制御は無理かと >>528 open locationじゃなくてブラウザに命令すると うまくいきましたけど、ダメ? set ctext to the clipboard as string set jitenn to "http://dictionary.goo.ne.jp/cgi-bin/dict_search.cgi?sw=2&MT=" tell application "Internet Explorer" to OpenURL (jitenn & ctext)
set filePath to (choose file name) set filePath to filePath as text set thisData to "abcde" try set openFile to open for access file filePath with write permission write thisData to openFile close access openFile on error close access openFile end try
set theData to "abcde" tell application "Finder" to set theFile to (make file) as alias try open for access theFile with write permission write theData to theFile close access theFile on error close access theFile end try
こんな事が可能になってますた。凄いかも。 set fileList to (fromPosixPath (system "find /some/where -name '*.jpg' -type f")) as list repeat with aFile in fileList 色々と処理 end repeat
とかヒアドキュメントみたいにこんな事も。 set aCmd to " for aFile in `find /some/where -name '*. jpeg' -type f` do mv "$aFile" `echo "$aFile" | sed 's/. jpeg$/. jpg/'` done" system aCmd with EOLisCR
set theString to "Hello, world!" set theOutputName to "my new file.txt" set theOutputPosix to quoted form of ((POSIX path of (path to desktop)) & theOutputName) do shell script "echo " & theString & " > " & theOutputPosix & "; open " & theOutputPosix
tell application "Finder" activate set theFilelist to every file of (choose folder with prompt "「あるフォルダ」を選んで下さい。") set theMove2folder to (choose folder with prompt "「任意のフォルダ」を選んで下さい。") repeat with aFile in theFilelist move aFile to theMove2folder end repeat end tell
tell application "Finder" activate set theFilelist to every file of folder "desktop" of folder "tab" of folder "Users" set theMove2folder to folder "押し入れ" of folder "desktop" of folder "tab" of folder "Users" repeat with aFile in theFilelist move aFile to theMove2folder end repeat end tell
set theFromFolder to choose folder with prompt "From" set theToFolder to choose folder with prompt "To" tell application "Finder" to move every file of theFromFolder to theToFolder
他のアプリやAppleScript内で処理する場合には リストに入れてループさせることが多いので、そう書いてしまいました。 (そのリストの中にはFinder形式の参照が入っているので、 その場合はas alias listでクラス変換する必要があります。)
>>548 set theFromFolderPosix to quoted form of POSIX path of (choose folder with prompt "From") set theToFolderPosix to quoted form of POSIX path of (choose folder with prompt "To") set the notFolder to "Document" do shell script ツ で
on open fileList set LengthList to {} set counter to 0 repeat with aFile in fileList tell application "RealOne Player" open aFile set end of LengthList to (GetLength) / 1000 end tell end repeat tell application "RealOne Player" repeat with aFile in fileList set counter to counter + 1 activate open aFile delay (item counter of LengthList as number) end repeat end tell end open
on open fileList set LengthList to {} set SortedList to {} set counter to 0 set fileList to reverse of fileList repeat with aFile in fileList tell application "RealOne Player" open aFile set end of LengthList to (GetLength) / 1000 end tell end repeat tell application "RealOne Player" repeat with aFile in fileList set counter to counter + 1 activate open aFile delay (item counter of LengthList as number) end repeat end tell end open
on open file_List tell application "Finder" repeat with a_File in file_List set a_File to "<entry><ref href=\"file://" & a_File & "\"/></entry>" set end of wm_List to a_File end repeat end tell end open
on run tell application "Finder" set the_button to button returned of (display dialog "asxファイルを作ってもいいんだな?" buttons {"キャンセル", "クリア", "いいよ"} default button 3) if the_button is "いいよ" then set old_Delim to AppleScript's text item delimiters set AppleScript's text item delimiters to return set the_text to {"<asx version=\"3.0\">", wm_List as string, "</asx>"} set the_text to the_text as string set AppleScript's text item delimiters to old_Delim set asx_file to choose file name set the_file to open for access asx_file with write permission write the_text to the_file close access the_file set creator type of asx_file to "Ms01" else if the_button is "クリア" then set wm_List to {""} end if end tell end run
on open dropFolder tell application "Finder" set the myList to list folder dropFolder without invisibles set dropFolder to dropFolder as string repeat with i from 1 to number of items in the myList set iItem to item i of the myList set iAlias to (dropFolder & iItem) as alias set iInfo to info for iAlias if folder of iInfo is true then --if folder of iAlias is true then --if folder iAlias exists then --if folder (org & iItem) exists then open iAlias end if end repeat end tell end open
>>593 第1階層だけでいいの? on open drpItems tell application "Finder" set selection to drpItems tell every folder of every folder of selection open end tell end tell end open
on open dropFolder set the myList to list folder dropFolder without invisibles set dropFolder to dropFolder as string repeat with i from 1 to number of items in the myList set iItem to item i of the myList set iAlias to (dropFolder & iItem) as alias set iInfo to info for iAlias if folder of iInfo is true then tell application "Finder" to open iAlias end if end repeat end open
on open theList tell application "Finder" set oBounds to {0, 0, 0, 0} repeat with iItem in theList open iItem set oBounds to bounds of window of iItem my setPositionWindow(0, iItem, oBounds) close window of iItem end repeat end tell end open --続きます
--続きです on setPositionWindow(a, org, oBounds) tell application "Finder" set pos to {(item 1 of oBounds) + (-3 * a), (item 2 of oBounds) + (21 * a)} try set bounds of container window of org to {200, 200, 200, 200} set zoomed of container window of org to true set position of container window of org to pos --set current view of container window of org to icon view --set icon size of icon view options of container window of org to small --set arrangement of icon view options of container window of org to snap to grid end try
set the myList to every folder of org repeat with i from 1 to number of items in the myList set iItem to item i of the myList open iItem my setPositionWindow(a + 1, iItem, oBounds) close window of iItem end repeat end tell end setPositionWindow
set home_string to do shell script "defaults read com.apple.internetconfig|sed -n '/^ *WWW/p'" set old_delimiter to AppleScript's text item delimiters set AppleScript's text item delimiters to "\"" set homepage to text item 4 of home_string set AppleScript's text item delimiters to old_delimiter display dialog homepage
on open fileList set URL_List to {} set counter to 0 tell application "Finder" repeat with aFile in fileList set end of URL_List to url of aFile as text end repeat end tell set SortedList to my ShellSort(0, URL_List) tell application "Finder" set old_Delim to AppleScript's text item delimiters set AppleScript's text item delimiters to return set the_text to SortedList as string set AppleScript's text item delimiters to old_Delim set ram_file to choose file name default name "名称未設定.ram" set the_file to open for access ram_file with write permission write the_text to the_file close access the_file set creator type of file (ram_file as text) to "PNst" end tell end open
--シェルソートサブルーチン(UpDown −> 0:昇順、1:降順) on ShellSort(UpDown, BoxList) set N to length of BoxList if N > 1 then set k to 1 set h to 1 repeat until h > N / 9 set k to h set h to (h * 3 + 1) end repeat
repeat until k = 0 repeat with i from k + 1 to N set j to i if UpDown = 0 then --昇順 repeat while ((j > k) and ((item (j - k) of BoxList) > (item j of BoxList))) set Temp to item j of BoxList set item j of BoxList to item (j - k) of BoxList set item (j - k) of BoxList to Temp set j to j - k end repeat
else --降順 repeat while ((j > k) and ((item (j - k) of BoxList) < (item j of BoxList))) set Temp to item j of BoxList set item j of BoxList to item (j - k) of BoxList set item (j - k) of BoxList to Temp set j to j - k end repeat end if end repeat set k to ((k / 3) div 1)
set home_string to do shell script "defaults read com.apple.internetconfig|grep -A1 '^ *WWW'" set old_delimiter to AppleScript's text item delimiters set AppleScript's text item delimiters to "\"" set homepage to text item 4 of home_string set AppleScript's text item delimiters to old_delimiter display dialog homepage
#!/bin/sh curl 'http://pc.2ch.net/mac/subback.html' | grep '^<a\ href\=' | sed 's/^<a\ href\=\"//g' | sed 's/\/l50\">/\ /g' | sed 's/<\/a>..//g' |\ sed -e 's/^\([0-9]\{9,10\}\)\ \([0-9]\{1,3\}:\)/\1_\2_/g' -e 's/\ //g' -e 's/^\([0-9]\{9,10\}\)_\([0-9]\{1,3\}:\)_/\1\ \2\ /g' > /tmp/2ch1.$$
curl 'http://pc.2ch.net/mac/dat/' | perl -p0e 's/\.dat\">/\n/g' | grep '^[0-9][0-9]' | sed 's/\.dat<\/A>//g' | sed 's/-Jan-/\ 01\ /g' | sed 's/-Feb-/\ 02\ /g' |\ sed 's/-Mar-/\ 03\ /g' | sed 's/-Apr-/\ 04\ /g' | sed 's/-May-/\ 05\ /g' | sed 's/-Jun-/\ 06\ /g' | sed 's/-Jul-/\ 07\ /g' | sed 's/-Aug-/\ 08\ /g' |\ sed 's/-Sep-/\ 09\ /g' | sed 's/-Oct-/\ 10\ /g' | sed 's/-Nov-/\ 11\ /g' | sed 's/-Dec-/\ 12\ /g' | awk '{print $4, $3, $2, $5, $1}' | sed 's/^20//g' |\ sed 's/\([0-9][0-9]\)\ \([0-9][0-9]\)\ \([0-9][0-9]\)/\1\/\2\/\3/g' | sort > /tmp/2ch2.$$
cd ~/Desktop
while read thrdate thrtime thrnum do while read thrttlnum thrrank thrtitle do if [ $thrttlnum == $thrnum ] then echo "$thrdate $thrtime$thrnum$thrrank $thrtitle" >> result fi done < /tmp/2ch1.$$ done < /tmp/2ch2.$$ rm /tmp/*.$$
while read thrdate thrtime thrnum do while read thrttlnum thrrank thrtitle do if [ $thrttlnum == $thrnum ] then echo "$thrdate $thrtime$thrnum$thrrank$thrtitle" >> result fi done < /tmp/2ch1.$$ done < /tmp/2ch2.$$ rm /tmp/*.$$ SetFile -c "JED3" -t "TEXT" ~/Desktop/result
on run tell app "Internet Explorer" Activate set urlStr to item 1 of (GetWindowInfo result) as list end tell tell app "Safari" activate OpenURL urlStr end tell end run
とんびさんのところを参考にして、 set thePath to (path to me) tell application "Finder" to set thePath to container of thePath で、thePathを「:」をつかったカレントパスに指定できるというところ までわかったんですが。
sset path1 to path to me set path1 to path1 as text set AppleScript's text item delimiters to ":" set path1 to every text item of path1 set AppleScript's text item delimiters to ":" set path1 to path1 as text
set path1 to path to me set path1 to path1 as text set AppleScript's text item delimiters to ":" set path1 to every text item of path1 set AppleScript's text item delimiters to "/" set path1 to path1 as text
707の続きです set bool to true as boolean set ff to {} repeat while bool choose file with prompt "Select a file" set ff to ff & the result display dialog "OK?" buttons {"Ok", "No"} default button 1 set kekka to the result as list if item 1 of kekka is "Ok" then set bool to false end if end repeat choose folder with prompt "Select Burn location" set dvd to the result with timeout of 7200 seconds tell application "Finder" set i to 1 repeat count ff times duplicate item i of ff to dvd set i to i + 1 end repeat end tell end timeout tell application "Disk Copy" BurnDVD ???ここがわかりません??? end tell
初心者から質問です terminalからAppleScriptを実行させようと % /usr/bin/osascript program.scpt とすると以下のようなエラーが出ます ------------------------------------------------- kCGErrorIllegalArgument : initCGDisplayState: cannot map display interlocks. kCGErrorIllegalArgument : CGSNewConnection cannot get connection port INIT_Processeses(), could not establish the default connection to the WindowServer.Abort ------------------------------------------------- これはどこがいけないんでしょうか?
ダウンロードフォルダをスクリプト自身を基準にして決める場合、 OS Xでは『(path to me) as string 』が失敗するという問題も 『(path to me) as Unicode text』とする事でとりあえず大丈夫みたいだし、なんとか行けそう。
さて次は落としたファイルをPerlに食わせてやるにはどうすればいいかな?と考え中。 Mac OSのMacJPerlは楽だったなー。
しかしそもそもPerl忘れてるし。
AS Studioはぼちぼち使ってますけど、NSTaskってのはまだ触ったことないですね。。 入門書に全面依存してる状況なので、本来の実力を発揮させてあげられていない気がします。 自由形状のウインドウとかウインドウの透明化とか、ASだけの範囲じゃ無理なのかなー。やっぱ。 クラスとかインスタンスとかのちんぷんかんぷんな話もわからないとだめなのだろうか。
OS 9以前はゴミ箱を空にする時に、ゴミ箱の項目数や容量を知らせてた のですが OS X では空にしますか?という警告だけでよく分かりません。
というので下記スクリプトを作って頂きました。
tell application "Finder" set gominoKazu to count items of trash set gominoRyou to 0 repeat with i from 1 to gominoKazu set gominoRyou to gominoRyou + (size of item i of trash) end repeat activate display dialog "The number of garbage : " & gominoKazu & return & "Size of garbage : " & gominoRyou & "byte" empty trash end tell
ただこのままでは「Can't makemissing value into a number. 」とアラート が出たり、空のフォルダを削除する時エラーが発生するようです。
tell application "Finder" set gominoKazu to count items of trash set gominoRyou to 0 repeat with i from 1 to gominoKazu try set gominoRyou to gominoRyou + (size of item i of trash) on error set gominoRyou to gominoRyou + (size of item i of trash) end try end repeat activate display dialog "The number of garbage : " & gominoKazu & return & "Size of garbage : " & gominoRyou & "byte" empty trash end tell
tell application "Finder" set trash_items to entire contents of trash set trash_size to physical size of every item of trash end tell set trash_n to number of trash_items if trash_n > 0 then if class of trash_size is not list then set trash_size to {trash_size} set total to sum(trash_size) set dtotal to size_unit(total) display dialog ((trash_n as text) & "項目、合計で" & dtotal & "(" & total as text) & ")" & return & return & "ゴミ箱の中にあります。" tell application "Finder" to empty else display dialog "ゴミ箱は空です。" end if
on sum(num) set total to 0 repeat with n in num set total to total + n end repeat set total to total as integer return total end sum
on size_unit(the_size) if the_size > 1.0E+9 then set exp_size to ((the_size div 1.0E+9) as text) & "G" else if the_size > 1.0E+6 then set exp_size to ((the_size div 1.0E+6) as text) & "M" else if the_size > 1000.0 then set exp_size to ((the_size div 1000.0) as text) & "K" end if return exp_size end size_unit
tell application "起動ディスク" activate set startup disk alias to alias "HDの名前" set startup system folder alias to alias "HDの名前:System:Library:CoreServices:BootX" end tell tell application "Finder" activate restart end tell
on idle set sabun to yoteinoJikan - current date if sabun < 30 or sabun > -30 then beep activate display dialog "時間じゃボケおきんかわりゃ" else if sabun > 0 then return sabun end if end idle
--2sjis--applescript-- tell application "Safari" set CurURL to URL of document 1 set SjisURL to "http://localhost/~username/2sjis.cgi?" & CurURL set URL of document 1 to SjisURL end tell
すみません、初心者スレに書いたのですが、こっちに行くよう 促されたので質問させてください。 OSXで 「ドロップした複数フォルダの中の全てファイルのロックを 解除する」 というスクリプトを書きたいのですが、 on open droppeditems tell application "Finder" repeat with obj in droppeditems set locked of obj to false end repeat end tell end open では、当たり前ですが動作しません。 フォルダ内のファイルへのアクセスにはどのような記述が 必要なんでしょうか?
>>825 勉強になりました。 OS XのFinderで、ドロップしたファイル、フォルダ、フォルダの中の全てのファイルを処理するスクリプトが書けました。 folderの中身(elements?)としてのevery fileには反応してくれるのね。
property kagi : false
on open dropList tell application "Finder" repeat with aFile in dropList--ここが不細工 try set locked of aFile to kagi end try end repeat end tell my tojimari(dropList) end open
on tojimari(theFolders) tell application "Finder" repeat with obj in ObjectList set locked of every file of aFolder to kagi
set theFolders to {} set theFolders to every folder of aFolder if theFolders is {} then else my tojimari(theFolders) end if end repeat end tell end tojimari
いかのようなかんじで、マウントするのですが、 mount volume "OS9 HD" on server "OS 9 Mac" in Appletalk zone "*" as user name "DS" with password "" うまくいくときとうまくいかないときがあります。 うまくいかないときは、サーバをさがしているみたいな、ダイアログが 数秒でたあとに、エラーダイアログでて、それっきりです。
on open theItemList tell application "Finder" activate
repeat with theItem in theItemList set theFileList to every file of theItem repeat with theFile in theFileList set name of theFile to (name of theItem) & "_" & (name of theFile) end repeat end repeat end tell end open
tell application "Finder" activate set DialogReply to (display dialog "単語を入力" buttons {"Cancel", "OK"} default button 2 default answer "") set theWord to text returned of DialogReply end tell tell application "Safari" activate set dic to "http://dictionary.goo.ne.jp/search.php?MT=" set dic2 to "&ej.x=22&ej.y=8&kind=&mode=0" set URL of document 0 to (dic & theWord & dic2) end tell
>>862 遅レスだけど パッケージの中のContentsフォルダにスクリプトを入れて set thePath to (path to current application) でアプリのパスを取って、":Contents:scriptfile"を付け加えて loadしてみてください。ASSってコンパイルが面倒なんで、 試してないけど(=レスが付きにくいのかな)
tell application "Finder" activate set DlgRply to (display dialog "単語入力" default answer "") set theWord to text returned of DlgRply set pcmd to "#!/usr/local/bin/perl" & return & "while(<>){print &encodeurl}; sub encodeurl{my $str=euc; $str=\"" & theWord & "\"; ツ $str=〜s/(\\W)/'%'.unpack('H2',$1)/ge; $str=〜s/\\s/+/g;" do shell script "perl -e '" & pcmd & "'" tell application "Safari" activate set dicje to "http://dictionary.goo.ne.jp/search.php?MT=" set dicje2 to "&je.x=49&je.y=15&kind=ej&mode=0" set URL of document 0 to (dicje & theWord & dicje2) end tell end tell
>これ、868さんのスクリプトの「#!」以降を >単なるテクスト書類で保存して置いておくので合ってますか? 残念ながらちゃう。サブルーチンで書いていたのを素で書いているのと、while(<>){〜}を省略するために-nオプションを付けただけ。 >そもそも884での使い方、あれでOKだったのでしょうか? もとのスクリプトを見ると、theWordにスクリプトの結果を代入してないので素通りしてるように見えるんだと思う。 さて。 on urlencode(aWord)はAppleScriptのハンドラとして、君のスクリプトに入れとくのだ>868=884=890 サイトを見たが、Encode前の漢字コードはEUCみたいなので、perlに渡す前にEUCにしてしまおう。 on urlencode(aWord) return do shell script ("echo -n " & aWord & "|/usr/local/bin/nkf -e|perl -ne 'shift;s/([^0-9A-Za-z_ ])/\"%\".unpack(\"H2\",$1)/ge;s/\\s/+/g;print;'") end urlencode だな。nkfのインストールは自分で調べるように:-)。あとは884のスクリプトで set URL of document 0 to (dicje & theWord & dicje2)を set URL of document 0 to (dicje & my urlencode(theWord) & dicje2) にすればいいんでないかい?やってみよう.......うん、出来たっぽい。 property dicje : "http://dictionary.goo.ne.jp/search.php?MT=" property dicje2 : "&je.x=49&je.y=15&kind=ej&mode=0" on run tell application "Finder" activate set theWord to text returned of (display dialog "単語入力" default answer "") end tell tell application "Safari" activate open location (dicje & my urlencode(theWord) & dicje2) end tell end run on urlencode(aWord) return do shell script ("echo -n " & (aWord as Unicode text) & "|/usr/local/bin/nkf -e|perl -ne 'shift;s/([^0-9A-Za-z_ ])/\"%\".unpack(\"H2\",$1)/ge;s/\\s/+/g;print;'") end urlencode でどうだ。
tell application "Internet Explorer" Activate --> 45 choose file name with prompt "" default name "JIKKENN.txt" --> file "MacHD:Users:syuu:Desktop:JIKKENN.txt" end tell tell current application open for access file "MacHD:Users:syuu:Desktop:JIKKENN.txt" with write permission --> 90 write "hogehoge_jikkenn_desu" to 90 starting at eof close access 90 --> スタックオーバーフローです。
on run tell application "Finder" activate set theWord to text returned of (display dialog "単語入力" default answer "") set theDic to button returned of (display dialog "辞書選択" buttons {"英和", "和英", "国語"}) end tell tell application "Safari" activate if theDic is "英和" then open location (dic & theWord & dicej) else if theDic is "和英" then open location (dic & my urlencode(theWord) & dicje) else if theDic is "国語" then open location (dic & my urlencode(theWord) & dicjj) end if end tell end run on urlencode(theWord) return do shell script ("echo -n " & (theWord as Unicode text) & "|/usr/local/bin/nkf -W -e|perl -ne 'shift;s/([^0-9A-Za-z_ ])/\"%\".unpack(\"H2\",$1)/ge;s/\\s/+/g;print;'") end urlencode
Larry Wall(perl,patchの作者)じゃ無いけれど、 「何をするにもやり方は一つだけじゃない」(TMTOWTDI; There's more than one way to do it.) わけで、取り分けMacは他の環境に比べて選択肢が多いように感じます。AppleScriptが あるだけで、他のアプリの機能を自分の物のように使えると言うのは強いよね。 思いつきをどんどん形にして行くだけでも、それは経験になり、財産になります。 私もそうして今がある訳だし、863=897さんもこの先そうして経験を積んで行く訳です。 そして、今度は863=897さんがその経験を元に、他の方に色々教えてあげてくれるように なれば、私もここに色々書き込んだ甲斐があったと言うものです。 これを最後に名無しに戻りますが、多分呼ばれればまた出てくるでしょう:-)
-- test script property myList : "" tell application "Finder" to set storeFile to (home as string) & "_StoreFIle.scpt" set myList to load script (storeFile as alias) set myData of myList to {} store script myList in (storeFile as alias) replacing yes set myList to (load script (storeFile as alias)) get myData of myList -- {1,2,3,4,5} << 空になってない
>960-964 --write.scpt property myList : {{name:"test1", number:1}, {name:"test2", number:2}, {name:"test3", number:3}, {name:"test4", number:4}} tell application "Finder" set wh to open for access file ((home as string) & "StoreFIle.dat") with write permission try write myList as list to wh end try close access wh end tell
--read.scpt tell application "Finder" set rh to open for access file ((home as string) & "StoreFIle.dat") with write permission try set r to read rh as list end try close access rh end tell return r