0

Apple スクリプトを使用して、システム設定で 2 つのプロキシ (このサイトにアクセスするために使用する必要があります) を開こうとしていますが、スクリプトでチェック ボックスをクリックすることができません。コードは次のとおりです。

tell application "System Preferences" to set current pane to pane "com.apple.preference.network"
tell application "System Events" to tell process "System Preferences" to tell window "Network"
    click button "Advanced…"
    delay 2
    tell TabGroup of sheet 1
        tell radio button "proxies"
            click
        end tell
    end tell
end tell

高度なスライドダウンタブの一部であるプロキシタブにある http および https プロキシボックスをクリックするコードが必要ですが、「パス」が何であるかわかりません。誰でもこれで私を助けることができますか?ありがとう;)

4

2 に答える 2

2

この例では、Web プロキシを使用しています。

 tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.network"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Network"
    click button "Advanced…"
    delay 2
    click radio button "Proxies" of tab group 1 of sheet 1
    delay 2

    repeat until focused of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1
        keystroke tab
    end repeat

    -- Make sure you start from the top of the list
    repeat 20 times
        key code 126 -- up arrow Key
        delay 0.2
    end repeat

    set counter to 0
    repeat until (value of static text of group 1 of group 1 of tab group 1 of sheet 1 as text) contains "Web Proxy Server"
        set counter to counter + 1
        key code 125
        if counter ≥ 100 then
            display dialog "You have not entered a valid protocol name" buttons {"OK"}
            exit repeat
        end if
    end repeat

    delay 1
    click checkbox 1 of row 3 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1

end tell
于 2012-07-02T11:55:08.910 に答える
0

チェックするボックスを決定するには、行番号を変更するだけです。現在、SOCKS プロキシを切り替えるように設定されています。

tell application "System Preferences" to activate
tell application "System Preferences" to set current pane to pane id "com.apple.preference.network"
tell application "System Events" to tell process "System Preferences" to tell window 1
    click button "Advanced…"
    click radio button "Proxies" of tab group 1 of sheet 1
    set box to checkbox 1 of row 6 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1
    set selected of row 6 of table 1 of scroll area 1 of group 1 of tab group 1 of sheet 1 to true
    click box
    set val to the value of box as boolean
    click button "OK" of sheet 1
    click button "Apply"
end tell
tell application "System Preferences" to quit
if val is true then return "Toggled On"
if val is false then return "Toggled Off"
于 2015-03-20T14:24:45.593 に答える