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.
- 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
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.
- Trying to get button color by UI Automation. (Button goes red when phone is not registered in iMessage, and blue otherwise.)
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
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 :)
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 & "));\""
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
来源:https://stackoverflow.com/questions/28501094/check-is-phone-registered-in-imessage