我有以下代码。它运行,我得到我的结果,我认为退出重复有问题,在获得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
答案 0 :(得分:0)
如果要在找到第一个iPad后退出脚本,请将return repeat替换为return。
答案 1 :(得分: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
我使用开头的原因是包含将点击之前的手柄菜单项。