You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Messages.app跨收件人系统自动发短信?FileMaker脚本需求

解决方案:通过AppleScript GUI脚本实现Messages.app发送短信到任意号码

Got it, since Messages.app's native AppleScript API only supports sending messages to contacts saved in Contacts.app or existing conversation threads, we need to use GUI scripting to simulate manual interactions with the Messages app. This approach works for any phone number, even those not stored in your address book, and fits your requirement of not including tell app "FileMaker" in the script.

Here's the complete AppleScript you can use in FileMaker's Perform AppleScript step:

set _delay to 1.0 -- Adjust this based on your Mac's performance (increase if actions are missed)
set _phone_number to repetition 1 of cell "APPLESCRIPT_PIPE" of layout "DEV"
set _msg to repetition 2 of cell "APPLESCRIPT_PIPE" of layout "DEV"

-- Copy the target phone number to clipboard
set the clipboard to _phone_number

-- Activate Messages app to bring it to foreground
tell application "Messages" to activate
delay _delay

-- Use System Events to simulate user actions
tell application "System Events"
    -- Open new message window (default shortcut: Cmd+N)
    keystroke "n" using command down
    delay _delay
    
    -- Paste the phone number into the recipient field
    keystroke "v" using command down
    delay _delay
    
    -- Tab to the message input box
    keystroke tab
    delay _delay
    
    -- Paste the message content
    set the clipboard to _msg
    keystroke "v" using command down
    delay _delay
    
    -- Send the message by pressing Return
    keystroke return
end tell

Key Notes & Requirements:

  • Enable Accessibility Permissions: This is mandatory for GUI scripting to work. Go to System Settings > Privacy & Security > Accessibility, click the + button, and add FileMaker Pro to the list of allowed apps. Restart FileMaker after doing this.
  • Correct Phone Number Format: Use the international format (e.g., +8613800138000 for mainland China numbers). Messages won't recognize invalid or incomplete number formats, which will break the script.
  • Adjust Delay Times: If your Mac is slower, increase the _delay value (e.g., to 1.5 or 2.0) to ensure each GUI action completes before the next one runs.
  • Avoid Interruptions: Make sure Messages app doesn't have any pop-ups, alerts, or open dialogs when running the script—these will throw off the GUI automation.

内容的提问来源于stack exchange,提问作者Chuck

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:24:08