0
tell application "System Preferences"
    activate
end tell

tell application "System Events"
    set preferencesLocked to false
    tell process "System Preferences"
        delay 1
        click menu item "Security & Privacy" of menu "View" of menu bar 1
        delay 2.5
        if title of button 4 of window 1 is "Click the lock to make changes." then
            set preferencesLocked to true
            click button "Click the lock to make changes." of window 1
        end if
    end tell
    if preferencesLocked is true then
        delay 2.5
        activate application "SecurityAgent"
        tell application "System Events"
            tell process "SecurityAgent"
                set value of text field 1 of scroll area 1 of group 1 of window 1 to "admin"
                set value of text field 2 of scroll area of group 1 of window 1 to "XXXXXXX"

                click button "Unlock" of group 2 of window 1
                tell application "System Events"
                    tell process "SecurityAgent"

                        **click button "Advanced..."**
                    end tell
                end tell


            end tell
        end tell
    end if


end tell
4

1 回答 1

0

您只需用省略号字符替换三个句点:

tell application "System Preferences"
    reveal pane id "com.apple.preference.security"
    activate
end tell
tell application "System Events"
    if title of button 4 of window 1 of process "System Preferences" is "Click the lock to make changes." then
        click button "Click the lock to make changes." of window 1 of process "System Preferences"
        delay 5
        tell process "SecurityAgent"
            set value of text field 2 of scroll area 1 of group 1 of window 1 to "password"
            click button 2 of group 2 of window 1
        end tell
    end if
    tell process "System Preferences"
        click button "Advanced…" of window 1
    end tell
end tell
于 2013-10-29T17:07:49.190 回答