LoginSignup
0
0

More than 5 years have passed since last update.

macでweinreを自動起動する

Posted at

シェルスクリプトを作ったりして簡略化してたけど、
もっと楽したいので起動時に設定できるAutomatorを弄る

Automatorのフローは以下
  1. 指定されたFinder項目を取得
  2. Finder項目を開く
  3. AppleScriptを実行
Automatorに設定していく
  1. ターミナル.appをAutomatorのフローの中にドラッグ&ドロップで突っ込む
    • "/Applications/Utilities/Terminal.app"
    • "アプリケーション>ユーティリティ>ターミナル.app"
  2. フローにアクションを追加
    • "ライブラリ>ファイルとフォルダ>Finder 項目を開く"
    • "ライブラリ>ユーティリティ>AppleScript を実行"
  3. AppleScriptをザカザカと書いていく
AppleScript
tell application "System Events"
    --英数入力に変更
    key code 102
    delay 0.5
    --実行モジュールのパス
    keystroke "/node_modules/weinre/weinre"
    key code 49
    --オプション値その1
    keystroke "--boundHost"
    key code 49
    --オプション値その2
    keystroke "-all-"
    --Returnキーを押下で実行
    keystroke return
    --邪魔なので最小化(Command + m)
    keystroke "m" using {command down}
end tell


※蛇足

注意としては起動時しか考慮してないので、
他にターミナルが開いてたり処理中だったりすると開いているターミナルを使用しちゃう。

どうしても、新しく開いてほしいならAppleScriptの頭に
keystroke "n" using {command down}入れてディレイさせれば新しく開く……はず

あとは空白の入力は「keystroke spaceでいいだろう」とか思ってたら上手くいかなかったというorz
なのでキーコードで対処(なんかスマートな方法あるかもしれない……)
英数入力後0.5秒遅延させてるのは反映俟ち

後は上記で出来たAutomatorのappを出力してユーザのログイン項目に放り込んでおけばいいんじゃないかなぁー

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0