【问题标题】:Apple Script app helpApple 脚本应用程序帮助
【发布时间】:2011-01-23 08:19:09
【问题描述】:

我正在尝试制作一个基于 applescript 的应用程序,只需单击一下即可激活/停用网络和 Adium 代理设置。 Adium 部分完成。 我不能做的是做一个 switch/if_then_else 语句来选择: 网络/位置:“自动”和“uMinho”设置。 脚本应选择非活动选项。 有什么想法吗?

这是脚本:

-- Activate Location "uminho"
tell application "Finder" to activate
tell application "System Events"
tell process "Finder"
    tell menu bar 1
        tell menu bar item "Apple"
        tell menu "Apple"
        tell menu item "Location"
            tell menu "Location"
 -- Need to switch between "Automatic" and "uMinho"
 -- Switch to the unactive one
                     click menu item "uMinho" 
            end tell
            end tell
                end tell
            end tell
        end tell
    end tell
end tell

-- Activate adium proxy settings to all accounts
tell application "Adium" to activate
-- let's do this
tell application "System Events"
    tell process "Adium"
        -- open prefs
        keystroke "," using command down
        tell window 1
            -- open the accounts pane
            tell tool bar 1 to click button "Accounts"
            repeat with i from 1 to count of rows of table 1 of scroll area 1
                    -- tell group 1
                -- select the account
                set selected of row i of table 1 of scroll area 1 to true
                -- edit it
                click button "Edit"
                -- end tell
                tell sheet 1
                    tell tab group 1
                        -- open the personal info pane
                        click radio button "Proxy"
                        -- change the name, if one was provided
                        click checkbox "Connect using proxy"
                    end tell
                    click button "OK"
                end tell
            end repeat
            keystroke "w" using command down
        end tell
    end tell
end tell

【问题讨论】:

    标签: user-interface proxy applescript switch-statement


    【解决方案1】:

    在 10.5 或更高版本中这将起作用,否则您可以使用命令行实用程序 scselect 来切换位置。

    tell application "System Events"
        tell network preferences
            set currentName to name of current location
            if currentName is "Automatic" then
                set current location to location "uMinho"
            else
                set current location to location "Automatic"
            end if
        end tell
    end tell
    

    【讨论】:

    • 我目前使用的是 10.6.6。我无法让该代码工作。我尝试了它而不是我的第一部分代码,然后只尝试了那个代码。它运行,但没有变化。我错过了什么吗?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 2011-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-24
    相关资源
    最近更新 更多