2

AppleScript を使用して、選択ボックス内の項目をクリックしようとしています。

ウィンドウのスクリーンショット

[その他...] 項目をマウスで手動でクリックすると、標準の OSX ファイル選択ダイアログが開きますが、AppleScript を使用して実行しようとすると、[その他...] 項目が選択項目として選択された項目として表示されます。ボックスに表示されますが、ダイアログは表示されません。

これまで試してみました...(要素名はAutomatorレコーダーから来ました)

tell application "System Events"

    click static text 1 of window 1 of application process "DYMO Word Addin"
    -- combo box arrow
    click UI Element 1 of combo box 2 of group 1 of window 1 of application process "DYMO Word Addin"

    set labelsList to (list 1 of scroll area 1 of combo box 2 of group 1 of window 1 of application process "DYMO Word Addin")
    set numLabelsInList to (count text fields of labelsList)
    set theTextField to (text field numLabelsInList of labelsList)

    if numLabelsInList > 1 then

            repeat with z from 1 to (numLabelsInList - 1)
                    key code 125 -- down arrow
            end repeat

    end if

    -- stuff I've tried

    click theTextField
    keystroke return
    key code 36 -- return
    set focused of theTextField to true
    set value of attribute "AXFocused" of theTextField to true
    perform action "AXConfirm" of theTextField

end tell

...そして今、私はアイデアがありません。

4

2 に答える 2

1

さらに多くのテストを行った結果、コンボ ボックスにフォーカスがある場合にのみファイル ダイアログが開き、コンボ ボックスの矢印ボタンとメニュー項目をクリックしても実際にはフォーカスされないことが判明しました。

http://lists.apple.com/archives/accessibility-dev/2006/Oct/msg00013.html

そのスレッドのすべてのメソッドを試して要素にフォーカスを与えた後、「クリック」でさえ機能しませんでした。

https://apple.stackexchange.com/questions/40141/when-mousekeys-are-on-how-do-i-click-or-move-the-mouse-using-applescript#answer-40859

その答えは、マウスを移動してクリックする別の方法としてcliclickを推奨しています。

だから結局私は

click static text 1 of window 1 of application process "DYMO Word Addin"
set labelsComboBox to (combo box 2 of group 1 of window 1 of application process "DYMO Word Addin")

tell labelsComboBox
        set {xPosition, yPosition} to position of labelsComboBox
        set {xSize, ySize} to size
end tell

set {realXPosition, realYPosition} to {(xPosition + (xSize div 2)) as string, (yPosition + (ySize div 2)) as string}

do shell script "/usr/local/bin/cliclick m:" & realXPosition & "," & realYPosition & " dc:" & realXPosition & "," & realYPosition

-- combo box arrow
click UI element 1 of labelsComboBox

...
于 2013-02-23T23:16:52.473 に答える
-1

ここでは、同様の質問をした人を見つけることができ、答えもクリックでした

https://discussions.apple.com/message/17662850#17662850

于 2014-03-24T02:14:02.260 に答える