Skip to content

Instantly share code, notes, and snippets.

@gouf
Created July 6, 2019 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gouf/f875746d0be9d4408e2286f93a4bcdcc to your computer and use it in GitHub Desktop.
Save gouf/f875746d0be9d4408e2286f93a4bcdcc to your computer and use it in GitHub Desktop.
Slack 特定のチャンネルに 3x3 の 💪 を入力する AppleScript
# Slack の入力欄に :muscle: をたくさん打ち込むスクリプト
# 3x3 に渡ってたくさんの muscle を自動で打ち込む
property channelName : ""
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる
if (count of argv) > 0 then
set channelName to argv
else
set channelName to "my-rails" # 未指定の場合、この値を設定
end if
# NOTE: すでにアプリケーションが起動している必要がある
tell application "Slack"
activate
delay 0.2
# キーストロークをシステムイベントとして送信
# NOTE: 適宜 delay を入れないと操作が速すぎて 受け付けてもらえない
tell application "System Events"
keystroke "k" using command down
delay 1.0
# 指定されたチャンネル名に切り替え
keystroke channelName
delay 0.5
keystroke return
delay 0.5
# 入力欄にフォーカスを移動
keystroke tab
# 3x3 の :muscle: の入力と送信
repeat 3 times
repeat 3 times
keystroke ":muscle"
keystroke return
delay 0.1
end repeat
keystroke return using {control down}
end repeat
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