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

查看:145
本文介绍了检查手机是否已在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.

请帮助我完成任务:)

推荐答案

您可以获取按钮的颜色,该按钮的颜色是在其上移动鼠标指针,然后为应用程序数字色度计"编写脚本. 首先使用positionsize属性,根据iMessage窗口上的gui元素计算按钮的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天全站免登陆