0

我有以下代码。它运行,我得到了我的结果,我认为退出重复有问题,在它获得 ipad 名称后,脚本仍在运行直到超时。谁能告诉我代码有什么问题?谢谢!


set deviceName to "iPad"
tell application "System Events"
tell process "iTunes"
    activate
    repeat with i from 1 to the count of (row of outline 1 of scroll area 2 of window "iTunes")
        repeat with j from 1 to the count of static text of row i of outline 1 of scroll area 2 of window "iTunes"
            set xxxx to the value of item j of static text of row i of outline 1 of scroll area 2 of window "iTunes"
            if (xxxx contains deviceName) then
                print xxxx
                click row i of outline 1 of scroll area 2 of window "iTunes"
                exit repeat
            end if
            --exit repeat
        end repeat

    end repeat

end tell
end tell
4

2 回答 2

0

问题(您要求)是您在重复中有重复。这意味着当您在子循环中并退出重复时,您将跳转到主循环。要从这里退出,您必须再次退出重复。

查看您的代码,我不理解嵌套的重复循环。您可以删除包围/主要重复,它会按预期工作。

set deviceName to "iPad"
tell application "System Events"
    tell process "iTunes"
        activate
        repeat with UIElement in rows of outline 1 of scroll area 2 of window "iTunes"
            if (value of static text of UIElement as text) begins with deviceName then return select UIElement
        end repeat
    end tell
end tell

我使用 an 开头的原因是 contains 将单击以前的钱包菜单项。

于 2012-11-14T20:08:22.210 回答
0

如果您想在找到第一台 iPad 后退出脚本,请将 exit repeat 替换为 return。

于 2012-11-14T19:24:45.200 回答