#author("2023-05-14T07:22:15+00:00","default:hotate","hotate") #author("2023-05-14T07:22:42+00:00","default:hotate","hotate") #contents &tag(macOS); * 情報 [#w64c0110] ** Finder [#re56bcfa] - [[AppleScriptをメニューバーから実行するための設定>https://rcmdnk.com/blog/2015/07/26/computer-mac/]] メニューバーに表示する設定は AppleScript Editor.app (スクリプトエディタ.app)の環境設定から 行います。 ** ウインドウ [#yd0a48ef] - [[【macOS】07 AppleScriptによるウィンドウサイズの変更 | ブログ>https://ameblo.jp/altair265/entry-12597228357.html]] ターミナルにコマンド入力 -------------------------------------------------- osascript \ -e 'tell application "ソフト名"' \ -e 'set bounds of front window to {0, 0, 1200, 900}' \ -e 'end tell' -- コメント:期待通りに動作した。下記は一例。([[2022]]/02/06) osascript -e 'tell application "Chrome"' -e 'set bounds of front window to {0, 0, 1200, 900}' -e 'end tell' - [[AppleScript: Beginner's Tutorial>https://macosxautomation.com/applescript/firsttutorial/04.html]] As a matter of fact, the value of the index property of the previous scripts could also be written like this: tell application "Finder" to get the index of the 1st Finder window ** パス [#n7d1810e] - [[AppleScriptのファイル参照、パス、などについて: 2008/6/18~>http://johny-johni-johne.sblo.jp/article/94698016.html]] 要はUnix的なパスの指定はPOSIXパス。それをMac的に書くとテキストパス。 - [[macos - How to make an AppleScript app locate itself? - Ask Different>https://apple.stackexchange.com/questions/237080/how-to-make-an-applescript-app-locate-itself]] If you want the path up to the script or app set to a variable use the following code: set thePath to POSIX path of ((path to me as text) & ":") - [[Get path of parent folder of script location : Applescript - Super User>https://superuser.com/questions/670893/get-path-of-parent-folder-of-script-location-applescript]] set UnixPath to POSIX path of ((path to me as text) & "::") - [[[AppleSript] スクリプト自身のパスを得る | コピペで使える自動処理>https://sakuraorange.minibird.jp/?p=78]] スクリプト自身が保存されているパスを取得します。UNIXシェルに投げる事が多いのでUNIX形式への変換も行っています。 ** ファイル [#s0399ea6] - [[Applescript: read text from file - Stack Overflow>https://stackoverflow.com/questions/48967281/applescript-read-text-from-file]] set sharesFileName to (the POSIX path of (path to home folder)) & "Applications/mounts" set sharesLines to read sharesFileName - [[鳶嶋工房 / AppleScript / Tips / テキストの読み込み>http://tonbi.jp/AppleScript/Tips/String/Read.html]] 最初は、テキストファイル全体を文字列に読み込む方法を紹介します。 ** Safari [#a83eb83f] ** [[Safari]] [#a83eb83f] - [[AppleScript : Safari で URL を開き、テキストをクリップボードに保存する : R for Radio>http://blog.livedoor.jp/smilewave/archives/46366762.html]] AppleScript を使って、Safari を操作します。ここでは、Safari で URL を開き、テキストをクリップボードに保存してみます。 - [[Safariを自由自在に操作するためのAppleScript集 | Macの手書き説明書>https://mac-tegaki.com/basic-usage/safari-applescript.html#]] URLを現在のタブで読み込む 現在のタブで読み込むようにすると、新しいタブがどんどん開いていくのを防げます。 - [[AppleScript : Safari で URL を開き、テキストをクリップボードに保存する : R for Radio>http://blog.livedoor.jp/smilewave/archives/46366762.html]] ここでは、Safari で URL を開き、テキストをクリップボードに保存してみます。 * 関連 [#cfb36f27] #related #taglist(tag=AppleScript)