检测 window 总行数
Detecting a window total row count
我是 applescripting 的新手,我想确定在 window 中遍历行的最佳实践。但是我不知道在比较所有行后如何抛出错误。
目前我将 'hard value' 设置为 3(因为我只有 2 行要检查)但我可能有超过 3 行并且我希望它在检查 window 中的所有行后失败。
我可以用什么替换下面的代码行 'if TheRow is equal to 3' 以检测它是否已遍历所有行?
set ReadDBPluginName to value of (text field 1 of row TheRow of table 1 of scroll area 1 of tab group 1 of window "Plugins Manager" of process "OSX")
if ReadDBPluginName is not equal NewDBPluginName then
set TheRow to TheRow + 1
if TheRow is equal to 3
error "Plugin Name " & NewDBPluginName & " does not exist"
end if
尽管我在评论中针对你的问题写了些什么(这对以后的任何帖子来说都是很好的建议,可以帮助你获得最好的帮助),我 可能 能够为你提供有一个解决方案,请记住它直接来自我的头顶并且没有经过任何容量测试。
您似乎正在迭代一系列 UI elements
分组到 row
个对象中,每个对象都包含一个 text field
,您希望检索 value
的,并将其与一些预先存在的字符串 (NewDBPluginName
).
进行比较
按照这个前提,您可以取消任何您已经在使用的 repeat
循环,并立即读取每个 row
的每个 text field 1
的值。然后,只需检查此值列表是否包含 NewDBPluginName
:
tell application "System Events" to ¬
set ReadDBPluginNames to the value of ¬
text field 1 of ¬
rows of ¬
table 1 of ¬
scroll area 1 of ¬
tab group 1 of ¬
window "Plugins Manager" of process "OSX"
if NewDBPluginName is not in ReadDBPluginNames then ¬
error "Plugin Name " & NewDBPluginName & " does not exist"
我是 applescripting 的新手,我想确定在 window 中遍历行的最佳实践。但是我不知道在比较所有行后如何抛出错误。
目前我将 'hard value' 设置为 3(因为我只有 2 行要检查)但我可能有超过 3 行并且我希望它在检查 window 中的所有行后失败。
我可以用什么替换下面的代码行 'if TheRow is equal to 3' 以检测它是否已遍历所有行?
set ReadDBPluginName to value of (text field 1 of row TheRow of table 1 of scroll area 1 of tab group 1 of window "Plugins Manager" of process "OSX")
if ReadDBPluginName is not equal NewDBPluginName then
set TheRow to TheRow + 1
if TheRow is equal to 3
error "Plugin Name " & NewDBPluginName & " does not exist"
end if
尽管我在评论中针对你的问题写了些什么(这对以后的任何帖子来说都是很好的建议,可以帮助你获得最好的帮助),我 可能 能够为你提供有一个解决方案,请记住它直接来自我的头顶并且没有经过任何容量测试。
您似乎正在迭代一系列 UI elements
分组到 row
个对象中,每个对象都包含一个 text field
,您希望检索 value
的,并将其与一些预先存在的字符串 (NewDBPluginName
).
按照这个前提,您可以取消任何您已经在使用的 repeat
循环,并立即读取每个 row
的每个 text field 1
的值。然后,只需检查此值列表是否包含 NewDBPluginName
:
tell application "System Events" to ¬
set ReadDBPluginNames to the value of ¬
text field 1 of ¬
rows of ¬
table 1 of ¬
scroll area 1 of ¬
tab group 1 of ¬
window "Plugins Manager" of process "OSX"
if NewDBPluginName is not in ReadDBPluginNames then ¬
error "Plugin Name " & NewDBPluginName & " does not exist"