2014-09-26 34 views
0

我的問題是,我無法找到想要設置值的滑塊的正確路徑。我找不到Slider1的路徑,我想爲它設置一個值。

這是我現在的代碼,也有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 

回答

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 
相關問題