2016-09-05 1 views
0

AppleScriptを使用して、「システム環境設定」の「すべてのユーザーのアクセスを許可する」のチェックマークをクリックしてから、このスクリーンショットに示すように:私はそれがクリックされたが、私はまだここでは成功していない取得することができることに本当に近い得ているので、とにかくこのチェックマークをクリックするには、AppleScriptを使用するにはどうすればいいですか?

What it should look like if it works

私がこれまで持っているスクリプトです:

tell application "System Preferences" 
set current pane to pane "com.apple.preferences.sharing" 
end tell 
tell application "System Events" 
    tell process "System Preferences" 
     tell checkbox 2 of row 4 of table 1 of scroll area 1 of group 1 of window "Sharing" to if value is 0 then click 
    end tell 
end tell 

私はちょうど右のチェックボックスをクリックすることはできません。ありがとう!

1)は、 "リモートログイン" サービスを含む、正しい行を見つける:(解決しよう)

答えて

0

あなたは2つの手順を実行する必要があります。これは必ずしも修正番号ではない可能性があります(例:行5)。その後、行を選択し、サービスがアクティブになると、「すべてのユーザー」のラジオボタンをクリックし

2)を活性化するために、チェックボックスをクリックし

スクリプト怒鳴るはコメントでこれを行い

set SWindow to "Sharing" 
set SRow to "Remote Login" 

tell application "System Preferences" 
set current pane to pane "com.apple.preferences.sharing" 
end tell 
tell application "System Events" 
tell process "System Preferences" 
    -- get the correct row number of the sharing services 
    repeat with theRow in every row of table 1 of scroll area 1 of group 1 of window SWindow 
     if value of UI element 2 of theRow is SRow then -- this is the "Remote Login" row 
      select theRow -- select the row 
      if value of checkbox 1 of theRow is 0 then click checkbox of theRow -- click on activate check box if not yet set 
     end if 
    end repeat 
    delay 1 -- time to display the correct pane with the users for sharing 
    click radio button 1 of radio group 1 of group 1 of window SWindow -- click the button "all users" 
end tell 
end tell 

注:2つの変数SWindowとSRowを定義して割り当てました。私のシステムでテストする方が簡単なので(英語ではなく、同じ文字列の値ではありません)。

+0

ありがとう、完璧に動作します! – fake666666666

+0

私が遭遇した主な問題の1つは、ボタンの正しい名前を見つけることでした。私はそれがラジオボタンと呼ばれていたことに気付かず、将来の参照のために非常に役立ちます。ありがとう! – fake666666666

0

GUIスクリプティングのないスマートな解決策は、(管理者パスワードが必要):

do shell script "launchctl load -w /System/Library/LaunchDaemons/ssh.plist" with administrator privileges 
do shell script "/usr/bin/dscl . -delete /Groups/com.apple.access_ssh" with administrator privileges 

警告dsclラインは完全に "のみこれらのユーザー" で作成したグループを削除します。

+0

私は管理者特権なしでそれを行う方法を探していましたが、とにかく感謝しています。 – fake666666666

関連する問題