我如何使用 applescript 来点击这个复选标记 [英] How do I use applescript to get this checkmark clicked
问题描述
所以我想使用applescript点击系统偏好设置中的允许所有用户访问"的复选标记,然后共享然后远程登录.如此屏幕截图所示:
So I would like to use applescript to click the checkmark that says "allow access for all users" in System Preferences then sharing then remote login. As shown in this screenshot:
无论如何,我已经非常接近能够点击它,但我还没有成功,这是我目前拥有的脚本:
Anyways so I've gotten really close to being able to get it clicked but i haven't yet succeeded here is the script that I have so far:
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
我只是无法点击正确的复选框,如果你们能帮助我,那就太棒了.谢谢!
I just cant quite get it to click the right checkbox, if you guys could help me out that would be awesome. thanks!
(已解决)
推荐答案
你需要做2个步骤:
1) 找到包含远程登录"服务的正确行.这可能并不总是一个固定编号(即您的示例中的第 5 行).然后选择该行并单击复选框以激活
1) find the correct row containing the "Remote Login" service. This may not be always a fix number (i.e. row 5 in your example). then select the row and click the check box to activate
2) 一旦服务被激活,点击所有用户"单选按钮
2) once the service is activated, click of the "all users" radio button
下面的脚本使用注释来做到这一点:
The script bellow does this with comments :
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 因为我更容易用我的系统进行测试(不是英语语言,然后不是相同的字符串值!).
Note : I defined and assigned 2 variables SWindow and SRow because it is easier for me to test with my system (not English language, then not same string values !).
这篇关于我如何使用 applescript 来点击这个复选标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!