我的问题是我无法找到想要设置值的滑块的正确路径。
这是我目前的代码,还有UIElemtInspector路径,非常感谢任何帮助。 :)
UIElemtInspector路径:
<AXApplication: “OSCulator”>
<AXWindow: “Preferences”>
<AXTabGroup>
<AXGroup>
<AXSlider>
Attributes:
AXRole: “AXSlider”
AXRoleDescription: “slider”
AXHelp: “(null)”
AXEnabled: “1”
AXFocused (W): “0”
AXParent: “<AXGroup>”
AXWindow: “<AXWindow: “Preferences”>”
AXTopLevelUIElement: “<AXWindow: “Preferences”>”
AXPosition: “x=263 y=513”
AXSize: “w=214 h=21”
AXValue (W): “20.35702720207254”
AXMinValue: “0”
AXMaxValue: “100”
AXChildren: “<array of size 1>”
AXAllowedValues: “(null)”
AXOrientation: “AXHorizontalOrientation”
AXIdentifier: “_NS:405”
Actions:
AXIncrement - increment
AXDecrement - decrement
代码:
if application "OSCulator" is running then
tell application "System Events"
tell application process "OSCulator"
tell menu bar 1
tell menu bar item "OSCulator"
tell menu "OSCulator"
click menu item "Preferences..."
end tell
end tell
end tell
end tell
end tell
tell application "OSCulator" to activate
tell application "System Events" to tell application process "OSCulator" to tell window "Preferences" to tell tab group 1
click radio button "Outputs"
end tell
end if
答案 0 :(得分:1)
正如UIElementInspector所说,滑块位于一个组中。您可以像这样显示每个组:
tell application "System Events" to tell application process "OSCulator"
tell window "Preferences" to tell tab group 1
click radio button "Outputs"
get every group
end tell
end tell
结果:
group "Kyma" of tab group 1 of window "Preferences"...
group "HID" of tab group 1 of window "Preferences"...
group "Mouse" of tab group 1 of window "Preferences"...
现在你可以找到滑块:
get every UI element of group "Mouse"
然后最后设置滑块:
tell application "System Events" to tell application process "OSCulator"
tell window "Preferences" to tell tab group 1
click radio button "Outputs"
set value of slider 1 of group "Mouse" to 50
end tell
end tell