检查手机是否已在 iMessage 中注册 [英] Check is phone registered in iMessage

查看:33
本文介绍了检查手机是否已在 iMessage 中注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检查不在我的联系人列表中的电话是否已在 iMessage 中注册.

I'm trying to check if phone not from my contact list is registered in the iMessage.

我尝试了两种通用方法.

There is two general approaches that I've tryed.

  1. 发送消息到好友列表中的电话号码
  1. Send message to phone number if it's in buddy list

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"来发送消息,我也不想向用户发送垃圾邮件.延迟它只能检查我的好友(联系人)列表中是否有电话.

Why it doesn't work? Even tho it can send messages by removing "delay 1" I don't want to spam users. With delay it can only check if phone in my buddy (contact) list.

  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 访问上下文菜单.

I'm unable to get button color because it doesn't have such property. Also I tried to get data from context menu where application says "+38093111111 is not registered in iMessage" but I can't reach context menu from AppleScript.

请帮助我完成我的使命:)

Please, help me to accomplish my mission :)

推荐答案

您可以通过将鼠标指针移到按钮上来获取按钮的颜色,然后编写应用程序数字色度计的脚本.首先根据 iMessage 窗口上的某个 gui 元素,使用 positionsize 属性计算按钮的 x 和 y 位置.
然后将指针移动到计算出的位置:

You could get the color of the button moving the mouse pointer on it and then scripting the application Digital Color Meter. First calculate the x and y position of the button based on some gui element on the iMessage window, using the position and size attributes.
Then move the pointer to the calculated position:

do shell script "/usr/bin/python -c \"import objc;bndl = objc.loadBundle('CoreGraphics', globals(), '/System/Library/Frameworks/ApplicationServices.framework');objc.loadBundleFunctions(bndl, globals(), [('CGWarpMouseCursorPosition', 'v{CGPoint=dd}')]);CGWarpMouseCursorPosition((" & x & "," & y & "));\""

使用数字色度计获取像素点的颜色,RGB格式:

Use Digital Color Meter to get the color of the pixel pointed, in rgb format:

tell application "Digital Color Meter" to activate
tell application "System Events"
    tell process "Digital Color Meter"
        click menu item 1 of menu 1 of menu bar item 4 of menu bar 1
        delay 1
    end tell
    set rgbColors to words of (the clipboard)
end tell

这篇关于检查手机是否已在 iMessage 中注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆