2016-05-03 38 views
0

システム環境設定のディスプレイパネルのラジオボタンをクリックして、つまり画面解像度を変更しようとしています。これはラジオボタンを識別するために使用するコードです。AppleScriptで画面解像度を変更する

tell application "System Preferences" 
    activate 
    reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays" 
end tell 
tell application "System Events" 
    tell application process "System Preferences" 
     set frontmost to true 
     get every radio button of window 0 

     --click button 1 of window 0 of application process "System Preferences" of application "System Events" 

     --click radio button "Scaled" of radio group of window "com.apple.preference.displays" 
    end tell 
end tell 

返されるラジオボタンはnoneです。私が見るものに基づいて、ウィンドウにはゼロのラジオボタンがあります。これは、ラジオボタンがサブウィンドウの一部、すなわち、サブウィンドウの表示であり、メインウィンドウではないという結論につながる。この「サブウィンドウ」に移動してラジオボタンをクリックするにはどうすればよいですか?

enter image description here

答えて

1

ラジオボタンは、radio groupの一部です。ラジオグループはtab groupの一部です。ここで

はスクリプトです:

tell application "System Preferences" 
    activate 
    reveal anchor "displaysDisplayTab" of pane id "com.apple.preference.displays" 
end tell 
tell application "System Events" 
    tell application process "System Preferences" 
     set frontmost to true 
     tell tab group 1 of window 1 
      click radio button 2 of radio group 1 -- "Scaled" 
      select row 2 of table 1 of scroll area 1 -- select the second row in the table to change the resolution of the monitor 
     end tell 
    end tell 
end tell 
+0

私はそれが働いて取得する部分「...選択行2」を微調整し、そうでない場合、これは素晴らしいです! – sanjihan