希望有人能提供帮助——我在 Apple M1 Pro 笔记本电脑上运行 macOS Monterey。我的 AppleScript 发送批量文本消息,存储在 Excel 文件中,通过 Messages 应用程序传递,现在无法正常工作——它在我在 Catalina 下运行的旧笔记本电脑上运行良好。
问题似乎在于将电话号码(“targetBuddyPhone”)传递到消息应用程序中的正确位置。相反,文本消息(“targetMessage”)被放入应用程序中的收件人位置。有人对可能的解决方案有任何想法吗?
提前致谢。
on run {input, parameters}
set phoneCol to "B"
set messageCol to "C"
set startRow to 1
set counter to "D"
set xlsFilePath to (path to desktop as text) & "texttest.xlsx"
tell application "Microsoft Excel" to open file xlsFilePath
tell application "Microsoft Excel"
set endRow to value of cell (counter & startRow) as number
end tell
repeat with thisRow from startRow to endRow
tell application "Microsoft Excel"
set targetBuddyPhone to string value of cell (phoneCol & thisRow) as string
set targetMessage to value of cell (messageCol & thisRow) as string
end tell
activate application "Messages"
tell application "System Events" to tell process "Messages"
key code 45 using command down -- press Command + N to start a new window
keystroke targetBuddyPhone -- input the phone number
key code 36 -- press Enter to focus on the message area
delay 3
keystroke targetMessage -- type some message
key code 36 -- press Enter to send
end tell
delay 6
end repeat
return input
end run