无论收件人的操作系统如何,如何通过Messages.app自动发送文本?

问题描述 投票:0回答:1

我的目标是使用FileMaker的Perform AppleScript步骤将macOS上的自动文本发送到FileMaker记录中的电话号码(因此tell app "FileMaker"不在下面的脚本中)。

这些联系人不在Contacts.app的数据库中,所以tell app "Messages" to send ...不是一个选项,至少不是直接选项。

这是我目前的剧本。

set _delay to 0.5

set _phone_number to repetition 1 of cell "APPLESCRIPT_PIPE" of layout "DEV"
set the clipboard to _phone_number

set _msg to repetition 2 of cell "APPLESCRIPT_PIPE" of layout "DEV"

tell application "System Events"
  tell process "Messages"
    set frontmost to true
    keystroke "n" using {command down}
    delay _delay

    keystroke "v" using {command down}
    delay _delay

    keystroke return
    delay _delay

    tell text area 1 of scroll area 4 of splitter group 1 of window 1
      set value to _msg
      delay _delay

      keystroke return

    end tell

  end tell
end tell

activate

这在将文本发送到iPhone时可以完美地工作,但是当收件人使用没有iMessages的电话时,有时它无法传送。

enter image description here

单击“未交付”按钮,然后单击“再试一次”,通过短信发送。

如果电话号码在Contacts.app数据库中,tell app "Messages" to send...工作,至少它已经测试了一些,但是向数据库添加联系人然后尝试发送该联系人文本不起作用。这是我试过的脚本:

tell application "Contacts"
  set _person to make new person with properties¬
    {first name:"Bruce", last name:"Wayne"}
  tell _person
    make new phone at end of phones of _person with properties¬
      {label:"mobile", value:"1234567890"}
  end tell
  save
end tell

tell application "Messages"
  send "Chuck's test" to buddy "1234567890" of service "SMS"
end tell

联系人确实已添加到数据库中,但邮件不会发送。没有生成错误,它只是不发送。

任何人都知道如何确保Android手机的文本第一次通过,或作为后备,一种方法来检测他们什么时候没有?

applescript sms imessage
1个回答
1
投票

我开发了一个Filemaker脚本,可以通过iMe​​ssage或SMS发送消息(无需将好友添加到联系人应用程序)。正如您对Filemaker所熟悉的那样,您可以

  1. 使用要发送的文本设置变量$ Message
  2. 使用电话号码设置变量$ Phone Number(过滤“+0123456789”)
  3. 使用Perform Applescript步骤和计算的Applescript,如下所示:

"display dialog \"Send SMS?\" default answer \"" & $Message & "\" buttons {\"Cancel\", \"OK\"} default button 2" & ¶ & "copy the result as list to {button_pressed, text_returned}" & ¶ & "if button_pressed is \"OK\" then" & ¶ & "tell application \"Messages\"" & ¶ & "send text_returned to buddy \"" & $PhoneNumber & "\" of service \"SMS\" " & ¶ & "end tell" & ¶ & "end if"

我添加了一个对话框,可以在我的Filemaker数据库中编辑自动格式化的消息。下一步形成我就是能够在发送的短信中添加一个ical事件......任何想法都是受欢迎的;-)

© www.soinside.com 2019 - 2024. All rights reserved.