on open dropItems set urlList to {} set fileName to {} repeat with theFile in dropItems if (theFile as string) ends with "webarchive" then tell application "System Events" to set webMainResourceRecord to (value of property list item "WebMainResource" of property list file (theFile as string) as record) set theURL to |WebResourceURL| of webMainResourceRecord set urlList to urlList & theURL tell application "Finder" to set fileName to fileName & (name of theFile) end if end repeat if urlList is {} then return set stringList to (item 1 of urlList) as string repeat with i from 2 to (number of items of urlList) set stringList to stringList & return & (item i of urlList) as string end repeat tell application "Finder" to display dialog "webarchiveファイルの元URLを取り出しました。" buttons {"cancel", "クリップボードへ", "ブラウザで開く"} default button 3 set buttonReturned to (button returned of result) if (number of items of urlList) is 1 then doItRightNow(buttonReturned, urlList) else chooseList(buttonReturned, fileName, stringList, urlList) end if end open
on doItRightNow(buttonReturned, urlList) if buttonReturned is "クリップボードへ" then set the clipboard to (item 1 of urlList) else open location (item 1 of urlList) end if end doItRightNow
on chooseList(buttonReturned, fileName, stringList, urlList) tell application "Finder" to choose from list {"すべて"} & fileName default items {"すべて"} if result is not false then if (item 1 of result) is "すべて" then if buttonReturned is "クリップボードへ" then set the clipboard to stringList else repeat with theLoc in urlList open location theLoc end repeat end if else set theResult to (item 1 of result) repeat with i from 1 to (number of items of fileName) if theResult is (item i of fileName) then if buttonReturned is "クリップボードへ" then set the clipboard to (item i of urlList) else open location (item i of urlList) end if exit repeat end if end repeat end if end if end chooseList
tell application "System Events" open alias "保存された検索条件のパス"
tell process "Finder" tell window 1 tell group 1 of group 2 of group 1 of splitter group 1 try click button "編集" delay 1 tell text field 1 of group 1 -- ??? end tell end try end tell end tell end tell end tell
これで検索語句の入力欄(text field 1)が表示され、
set value of text field 1 of group 1 to "XYZ"
で、検索語句をスクリプトで直接設定することはできています。が、 text field 1 がタイピングを受け付けるようにフォーカスを移動させ、 古い内容を全選択する方法がわかりません。
set focused of text field of group 1 to true では駄目だったし。どう書けばいいのでしょうか?
小ネタ。サービスメニューが使えないマカー用。などのアプリで、選択したテキストをgooDictに渡す。 tell application "System Events" to set frontApp to (name of (path to frontmost application)) tell application frontApp to activate delay 1 tell application "System Events" to keystroke "c" using command down delay 1 tell application "System Events" if (text of (the clipboard)) is not "" then set theWord to (text of (the clipboard)) as string tell application "gooDict" to activate tell process "gooDict" set value of combo box 1 of window 1 to theWord keystroke "e" using command down (* EtoJ→ keystroke "e" using command down Japanese→ keystroke "j" using command down JtoE→ keystroke "e" using {shift down, command down} *) end tell else return end if end tell
set the clipboard to "" set x to 0 tell application "System Events" repeat until ((the clipboard) is not "") or (x = 10) delay 1 keystroke "c" using command down set x to (x + 1) end repeat end tell the clipboard
デスクトップをftpアップロードするスクリプト on idle set UserName to "name" ---アカウント名 set UserPassword to "password" ---パスワード ---FTPサーバ名/ユーザ名/リモートディレクトリ、最後に"/"をつける set FTPaddress to "f999.aaacafe.ne.jp/public_html/"
set thePDFName to "screencapture" & ".pdf" set thePNGName to "screencapture" & ".png" do shell script "cd $HOME/Desktop; screencapture " & quoted form of thePDFName do shell script "cd $HOME/Desktop; sips -s format png " & quoted form of thePDFName & " --out " & quoted form of thePNGName do shell script "cd $HOME/Desktop; rm -f " & quoted form of thePDFName
tell application "URL Access Scripting" activate set fullPath to ((path to desktop) as text) & thePNGName set FTPURL to ("ftp://" & UserName & ":" & UserPassword & "@" & FTPaddress) upload file fullPath to FTPURL replacing yes with progress without binhexing quit end tell return 20 end idle
Finderで項目名をコピーしてSafariで検索しようとすると 濁点、半濁点が一文字として数えられてしまう問題で clipboard as text (as string) とすれば解決できることをさっき知ったので ついでにそのまま検索できるようにしてみました。
tell application "Finder" to activate set the clipboard to "" delay 1 tell application "System Events" tell process "Finder" set x to 0 repeat until ((the clipboard) is not "") or (x = 10) keystroke "c" using command down set x to (x + 1) delay 1 end repeat end tell end tell
set keyword to (the clipboard) as text set the clipboard to "" set the clipboard to keyword as text
(* クリップボードのテキストの各行をURLとしてブラウザで開くスクリプト *) on run set clipTexts to every paragraph of ((the clipboard) as text) set URLList to {}
repeat with clipParagraph in clipTexts if (clipParagraph as string) is not equal to ("" as string) then if clipParagraph starts with "ttp:" then set clipParagraph to "h" & clipParagraph else if not (clipParagraph contains "://") then set clipParagraph to "http://" & clipParagraph end if set URLList to URLList & clipParagraph end if end repeat
tell application "System Events" repeat with aURL in URLList activate set dialogResult to display dialog "Open as URL..." default answer aURL buttons {"キャンセル", "スキップ", "OK"} default button 3 if button returned of dialogResult is "OK" then try open location ((text returned of dialogResult) as string) with error reporting on error e beep display dialog "失敗しました:" & return & return & (e as Unicode text) buttons {"OK"} default button 1 giving up after 3 end try end if end repeat end tell
on open olist tell application "Finder" activate repeat with obj in olist set obj to (obj as string) set newNm to (characters 1 thru -((count ((name of file obj) as string)) + 1) of obj as string) & my sdt(creation date of file obj) & "ss.jpg" giconvert file obj type "JPEG" quality 50 image file newNm end repeat delete olist end tell end open
tell application "Finder" set olist to selection end tell
repeat with obj in olist tell application "Preview" activate open obj end tell
tell application "System Events" tell application process "Preview" pick menu item 8 of menu 3 of menu bar 1 tell sheet 1 of window 1 click pop up button 1 pick menu item 3 of menu 1 of pop up button 1 click button "保存" end tell pick menu item 5 of menu 3 of menu bar 1 end tell end tell end repeat
itune4.9からファイルタイプがMPEGだと読み込めなくなってMp3に変える必要ができました。 on open AAA tell application "Finder" repeat with BBB in AAA set creator type of BBB to "TVOD" set file type of BBB to "Mp3" end repeat end tell end open
on open AAA tell application "Finder" repeat with BBB in AAA set CCC to name of BBB as string if (creator type of BBB is "TVOD") or (creator type of BBB is "hook") then set creator type of BBB to "TVOD" set file type of BBB to "Mp3 " else display dialog "『" & CCC & "』" & "は音声ファイルじゃないかも?" buttons {"無視して変更", "除外して続行"} default button 2 set DDD to button returned of result if DDD = "無視して変更" then set creator type of BBB to "TVOD" set file type of BBB to "Mp3 " end if end if end repeat end tell end open
tell BBS "にちゃんねる" tell board "新・mac" tell thread "おもろい、めずらしいアップルスクリプト発表会 6 " make new response with properties {content:"保守", name:"", mail:"sage"} end tell end tell end tell
set target_refs to {} -- サブフォルダの中身も含むすべてのドロップされた項目のリスト
(* ドロップされた項目のリストを作成 *) repeat with an_alias in dropped_alias_list if the class of the item an_alias is folder then set the end of the target_refs to the folder an_alias -- 無駄な処理 set the target_refs to the target_refs & the entire contents of the folder an_alias -- (A) else set the end of the target_refs to the item an_alias end if end repeat
(* 作成したリストのすべての要素に対してクリエータ設定 *) repeat with an_item in target_refs if the class of the an_item is not folder then -- (A) でフォルダもリストに入るから... (* クリエータを設定する処理(略) *) end if end repeat
set a to (|numbertochoose| of parameters) as integer →消える set a to (|numberToChoose| of parameters) as integer →消えない set a to (|NUMBERTOCHOOSE| of parameters) as integer →消えない
set window_list to {} tell application "Finder" set app_list to name of every process whose visible is true end tell repeat with theapp in app_list try tell application theapp set theapp_list to (name of every window whose name is not "") end tell set window_list to window_list & theapp_list end try end repeat choose from list window_list
tell application "Safari" activate tell application "System Events" keystroke "l" using command down keystroke "b" using {command down, shift down} keystroke "/" using command down end tell end tell
正規表現じゃないならAppleScript's text item delimitersでできそう。
on replaceText(inText, inOld, inNew) set OriginalDelimiters to AppleScript's text item delimiters set AppleScript's text item delimiters to {inOld} set workData to text items of inText set AppleScript's text item delimiters to {inNew} set workData to workData as string set AppleScript's text item delimiters to OriginalDelimiters return workData end replaceText set theText to my replaceText("名称未設定OSX.txt", "OSX", "OS9")
>>152ありがとうございます。 on replaceText(inText, inOld, inNew)は使い方がよく分からなかったので (なんかドロップレットの中で使うと?エラーがでます) ↓結局こうなりました。
set kara to text item delimiters of AppleScript set motonamae to name of hensuu set text item delimiters of AppleScript to sakujo set sakujogonamae to (every text item of motonamae) set text item delimiters of AppleScript to tuika set name of hensuu to sakujogonamae as string set text item delimiters of AppleScript to kara
tell application "Finder" set myFinderSelection to selection repeat with I in myFinderSelection tell application "DropStuff" to stuff (I as alias) format StuffIt to my myGetDesktopFolder() end repeat end tell
on myGetDesktopFolder() tell application "Finder" return (desktop as alias) end tell end myGetDesktopFolder
open for access で delimiterをascii character 12にしてリストとして読み、 as textでテキスト変換するとか。あるいは伝統的手法でAppeScript's text item delimitersを ascii character 12にするとかやろうとしたけど、これっ てなんかうまくいかないね。
on open dropItems tell application "Finder" repeat with anItem in dropItems set theName to name of anItem if theName ends with ".tar.gz" then set name of anItem to my replace(theName, ".tar.gz", ".tgz") else if name of anItem ends with ".tar.bz2" then set name of anItem to my replace(theName, ".tar.bz2", ".tbz") end if end repeat end tell end open to replace(theText, replaceStr1, replaceStr2) set oldDel to AppleScript's text item delimiters set AppleScript's text item delimiters to replaceStr1 set theText to every text item of theText set AppleScript's text item delimiters to replaceStr2 set theText to theText as string set AppleScript's text item delimiters to oldDel return theText end replace
リストを逆順で処理するのは>185の一部をかえる場合次のようにする repeat with theIndex from (count (dropItems)) to 1 by -1 set anItem to item theIndex of dropItems display alert anItem end repeat あとはiTunesで開けばいいんじゃないかな?
on maxSort(aList) copy aList to theList set sum to count theList repeat with i from 1 to sum - 1 repeat with j from i + 1 to sum if item i of theList > item j of theList then set temp to item i of theList set item i of theList to item j of theList set item j of theList to temp end if end repeat end repeat return theList end maxSort
set oldDelims to AppleScript's text item delimiters set AppleScript's text item delimiters to {ASCII character 10} set listString to (theList as string) set newString to do shell script "echo " & quoted form of listString & " | sort -f" set newList to (paragraphs of newString) set AppleScript's text item delimiters to crlfStr set newString to (newList as string) set AppleScript's text item delimiters to oldDelims
Finderでselectionを使うとき、name of selection ってすると、選択してるファイルの 名前がリストで返ってきますよね? でも、selectionを変数に入れて name of my_sel とかってするとエラーが出ます、よね? あと、name of (item 1 of my_sel) や、name of (item 1 of selection) は、両方ちゃんと ファイル名を取得できますが、name of (every item of my_sel) は、 name of (every item of selection) と違って、エラーが出ます・・・よね?
"Show Raw File" 01 tell application "iPhoto" activate try copy (my selected_images()) to these_images if these_images is false or (the count of these_images) is not 1 then error "一個づつしか調べきらんと" set this_image to item 1 of these_images set textName to (image filename of this_image) as text set textName to my replaceW(textName, ".jpg", ".nef") set textPath to (image path of this_image) as text set textDate to (date of this_image) as text set oldDel to AppleScript's text item delimiters set AppleScript's text item delimiters to " " set textDate to text item 1 of textDate set textDate to my replaceW(textDate, "-", "/") set AppleScript's text item delimiters to "/" set libraryName to text item ((count text item of textPath) - 4) of textPath set AppleScript's text item delimiters to libraryName set textPath to text item 1 of textPath set AppleScript's text item delimiters to oldDel set textPath to textPath & libraryName & "/" & textDate & "/Originals/" & textName
--"Show Raw File"02 try set this_imagefile to ((textPath) as POSIX file) as alias on error try set changePath to text item ((count item of textPath) - 5) of textPath & text item ((count item of textPath) - 4) of textPath & ".nef" set textPath to my replaceW(textPath, changePath, ".nef") set this_imagefile to ((textPath) as POSIX file) as alias on error display dialog "RAWファイルじゃなかろごたぁ" end try end try
on error error_message number error_number if the error_number is not -128 then display dialog error_message buttons {"Cancel"} default button 1 end if end try end tell
--"Show Raw File"03 tell application "Finder" activate set visible of (every process whose visible is true and frontmost is false) to false reveal this_imagefile end tell
on selected_images() tell application "iPhoto" try set these_items to the selection if the class of item 1 of these_items is album then error return these_items on error return false end try end tell end selected_images
on replaceW(src, tg, rp) set oldDel to AppleScript's text item delimiters set AppleScript's text item delimiters to tg set myList to text items of src set AppleScript's text item delimiters to rp set myText to myList as string set AppleScript's text item delimiters to oldDel return myText end replaceW
tell application "Mail" set selectedMails to selection set msg to item 1 of selectedMails set subj to subject of msg set mid to id of msg end tell
set mailURL to do shell script "mdfind -onlyin ~/Library/Mail 'kMDItemFSName == ¥"" & mid & ".emlx¥"'|head -1"
set mailURL to "file://" & mailURL
tell application "iCal" activate tell calendar 1 set theEv to make event at end of every event with properties {summary:subj, start date:current date, end date:(current date) + 3600, url:mailURL} show theEv end tell end tell
>>272 tell application "Finder" if (version as string) starts with "10." then else tell application "IP Messenger 1.33r2" activate end tell end if end tell 起動項目につっこんで上手くいきました ?ォ!
set dateText to text returned of (display dialog "Input date" default answer "2005/11/22") set theDate to date dateText display dialog "Date" default answer (theDate as string)
最近のバージョンのOSXならISO8601フォーマットが使える。 -- ISO8601 format -> AS date class "2000-11-16T19:20:00" as <<class isot>> as date -- AS date class -> ISO8601 format ((current date) as <<class isot>>) as string http://www.w3.org/TR/NOTE-datetime
簡易ラジオサーバーを作っているのですが、定期再起動の時に再起動後SHOUTCast(UNIX実行ファイル)を実行しようと思い、 tell application "Terminal" do shell script "cd /volumes/os10.3/library/webserver/shoutcast-1-9-5-macosx/" do script with command "./sc_serv" end tell としても必ず新規窓が作られて一つ目と二つ目のコマンドが別窓で処理されてエラーが返ってきます。 このファイルはただ本体をダブルクリックして実行させても設定データが読み込まれないのでターミナルでの起動をしたいのです。
set x to NUM repeat x times tell application "System Events" tell process "Finder" key code 28 using {command down, option down, control down} end tell end tell end repeat
ライブラリのバックアップをとる簡単なAppleScriptを書いてみた。 tell application "Finder" activate make new folder at desktop set newFolder to result with timeout of 1200 seconds set name of newFolder to "Backup" set targetfile to folder "Library" of home end timeout duplicate targetfile to folder "Backup" of desktop end tell
dittoというのはAppleScriptのコマンドではなくて、 Mac OS XのUNIX部分が備えているコマンドです。 Mac OS X用にリソースフォークが扱えるように拡張してあります。 AppleScriptから使うならdo shell scriptで呼び出しですね。 アクセス権の事を考えるとrootログインかsudoで実行したほうがよいのだと思います。
on renice(theApplicationName, thePriority) --tell application "Finder" to set theApplicationName to name of current application tell application "System Events" --set theApplicationName to name of current application set i to item 1 of (every process where name is theApplicationName) display dialog name of i & ":" & (unix id of i) as string do shell script "renice " & thePriority & " -p " & (unix id of i) as string end tell end renice
set breed_all to every breed of pig set tempValue to 0
repeat with theBreed in breed_all set theUmami to (umami of (toro of theBreed)) as number if theUmami >= tempValue then -- set tempValue to theUmami set niku_best to name of theBreed end if end repeat
昨日違うスレで、フォルダの中の変更日より一ヶ月以上経過しているファイルを削除するスクリプトを教えていただきましたが、フォルダの中の一番上層の階層に対しては機能するのですが2番目以降の階層に対しては機能しません。 いろいろ書き換えて試したのですが、うまくいきません。どのように書き直すとうまくいくのでしょうか、勉強不足で申し訳ありませんが教えてください。 昨日教えていただいたところまでのスクリプトは以下です。 on open d_items del_old(d_items) end open
on del_old(d_items) tell application "Finder" repeat with a_file in d_items if folder (a_file as string) exists then set sub_items to every item of folder (a_file as string) my del_old(sub_items) else set cr_date to current date set md_date to (modification date of a_file) if (year of md_date) < (year of cr_date) then move a_file to trash else if (month of md_date) < ((month of cr_date) - 1) then move a_file to trash else if (month of md_date) < (month of cr_date) and (date of md_date) < (date of cr_date) then move a_file to trash end if end if end repeat end tell end del_old
352さん、 if (year of md_date) < ((year of cr_date) - 1) then move a_file to trash else if (year of md_date) = ((year of cr_date) - 1) and ((month of md_date) - 12) < (month of cr_date) then move a_file to trash なら年が変わっても大丈夫?
if (year of md_date) < ((year of cr_date) - 1) then move a_file to trash else if (year of md_date) = ((year of cr_date) - 1) and ((month of md_date) - 11) < (month of cr_date) then move a_file to trash else if (year of md_date) = ((year of cr_date) - 1) and ((month of md_date) - 11) = (month of cr_date) and (day of md_date) < (day of cr_date) then move a_file to trash こうしないとだめですね。
一ヶ月以上という設定は if (year of md_date) < ((year of cr_date) - 1) then move a_file to trash else if (year of md_date) = ((year of cr_date) - 1) and ((month of md_date) - 11) < (month of cr_date) then move a_file to trash else if (year of md_date) = ((year of cr_date) - 1) and ((month of md_date) - 11) = (month of cr_date) and (day of md_date) < (day of cr_date) then move a_file to trash else if (year of md_date) = (year of cr_date) and (month of md_date) < ((month of cr_date) - 1) then move a_file to trash else if (year of md_date) = (year of cr_date) and (month of md_date) = ((month of cr_date) - 1) and (date of md_date) < (date of cr_date) then move a_file to trash ここまでしないとだめですかね?
set md_date to (modification date of a_file) set check_date to (current date) - 60 * 60 * 24 * 30 if check_date > md_date then --move a_file to trash display alert ("delete" & return & a_file as string) end if こうかな。
on open theItemList tell application "Finder" my moveToTrash(theItemList) end tell end open
on moveToTrash(theItemList) tell application "Finder" set theFileList to every file of theItemList repeat with theFile in theFileList if ((current date) - (modification date of theFile)) > days * 30 then move theFile to trash end if end repeat my moveToTrash((every folder of theItemList)) end tell end moveToTrash
on open d_items del_old(d_items) end open on del_old(d_items) repeat with a_file in d_items set theInfo to info for a_file without size if folder of theInfo then tell application "Finder" set checkFiles to entire contents of folder (a_file as string) end tell else tell application "Finder" set checkFiles to {file (a_file as string)} end tell end if tell application "Finder" repeat with a_file in checkFiles if folder is not class of a_file then set md_date to (modification date of a_file) set check_date to (current date) - days * 30 if check_date > md_date then --move a_file to trash display alert ("delete" & return & a_file as string) end if end if end repeat end tell end repeat end del_old 359のが短くていいけど普通に書いてみた。 daysなんて定数あるんだね。知らんかった
>>360 あー、my moveToTrash((every folder of theItemList)) の部分は set theFolderList to every folder of theItemList repeat with theFolder in theFolderList my moveToTrash(theFolder) end repeat にしないと無限ループに陥ってしまうわ。
自動的に、言語環境をドイツ語に変えてくれるスクリプトを作りたくて tell application "System Events" tell application process "System Preferences" click radio button "言語" of tab group 1 of window "言語環境" click pop up button 1 of tab group 1 of window "言語環境" pick menu item "ドイツ語" of menu of pop up button 1 of tab group 1 of window "言語環境" end tell end tell tell application "System Preferences" to quit としてみたのですがこれだと並べ替えリストの順序をかえるだけで だめなのです。。 環境設定の言語環境の言語順の順番をscriptで入れ替えることはできないのでしょうか?
on run return end run on idle return 536870909 end idle on quit tell application "Finder" set itemsAlias to every item of (folder "ログアウト項目" of folder (path to library folder from user domain)) if (count of itemsAlias) is greater than 0 then try display dialog "ログアウト項目があります" & return & return & "3秒後に開きます" buttons {"キャンセル", "開く"} default button 1 with icon stop giving up after 3 open itemsAlias end try end if end tell continue quit end quit
--ディスプレイスリープまでの時間を1分に変更。最後に設定を元に戻す。 set curDRW to paragraph 1 of (do shell script "pmset -g ps")
tell application "Finder" set plistFile to file "com.apple.PowerManagement.plist" of folder "SystemConfiguration" of folder "Preferences" of (path to library folder) set plistFile to plistFile as string end tell
tell application "System Events" if curDRW ends with "AC Power'" then set displaySleepTimer to (|Display Sleep Timer| of |AC Power| of ((value of property list item "Custom Profile" of property list file plistFile) as record)) as integer --↑ここをdefauts readで取得する方法はないですか? set curOpt to "c" doPMSet(displaySleepTimer, curOpt) of me else if curDRW ends with "Battery Power'" then set displaySleepTimer to (|Display Sleep Timer| of |Battery Power| of ((value of property list item "Custom Profile" of property list file plistFile) as record)) as integer set curOpt to "b" doPMSet(displaySleepTimer, curOpt) of me else return end if end tell
on doPMSet(theTime, theOption) do shell script "sudo pmset -" & theOption & " displaysleep 1" user name (do shell script "whoami") password "[管理者パスワード]" with administrator privileges delay 63 --1分3秒待って元の設定に戻す。 do shell script "sudo pmset -" & theOption & " displaysleep " & theTime user name (do shell script "whoami") password "[管理者パスワード]" with administrator privileges end doPMSet
do shell script ("pmset dim 1") password "your_password" ¬ with administrator privileges delay 90 do shell script ("pmset dim 30") password "your_password" ¬ with administrator privileges
tell application "System Preferences" activate set current pane to pane "com.apple.preference.displays" end tell tell application "System Events" tell process "System Preferences" tell tab group 1 of window 1 click radio button "Display" tell table 1 of scroll area 1 of group 1 select row 9 -- modify this value end tell end tell end tell end tell tell application "System Preferences" to quit
(1) Finderより取得(10.4のみ動作可能) tell application "Finder" to bounds of the window of the desktop 命令的には、Finderの背景としてあるデスクトップをウインドウとして見て、 そのウインドウの大きさを取得しているらしい。 返り値はFinderと同じ意味の数値のリストらしく、1024x768なら、{0,0,1024,768}となる。 たぶん、432にとっては一番簡単な方法。
tell application "System Events" tell process "SystemUIServer" tell first menu bar set menuExtraList to every menu bar item repeat with aExtra in menuExtraList try tell aExtra click try tell front menu tell menu item "ログインウインドウ..." to click return 0 end tell on error click end try end tell end try end repeat end tell end tell beep end tell
ウソ情報を出してしまった441です。 >>444のを試してみたのだが…4番目のevery menu bar itemでエラーに。 バックグラウンドのアプリケーションのメニューを引っ張り出すっていう方法は すごく参考になったけども、SystemUIServerでevery menu bar の取得が出来てない模様。 (Prove Menu Bar.applescriptのtell processに、"SystemUIServer"を指定して確認) これ、OSのバージョンの問題かな。10.3.9だからダメなのかも。 >>444が動いた方、環境をぜひ教えて下さいな。
set a to text returned of (display dialog "半角数字でも全角数字でも" default answer "") set b to "" repeat with x in (text items of a) if x contains "0" or x contains 0 then set b to b & "0" if x contains "1" or x contains 1 then set b to b & "1" if x contains "2" or x contains 2 then set b to b & "2" if x contains "3" or x contains 3 then set b to b & "3" if x contains "4" or x contains 4 then set b to b & "4" if x contains "5" or x contains 5 then set b to b & "5" if x contains "6" or x contains 6 then set b to b & "6" if x contains "7" or x contains 7 then set b to b & "7" if x contains "8" or x contains 8 then set b to b & "8" if x contains "9" or x contains 9 then set b to b & "9" if x contains "−" or x contains "-" then set b to b & "-" if x contains "." or x contains "." then set b to b & "." end repeat set a to b as number
ファストユーザースイッチを自動で切り替えてかつ、切り替え時に safariを常時あげてくれるスクリプトをがんばって書いてます。 set h to do shell script "whoami" set newUser to "hogehoge1" set userName to "hogehoge" set newUser to do shell script "id -u " & userName do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID " & newUser do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"
property temp : "" on idle tell application "iTunes" tell current track set newtemp to (artist as string) & ". " & (name as string) set tempgenre to genre end tell end tell if newtemp is not equal to temp then if tempgenre is in {"Drum & Bass", "Drum'n'Bass", "Electronic", "Electronica/Dance", "House"} then set tempvoice to "Zarvox" else set tempvoice to "Vicki" end if tell application "iTunes" repeat with i from 0 to 8 set sound volume to sound volume - i delay 0.1 end repeat end tell say newtemp using tempvoice set temp to newtemp tell application "iTunes" repeat with i from 0 to 8 set sound volume to sound volume + i delay 0.1 end repeat end tell end if return 4 end idle
if ((creator type) of obj is "TVOD") or ((file type) of obj is "dvc!" or "MooV") tell application "QuickTime Player" activate set high quality of track "ビデオ トラック" of movie 1 of window 1 to true end tell end if
tell application "QuickTime Player" tell movie 1 set dimensions to {640, 480} set high quality of tracks to true set deinterlace fields of tracks to true end tell end tell
Safariでやってみた tell application "Safari" make new document with properties {URL:"http://checkip.dyndns.org/"} set theWin to id of window 1 delay 2--ロード待ち(手抜き) set myIP to word 4 of text of document of window id theWin close window id theWin end tell
tell application "Safari" open location "http://phobos.apple.com/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewTopSongs/" delay 5 end tell say "Welcome to iTunesMusicStore Japan today's top 100." delay 0.5 say "Okay, now let's start to count down the top 100 songs." tell application "iTunes" repeat with i from 100 to 1 by -1 say "today's number" & i set (sound volume) to 80 play repeat until (player position ? 27) delay 1 end repeat if (i > 1) then set (sound volume) to 50 say "okay, Let's go to the next tune." pause next track end if end repeat end tell
on run tell application "iTunes" set theTrack to item 1 of selection if lyrics of theTrack is "" then beep return end if OpenQtp(location of theTrack, lyrics of theTrack) of me end tell end run
on OpenQtp(theFile, theLyrics) tell application "QuickTime Player" activate open theFile --歌詞埋め込み set the clipboard to theLyrics as string select all movie 1 add movie 1 with scaled set dimensions of last track of movie 1 to {320, 240} set position of last track of movie 1 to {0, 0} --TextFrame更新 set scroll of frames of last track of movie 1 to {scroll in, scroll continuous} --後処理 select none movie 1 rewind movie 1 start movie 1 end tell end OpenQtp
>>560 tell application "System Preferences" activate reveal anchor 1 of pane id "com.apple.preference.startupdisk" --reveal anchor 1 of pane "起動ディスク" end tell
tell application "System Events" tell process "System Preferences" repeat until (exists button "Mac OS J1-9.2.2 (Macintosh HD 上)" of radio group 1 of scroll area 1 of group 1 of splitter group 1 of window 1) delay 1 end repeat click button "Mac OS J1-9.2.2 (Macintosh HD 上)" of radio group 1 of scroll area 1 of group 1 of splitter group 1 of window 1 delay 1 click button 6 of window 1 -- click button "再起動..." of window 1 repeat until (exists sheet 1 of window 1) delay 1 end repeat keystroke return end tell end tell
ボタンをクリックしてシステムを選択する部分だけどうしても言語環境に依存せざるを得ませんでした。 OS 9が必ず「button 2」になると決まっていればできなくもないけど。
click item 1 of (every button whose name contains "9.2") of radio group 1 of scroll area 1 of group 1 of splitter group 1 of window 1
set theSource to choose folder with prompt "Source:" set theDestination to choose folder with prompt "Destination:" tell application "Finder" to set theFiles to every file of folder theSource whose name ends with ".txt" repeat with aFile in theFiles set newName to do shell script "echo " & name of aFile & " | sed 's/\\.txt/.rtf/'" tell application "Finder" set newFile to (make new file at folder theDestination with properties {name:newName}) as string open aFile end tell tell application "TextEdit" activate tell application "System Events" keystroke "t" using {command down, shift down} end tell save front document in newFile as alias close front document end tell end repeat
特定のフォルダーからファイル名のリストを取得するスクリプトなんですが、 OS10.3から10.4にバージョンを上げたところ リストがおかしくなってしまいました。 10.3の時は「10001.jpg」 10.4では「1 0 0 0 1 . jpg」 となってしまいます。何が原因か全く検討がつきません。 どなたか、原因の解る方がおられましたらアドバイスいただけないでしょうか。 宜しくお願いします。 copy cell "basepath" of current record to theBasePath set aPath to theBasePath as string set aFolderA to (aPath & "gazou:") as alias set aContA to "" as text tell application "Finder" try move file (aPath & "list_full.txt") to trash end try set aListA to (every file of aFolderA) repeat with aFile in aListA set My_Name to name of aFile set aContA to (aContA & My_Name & return) end repeat try set fileNum to open for access file (aPath & "list_full.txt") with write permission write (aContA) to fileNum close access fileNum end try end tell
このスクリプトで問題無く書く出せるのですが、 シェルでシンプルにしようと書き出し部分を下記2行のような方法で 行えると思ったんですが、上手く行きません。何がいけないんでしょうか。 どなたかご教授ねがえたらアドバイス願いします。 set A to B do shell script "cd ~/desktop; echo " & A & " > a.txt" ------------------------------------------------------------------- set A to readSomeLines(choose file of "", 50) set aPath to "Macintosh HD:Users:Shared:testdb:" try move file (aPath & "list.txt") to trash end try try delete file (aPath & "list.txt") end try try set fileNum to open for access file (aPath & "list.txt") with write permission write (A) to fileNum close access fileNum end try
on readSomeLines(theFile, theLine) set textData to "" try open for access theFile repeat theLine times set textData to textData & (read theFile until return) end repeat end try close access theFile return textData end readSomeLines
--Finderで選択中の物の中で.mp3で名前が終わるファイルの --クリエータとファイルタイプを変更するスクリプト tell application "Finder" repeat with aFile in (every file of selection whose name ends with ".mp3") set creator type of aFile to "TVOD" set file type of aFile to "MPEG" end repeat end tell
結局、10.4.6/AppleScript 1.10.6/スクリプトエディタ 2.1.1の環境では、 下記のような物しか動かないみたいだな。 tell application "Finder" repeat with aFile in (selection as list) if name of aFile ends with ".mp3" then set creator type of aFile to "hook" set file type of aFile to "MPG3" end if end repeat end tell
レス違いだったら申し訳有りません。 ファイルメーカー用に使用するスクリプととし用意した物なんですが、 (read theFile until return)の部分を受け付けてくれません。 何故受け付けてくれないのかが解りません。 スクリプトエディタ上では問題無く動くんですが・・・。 詳しい方、アドバイスいただけないでしょうか。宜しくお願いします。
set A to readSomeLines(choose file of "", 200)
on readSomeLines(theFile, theLine) set textData to "" try open for access theFile repeat theLine times set textData to textData & (read theFile until return) end repeat end try close access theFile return textData end readSomeLines
>>619 アドバイスを基に修正したのですが、更に上手く行かない箇所があります。 set A to readSomeLines(theBasePath of "", 200) なんですが、set A to readSomeLines(choose file of "", 200)を基に 別途取得したパスを使って指定のファイルから読み込みしたいのですが、 何が足りないんでしょうか。 へたれですみませんが、アドバイスお願いします。
copy cell "path" of current record to theBasePath
set A to readSomeLines(theBasePath of "", 200) do shell script "cd ~/desktop/imageget/script; echo " & quoted form of A & " > C.txt"
on readSomeLines(theFile, theLine) tell application "Finder" set textData to "" try open for access theFile repeat theLine times set textData to textData & (read theFile until return) end repeat end try close access theFile return textData end tell end readSomeLines
628です。URL Access Scriptingだと進行状況がわからない&キャンセルできないので ターミナルでcurl使ってダウンロードすることにしました。 保存するファイル名を指定できるAppleScript対応ダウンローダーってありますかね。 YouTubeからファイル名をタイトルにしてムービフォルダに動画を保存するスクリプト。 日本語ファイル名は試してない。 tell application "Safari" set theURL to URL of document 1 set theTitle to name of document 1 set theTitle to text 11 thru -1 of theTitle end tell if theURL starts with "http://www.youtube.com/watch?v=" then --動画表示ページからURLを抜き出す set theFLVURL to do shell script "curl --max-time 30 " & quoted form of theURL & " | perl -e '$data = join(q||,<>); ($tmp, $key) = split( q{player.swf?}, $data ); ($key) = split( q{\"},$key ); print qq{http://www.youtube.com/get_video$key}; '" --保存フォルダ tell application "Finder" set theFolder to (home as string) & "Movies:" set theSavePath to theFolder & theTitle & ".flv" set isExist to exists (file theSavePath) end tell if isExist then say "already exists " & theTitle else tell application "Terminal" do script "curl -L -o " & quoted form of POSIX path of theSavePath & " " & quoted form of theFLVURL & "; say finish download" end tell end if end if
--Finder 上でアプレットを選択して実行 tell application "Finder" activate set applets to {} set appNames to "" repeat with j in (selection as list) tell application "System Events" set pkBool to package folder of (j as alias) set creatorType to creator type of (j as alias) end tell if (pkBool is true) and (creatorType is "aplt") and (exists folder "Japanese.lproj" of folder "Resources" of folder "Contents" of (j as alias)) is false then set applets to applets & (j as alias) set appNames to appNames & (name of (j as alias)) & return end if end repeat if not applets is {} then display dialog appNames & return & "に Japanese.lproj を追加します。" repeat with jj in applets make new folder at folder "Resources" of folder "Contents" of (jj as alias) with properties {name:"Japanese.lproj"} end repeat display dialog "完了" buttons {"OK"} default button 1 giving up after 1 else display dialog "Japanese.lproj を追加する必要がないようです。" buttons {"キャンセル"} default button 1 giving up after 2 end if end tell
if (pkBool is true) and ((creatorType is "aplt") or (creatorType is "dplt")) and (exists folder "Japanese.lproj" of folder "Resources" of folder "Contents" of (j as alias)) is false then
class curlのカッコが凄い事になってるな。 それを避けて扱いやすくする方法がある。 下記の場合、コンパイルする時に、その環境にiCabがインストールされている事が必要。
tell application "Firefox" using terms from application "iCab" set urlStr to URL of window 1 end using terms from end tell set htmlStr to do shell script "curl -s " & urlStr
set aPath to (theBasePath & "Image:General:") as string set aFolderA to POSIX path of ((aPath & "photo:") as alias) set aFolderB to POSIX path of (aPath as alias) set aContA to "" as text set aContA to do shell script "ls -v "& aFolderA &" > "& aFolderB &"/list.txt" end tell
--//ゴミ箱の内容を取得 tell application "Finder" set |項目リスト| to (every item of trash) set |項目テキスト| to ("" as Unicode text) repeat with |項目| in |項目リスト| set |項目テキスト| to |項目テキスト| & return & (POSIX path of (|項目| as alias)) as Unicode text end repeat end tell --//空なら終了 if |項目テキスト| is equal to ("" as Unicode text) then display alert "ゴミ箱は空です" message "" as informational buttons {"終了"} default button 1 giving up after 3 return 0 end if
--//処理を選択させる try display alert "ゴミ箱を空にします!!" message "ゴミ箱の内容:" & (|項目テキスト| as string) as critical buttons {"しない", "ゴミ箱を開く", "OK"} cancel button 1 default button 3 set |選択処理| to (button returned of result) on error return 0 end try --//選択に合わせて処理 if |選択処理| is equal to "OK" then --//ゴミ箱の内容を削除 set |パスリスト| to every paragraph of |項目テキスト| repeat with |パス| in |パスリスト| if (|パス| as Unicode text) is not equal to ("" as Unicode text) then do shell script "rm -rf '" & |パス| & "'" end if end repeat else --//ゴミ箱を開く tell application "Finder" open trash end tell end if
>>753 --最後に再生した日を変更 tell application "iTunes" set seltrack to a reference to selection repeat with x in seltrack set pldate to ((played date) of x as string) if pldate is "missing value" then set pldate to (current date) as string set newdate to text returned of (display dialog "最後に再生した日を変更" default answer pldate) set (played date) of x to date newdate end repeat end tell
activate application "iChat" tell application "System Events" tell process "iChat" try set tbl to table 1 of scroll area 1 of window 1 set tblRow to row of tbl set num to number of tblRow display dialog num & "人" end try end tell end tell
-- 検索ワードに1~5を入力 repeat with i from 1 to 5 do JavaScript "document.f.q.value = " & i & ";" in document 1 delay 1 end repeat
--ウェブ全体から検索 日本語のページを検索のトグル do JavaScript "document.f.lr[1].checked = true;" in document 1 delay 1 do JavaScript "document.f.lr[0].checked = true;" in document 1 delay 1 do JavaScript "document.f.lr[1].checked = true;" in document 1
--検索実行 do JavaScript "document.f.submit();" in document 1 end tell
(* sdefMerge.applescript *) -- 1/2 set suiteTags to {} set suiteObjects to {}
do shell script "ls /tmp/*.sdef" repeat with sdef in paragraphs of the result
set FH to open for access (sdef as POSIX file) set x to read FH using delimiter "<" close access FH
set {theSuite, inDepth} to {"", 0} repeat with i in x if inDepth < 2 then if i begins with "suite" then if (i as text) is not in suiteTags then set theSuite to theSuite & "<" & i as text set end of suiteTags to i as text set inDepth to 2 else set inDepth to 3 end if end if
-- 2/2 else if inDepth = 2 then if i begins with "/suite" then set theSuite to theSuite & "<" & i as text set end of suiteObjects to theSuite set theSuite to "" set inDepth to 1 else set theSuite to theSuite & "<" & i as text end if else if inDepth = 3 then if i begins with "/suite" then set inDepth to 1 end if end repeat -- with i
end repeat -- with sdef
-- set line1 to "<?xml version=¥"1.0¥" encoding=¥"UTF-8¥"?>" set line2 to "<!DOCTYPE dictionary SYSTEM ¥"file://localhost/System/Library/DTDs/sdef.dtd¥">"
set outputFileRef to (choose file name default name "Various Suites.sdef" default location (path to desktop folder))
set AppleScript's text item delimiters to return set suiteObjects to suiteObjects as text set AppleScript's text item delimiters to ""
set FH to open for access outputFileRef with write permission write line1 & return & line2 & return & "<dictionary>" & suiteObjects & "</dictionary>" to FH close access FH
tell application "Script Editor" to open outputFileRef
昔再生してる曲のアートワークをDragThingのゴミ箱アイコンにしてたので それをちょっと改造してみた。別途osaxが必要です。 --iTunesで再生してる曲のアートワークをデスクトップピクチャにする --必要なosax GraphicsImporter OSAX --http://www.azug.gr.jp/~h-abe/freeware/gio/index.ja.html tell application "iTunes" set theCurrentTrack to current track try set theArtwork to data of artwork 1 of theCurrentTrack on error error_message return -1 end try end tell -- iTunes7で取得したアートワークは形式不明で変換しないと駄目みたいだった -- 昔埋め込んだのはpictで取り出せるけどpictはデスクトップに貼れないみたい try set theArtwork to giconvert theArtwork type "JPEG" --resolution {72, 72} on error error_message return -1 end try set theFolder to path to desktop as string set theHFSFile to theFolder & "iTunes_Artwork_to_Desktop.pict" set refNum to open for access theHFSFile with write permission if refNum > 0 then write theArtwork to refNum close access refNum else return -1 --アートワークを保存できなかったので終了 end if tell application "Finder"--PICT、TIFFは設定できないみたい set desktop picture to theHFSFile as alias end tell
set {y, m, d, w, h, min, sec} to my date2list((current date)) if h < 6 then display dialog "The date has been changed already." & return & "Do you want to overwrite the date as it is still on the previous date?" buttons {"No", "Yes"} default button 2 giving up after 15 if button returned of result is not equal to "No" then set {y, m, d, w, h, min, sec} to my date2list((current date) - h * hours - min * minutes - sec - 60) end if
set wkd to item w of {" (Sun)", " (Mon)", " (Tue)", " (Wed)", " (Thu)", " (Fri)", " (Sat)"} set sdate to "" & y & "-" & m & "-" & d & wkd
sdate
on date2list(aDate) if class of aDate = date then set theDate to aDate else set theDate to current date end if tell theDate to return {year, its month as number, day, its weekday as number, its hours, its minutes, its seconds} end date2list
tell application "System Events" tell application process "Preview" tell application "Preview" to activate delay 0.5 keystroke "n" using command down delay 0.5 end tell end tell
tell application "iTunes" set seltrack to a reference to selection set theartwork to data of artwork 1 of item 1 of seltrack set the clipboard to theartwork end tell
tell application "System Events" tell application process "Preview" tell application "Preview" to activate delay 0.5 keystroke "n" using command down end tell end tell
tell application "System Events" tell application "Preview" to activate repeat if (visible of process "Preview") is true then exit repeat end repeat tell application process "Preview" delay 1 keystroke "n" using command down delay 1 end tell end tell
set current_track to item 1 of selection set artworkData to data of artwork 1 of current_track set imageFormat to format of artwork 1 of current_track as string
-- 画像フォーマットを判定 if imageFormat contains "JPEG" then set extension to ".jpg" else if imageFormat contains "PNG" then set extension to ".png" else return end if
-- ファイル名を設定 set art to artist of current track set alb to album of current track set file_name to (art & " - " & alb & " Artwork" & extension) as string
-- ファイル名に問題あるキャラクターを除去 if file_name contains "/" or file_name contains ":" then repeat with c from 1 to length of (file_name as string) if item c of file_name = "/" or item c of file_name = ":" then set file_name to (text 1 through (c - 1) of file_name) & "_" & (text (c + 1) through length of file_name) end if end repeat end if
-- tmp にアートワークデータを書き出し set tempFile to ("tmp:" & "Artwork.bin" as string) set fileRef to open for access tempFile with write permission write artworkData to fileRef close access fileRef
-- アートワークデータから先頭222バイトを削りデスクトップに保存 do shell script "cd ~/desktop/ ; tail -c +223 " & quoted form of the (POSIX path of tempFile) & " > " & quoted form of (file_name)
>>843 複数の選択を可能にしたければ、 set seltrack to a reference to selection repeat with x in seltrack set artworkData to data of artwork 1 of x 以下同様に処理 end repeat
保存先の指定は、set savefolder to POSIX path of (choose folder) とでもする。
禁止文字の変換はこうすると文は短いが、、、 do shell script "echo " & quoted form of thename & " | sed s/'¥¥/'/_/g | sed s/'¥¥:'/_/g"
tmpを使わぬ処理は tell application "Finder" to set thefile to make new file at thepath with properties {name:ファイル名} set thefile to thefile as alias という風に、先に空のファイルを作ってから、 そこにopen for access〜のようにデータを書き込み、頭222Bを削る。
tell application "iTunes" set extension to ".jpg" set current_track to current track set track_loc to location of current_track end tell
tell application "Finder" set alb to name of (container of track_loc) set art to name of (container of (container of track_loc)) set file_name to (art & " - " & alb & " Artwork" & extension) as Unicode text end tell
set theDate to do shell script "date +%Y-%m-%d¥¥ ¥¥(%a¥¥)" set hr to (do shell script "date +%H") as number if hr < 6 then set theDate to (do shell script "date -r $(($(date +%s)-86400)) +%Y-%m-%d¥¥ ¥¥(%a¥¥)") end if theDate
-- "~/Library/Script/Load Script….scpt" property script_lib_location : (path to library folder from user domain as string) & "Application Support:Script Menu:"
(* On Run *)
tell application "Finder" set scriptsList to displayed name of files of alias script_lib_location set chosenFile to file (script_lib_location & (item 1 of my chooseFromBigList(scriptsList, 10, 1))) if name extension of chosenFile is not equal to "scpt" then return (open chosenFile) end tell
on chooseFromBigList(aList, itemsPerPage, startPage) set nextPageLabel to "[ Next page ] >>" set firstPagelabel to "[ First page ] >>" set totalItems to the length of aList set pageItems to itemsPerPage as integer set pagingOption to nextPageLabel
-- handling some likely errors... if totalItems < pageItems then return (choose from list aList) --with multiple selections allowed) if startPage > (totalItems div pageItems + 1) then error "Invalid argument: startpage=" & startPage end if
set topItemIdx to (startPage - 1) * pageItems + 1
if totalItems < (topItemIdx + pageItems) then -- here we've reached at the last page. set pagingOption to firstPagelabel if not totalItems = (topItemIdx + pageItems - 1) then set pageItems to totalItems mod pageItems end if
set theList to (items topItemIdx thru lastItemIdx of aList) & pagingOption
choose from list theList with title (topItemIdx & " - " & lastItemIdx & " of " & totalItems & " items" as string) default items {pagingOption} --with multiple selections allowed if the result = false then return false else if the last item of result = nextPageLabel then return my chooseFromBigList(aList, itemsPerPage, (startPage + 1)) else if the last item of result = firstPagelabel then return my chooseFromBigList(aList, itemsPerPage, 1) else return the result end if
--escape of file name set fileName to do shell script "echo " & quoted form of fileName & " | sed -e s/:/\\\\//g"
--make unique file name set myDir to ((path to home folder) as string) & mySave set fileNames to fileName & fileExt set i to 0
repeat while ((fileNames) is in (list folder myDir)) set i to i + 1 set fileNames to fileName & i & fileExt end repeat
--make file tell application "System Events" set theFile to make new file at end of folder myDir with properties {name:fileNames} set thePath to path of theFile end tell
--Internet Shortcut data(it needs to be saved by Shift-JIS & CRLF) set wMsg to "[InternetShortcut]" & (ASCII character 13) & (ASCII character 10) & "URL=" & tarURL & (ASCII character 13) & (ASCII character 10) do shell script "echo " & quoted form of wMsg & " | iconv -f UTF8 -t Shift-JIS > " & quoted form of (POSIX path of thePath)
--set comment tell application "Finder" set theFinderFile to file thePath set comment of theFinderFile to myComment end tell
tell application "Safari" to set aList to {(URL of document 1), (do shell script "echo " & quoted form of ((name of document 1) as Unicode text) & --改行 " | perl -pe 's/(^" & (ASCII character 128) & ".|" & (ASCII character 128) & (ASCII character 128) & "|:)/_/g'")} --改行 tell application "Finder" to (make new internet location file at (folder "BookMark" of (path to documents folder)) to --改行 (item 1 of aList) with properties {name:(item 2 of aList), comment:(text returned of (display dialog "コメントを入れてください" default answer ""))})
>>875 tell application "System Events" to tell process "TextEdit" to tell scroll area 1 of window 1 to set A to value of text area 1 tell application "Terminal" to do script A in window 1
でいいですかね?あんまUI Element使ったスクリプトって好きじゃないんですよ・・・
分かりやすい書き方だと tell application "System Events" tell process "TextEdit" tell scroll area 1 of window 1 set A to value of text area 1 end tell end tell end tell tell application "Terminal" to do script A in window 1
tell application "System Events" tell process "TextEdit" tell text area 1 of scroll area 1 of window 1 set A to value of attribute "AXSelectedText" end tell end tell end tell
tell application "Terminal" do script A in window 1 end tell
tell application "System Events" tell application "TextEdit" to activate tell process "TextEdit" to keystroke "c" using command down tell application "Terminal" to activate tell process "Terminal" keystroke "v" using command down keystroke return end tell end tell
tell application "System Events" tell application "Jedit X" to activate tell process "Jedit X" to keystroke "c" using command down tell application "Terminal" to activate tell process "Terminal" keystroke "v" using command down keystroke return end tell end tell
on adding folder items to open_folder after receiving target_items tell application "Finder" repeat with obj in target_items set name of obj to "*" & name of obj end repeat end tell end adding folder items to
tell application "iTunes" tell current EQ preset if not modifiable then error "The current preset cannot be modified." set preamp to my qroundFloat(preamp) set band 1 to my qroundFloat(band 1) set band 2 to my qroundFloat(band 2) set band 3 to my qroundFloat(band 3) set band 4 to my qroundFloat(band 4) set band 5 to my qroundFloat(band 5) set band 6 to my qroundFloat(band 6) set band 7 to my qroundFloat(band 7) set band 8 to my qroundFloat(band 8) set band 9 to my qroundFloat(band 9) set band 10 to my qroundFloat(band 10) end tell my checkEQLevels() end tell
---- Subroutines ---- on qroundFloat(aFloat) return aFloat div 0.25 * 0.25 end qroundFloat
on checkEQLevels() tell application "iTunes" to tell current EQ preset display dialog "........Preamp level: " & preamp & " dB" & return & " ..32 Hz band level: " & band 1 & " dB" & return & "..64 Hz band level: " & band 2 & " dB" & return & "125 Hz band level: " & band 3 & " dB 250 Hz band level: " & band 4 & " dB" & return & "500 Hz band level: " & band 5 & " dB" & return & "..1 kHz band level: " & band 6 & " dB ..2 kHz band level: " & band 7 & " dB" & return & "..4 kHz band level: " & band 8 & " dB" & return & "..8 kHz band level: " & band 9 & " dB 16 kHz band level: " & band 10 & " dB" buttons {"OK"} with title "iTunes EQ preset - " & its name with icon 1 end tell end checkEQLevels
-- カスタムアイコンがセットされていない限りpropertyのiconはmissing valueなので、 -- 対策... tell application "Finder" tell selection as list if its length < 1 then return 0 open information window of item 1 set infoWindow to name of the result end tell end tell
tell application "System Events" tell window infoWindow of process "Finder" set iconButton to a reference to button 2 of scroll area 1 if not focused of iconButton then click iconButton keystroke "c" using command end tell end tell
tell application "Finder" close window infoWindow end tell
>>928 まず set theList to {} と空のリストを宣言して、 set end of theList to hoge と、なにかを順次格納していく。 -- 検証コード set theList to {} set end of theList to {1, 3, 5} set end of theList to {2, 4, 6} theList
(************************************************************************************* FinderウインドウをOS 9のポップアップウインドウのようにするスクリプト 自動的に終了しないアプリケーションとして保存する事 *************************************************************************************) on run return end run on idle try with timeout of 35791394 seconds tell application "Finder" set |window list| to every Finder window repeat with |Finder window| in |window list| if (frontmost is false) or ((index of |Finder window|) is not 1) then set (collapsed of |Finder window|) to true end if end repeat end tell end timeout end try return 3 end idle on quit continue quit end quit
set values to {} activate application "Preview" tell application "System Events" tell process "preview" repeat with i in windows set values to values & value of attribute "AXDocument" of i end repeat end tell end tell
tell application "Mail" set newMessage to make new outgoing message set visible of newMessage to true make new to recipient at end of to recipients of newMessage with properties {address:"user@domain"} end tell
tell application "Mail" set newMessage to make new outgoing message set visible of newMessage to true make new to recipient at end of to recipients of newMessage with properties {address:"user@domain"} end tell tell application "System Events" pick (menu item "Unicode(UTF-8)" of menu "テキストエンコーディング" of menu item "テキストエンコーディング" of menu "メッセージ" of menu bar item "メッセージ" of menu bar 1 of application process "Mail") end tell
ファイルをシェルスクリプトで処理した後にアップルスクリプトに渡して, またそこで処理をしたいのだけど,上手くファイルパスを渡せません。 ファイルパスに日本語が入っているとアップするスクリプト側で execution error: Can't make file "..." into aliasとエラー。 アルファベットだけのファイルパスだと問題ないので, コード変換に問題があるのかも知れないけど, 具体的な原因が判らないので対策もわかりません。 とりあえず以下のようなシェルスクリプトでエラーです。
#!/bin/sh filepath='/Users/フルパス/ほげほげ.jpg'
cat << EOS|iconv -f UTF8 -t SJIS|osascript tell application "Finder" set myFile to (POSIX file "${filepath}") as alias copy comment of myFile as Unicode text to content display dialog content end tell EOS
display_message () { osascript <<-EOF tell application "Finder" activate set dd to display dialog "$MESSAGE" giving up after 30 set UserResponse to button returned of dd end tell EOF }