内容へ移動
Cat Paw Software
ユーザ用ツール
ログイン
サイト用ツール
検索
ツール
文書の表示
以前のリビジョン
バックリンク
最近の変更
メディアマネージャー
サイトマップ
ログイン
>
最近の変更
メディアマネージャー
サイトマップ
トレース:
applescript
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
====== AppleScript ====== ===== シェルコマンドを実行 ===== ''do shell script''でターミナルを起動せずに実行できる ChromeをAppモードで起動し、GMailを開く <code applescript> do shell script "open -na 'Google Chrome' --args --app='https://mail.google.com/mail/u/0/#inbox'" </code> ===== サンプル ===== iTermを立ち上げて、docker-composeを起動する <code applescript> tell application "iTerm" activate set _targetWindow to current window if _targetWindow is null then set _targetWindow to create window with default profile end if tell current session of _targetWindow write text "cd ~/Documents/hoge" write text "docker-compose -d up" end tell end tell </code> ==== アラート ==== <code applescript> display alert "アラート" </code> ==== 確認ダイアログ ==== <code applescript> display dialog "続ける?" </code> デフォルトはOKとキャンセルボタン。キャンセルを選ぶとスクリプト実行が打ち切られる <code applescript> display dialog "どれ?" buttons {"A", "B", "C"} set ans to button returned of result </code> buttonsでボタンの中身を変更できる。button returned of resultで選択したボタンのラベルが取得できる <code applescript> display dialog "どれ?" buttons {"A", "B", "C"} default button "A" cancel button "C" </code> default buttonでデフォルトボタンを指定。cancel buttonでキャンセルボタンを指定(選択するとスクリプト実行が打ち切られる) ==== キャンセル ==== 途中で処理をキャンセル (エラーコード-128はユーザによるキャンセル扱い) <code> error number -128 </code> ===== TerminalからAppleScriptを呼び出す ===== osacriptコマンドで呼び出すことができる <code> /usr/bin/osascript -e 'display notification "メッセージ" with title "タイトル" subtitle "サブタイトル' sound name "Glass" </code> シェルスクリプトとして呼ぶことも可能 <code applescript> #!/usr/bin/osascript on run argv set msg to "notification" if (count of argv) > 0 then set msg to (item 1 of argv) end if display notification msg with title "From Terminal" sound name "Glass" end run </code> これをnotifyなどと名前をつけて保存し、実行権限を付与すると通知センターに任意のメッセージを表示するコマンドになる。 <code> ./notify 任意のメッセージ </code> ''/usr/local/bin'' などパスのとおった場所に設置すると便利に使える
applescript.txt
· 最終更新: 2024/05/05 16:32 by
nullpon
ページ用ツール
文書の表示
以前のリビジョン
バックリンク
文書の先頭へ