Created
March 11, 2019 22:44
-
-
Save gouf/d71a38659edfa50e0e93dd69bd94c524 to your computer and use it in GitHub Desktop.
Slack の検索窓を呼び出して与えられた引数で検索 (AppleScript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる | |
if (count of argv) > 0 then | |
set searchWord to argv | |
else | |
set searchWord to "test_keystroke" | |
end if | |
# NOTE: すでにアプリケーションが起動している必要がある | |
tell application "Slack" | |
activate | |
delay 0.5 | |
# キーストロークをシステムイベントとして送信 | |
# NOTE: 適宜 delay を入れないと操作が速すぎて 受け付けてもらえない | |
tell application "System Events" | |
key code 53 # なにか操作中だったときのために esc で抜ける | |
# 検索窓の呼び出し | |
keystroke "f" using {command down} | |
delay 0.5 | |
# 入力済みのチャンネル名を削除 | |
keystroke "a" using {command down} # 文字列を全選択 : [Command] + [A] | |
delay 0.2 | |
key code 51 using {command down} # 文字列を削除 : [Del] | |
delay 0.2 | |
keystroke searchWord | |
delay 0.2 | |
# 検索実行 : [Enter] | |
keystroke return | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment