要选择仅设置了标签/文本属性的元素,你可以使用AppleScript的UI元素的属性来判断元素是否只设置了标签/文本属性。以下是一个示例代码:
tell application "System Events"
tell process "YourAppName"
set elementsWithOnlyLabel to {}
-- 获取所有UI元素
set allElements to entire contents
repeat with anElement in allElements
-- 判断元素是否只设置了标签/文本属性
if (value of attribute "AXDescription" of anElement is missing value) and (value of attribute "AXValue" of anElement is not missing value) then
set end of elementsWithOnlyLabel to anElement
end if
end repeat
-- 处理选中的元素
-- 例如,显示元素的名称
repeat with anElement in elementsWithOnlyLabel
display dialog name of anElement
end repeat
end tell
end tell
请将代码中的"YourAppName"更改为你要操作的应用程序的名称。这段代码将遍历应用程序的所有UI元素,并通过判断元素的AXDescription和AXValue属性来确定是否只设置了标签/文本属性。如果是,它将将该元素添加到elementsWithOnlyLabel列表中。你可以根据你的需求对选中的元素进行进一步的处理。