2012-11-14 79 views
0

我有以下代碼。它運行,我得到了我的結果,我認爲退出重複出現錯誤,獲得ipad名稱後,腳本仍然保持運行,直到超時。 任何人都可以告訴我代碼有什麼問題嗎?謝謝!AppleScript在退出後不會停止運行重複


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 

回答

0

如果你想退出第一代iPad後的腳本中發現,有返程更換退出重複。

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 

我使用一個開始的原因是,包含將點擊以前的案例菜單項。