2

連絡先リストにない電話がiMessageに登録されているかどうかを確認しようとしています。

私が試した 2 つの一般的なアプローチがあります。

  1. 友だちリストにある電話番号にメッセージを送信する
    
    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
    

うまくいかないのはなぜですか?「delay 1」を削除することでメッセージを送信できますが、ユーザーにスパムを送信したくありません。遅延すると、電話が私のバディ(連絡先)リストにあるかどうかのみを確認できます。

  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からコンテキストメニューに到達できません。

私の使命を達成するのを手伝ってください:)

4

1 に答える 1

-1

マウス ポインターをボタンの上に移動して、アプリケーションのデジタル カラー メーターをスクリプト化することで、ボタンの色を取得できます。position最初に、およびsize属性を使用して、iMessage ウィンドウの GUI 要素に基づいてボタンの x および y 位置を計算します。
次に、ポインターを計算された位置に移動します。

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 & "));\""

Digital Color Meter を使用して、指定されたピクセルの色を RGB 形式で取得します。

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
于 2015-03-13T19:05:54.227 に答える