【AppleScript】iMessageを自動送信する
13640 ワード
基本のコード
iMessageを自動で送信できないか考えていて、AppleScriptでできないかとやってみた。
imessage.scpt
tell application "Messages"
set targetBuddy to "iMessageの送信先(メールアドレスor電話番号)"
set targetService to id of 1st service whose service type = iMessage
set textMessage to "送信するメッセージ"
set theBuddy to buddy targetBuddy of service id targetService
send textMessage to theBuddy
end tell
これでわりと簡単に送信できた。
1秒に1回送るようにしてみる
imessage.scpt
tell application "Messages"
set targetBuddy to "iMessageの送信先(メールアドレスor電話番号)"
set targetService to id of 1st service whose service type = iMessage
repeat
set textMessage to "送信するメッセージ"
set theBuddy to buddy targetBuddy of service id targetService
send textMessage to theBuddy
delay 1
end repeat
end tell
ちなみに、
delay 1
の行を、
delay (random number from 1 to 30)
とかにすれば、1〜30秒の間に1回送信される。
送るメッセージをランダムにしてみる
imessage.scpt
tell application "Messages"
set targetBuddy to "iMessageの送信先(メールアドレスor電話番号)"
set targetService to id of 1st service whose service type = iMessage
set rand to random number from 1 to 4
if rand = 1 then
set message to "うっひょー"
end if
if rand = 2 then
set message to "ほげほげ"
end if
if rand = 3 then
set message to "ヌベジョンヌゾジョンベルミッティスモゲロンボョ"
end if
if rand = 4 then
set message to "うぇーい"
end if
set textMessage to message
set theBuddy to buddy targetBuddy of service id targetService
send textMessage to theBuddy
end tell
数字と一緒に送ってみる
imessage.scpt
tell application "Messages"
set targetBuddy to "iMessageの送信先(メールアドレスor電話番号)"
set targetService to id of 1st service whose service type = iMessage
set rand to random number from 1 to 100
set textMessage to rand & "億ほしい"
set theBuddy to buddy targetBuddy of service id targetService
send textMessage to theBuddy
end tell
Author And Source
この問題について(【AppleScript】iMessageを自動送信する), 我々は、より多くの情報をここで見つけました https://qiita.com/mkn_ppr/items/1ca8b38fa42632bdc224著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .