我正在尝试检查不在我的联系人列表中的电话是否已在 iMessage 中注册。
我尝试过两种通用方法。
- 如果在好友列表中,则向电话号码发送消息
on run argv set toAddress to "+380631111111" set message to "Test" tell application "Messages" set targetService to 1st service whose service type = iMessage set targetBuddy to buddy toAddress of targetService delay 1 if targetBuddy exists then send message to targetBuddy end if #delay 5 end tell end run
为什么它不起作用?即使它可以通过删除“延迟 1”来发送消息,我也不想向用户发送垃圾邮件。延迟它只能检查我的好友(联系人)列表中的电话。
- 试图通过 UI 自动化获取按钮颜色。(手机未在 iMessage 中注册时按钮变为红色,否则为蓝色。)
tell application "System Events" to tell process "Messages"
set input to "TEST" as text
click button 1 of group 1 of splitter group 1 of window 1
delay 1
keystroke "+380931111111"
keystroke return
delay 1
set phoneInput to text field 1 of scroll area 2 of splitter group 1 of window 1
set phoneInputElement to menu button 1 of phoneInput
#set phoneInputElementColor to color of phoneInputElement
end tell
我无法获得按钮颜色,因为它没有这样的属性。我还尝试从应用程序显示“+38093111111 未在 iMessage 中注册”的上下文菜单中获取数据,但我无法从 AppleScript 访问上下文菜单。
请帮助我完成我的使命:)