csrutil status
。它应该显示SIP状态:已启用/已禁用。
要禁用它:csrutil disable
。再次重启,启动到正常的mac os。
sudo chmod 664 /Library/Application\ Support/com.apple.TCC
grant screencapure privilege to cron and screencapture
a) CRON:
`sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'insert into access values ("kTCCServiceScreenCapture", "/usr/sbin/cron", 1, 1, 1, "", "", "", "UNUSED", "", 0,"")'`
b) screencapture:
Pre Big Sur:
`sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'insert into access values ("kTCCServiceScreenCapture", "/usr/sbin/screencapture", 1, 1, 1, "", "", "", "UNUSED", "", 0,"")'`
--------------------------------------------------------------------------
Big Sur and later:
`sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'insert into access values ("kTCCServiceScreenCapture", "/usr/sbin/screencapture", 1,2,4,1, "", "", "", "UNUSED", "", 0,"")'`
It's probably a good idea to turn SIP back on at this stage. To enable it, follow step 1, and instead of csrutil disable
just type csrutil enable
.
编辑 @ 2021-12-09T11:58:00+1000:根据Silvan Mühlemann的评论,添加了针对Big Sur和更高版本的命令。
csrutil clear
来重新启用SIP,而无需在macOS Sierra 10.12.2或更高版本中重新启动到恢复模式。 - Matiassudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'insert into access values ("kTCCServiceScreenCapture", "/usr/sbin/screencapture", 1,2,4,1, "", "", "", "UNUSED", "", 0,"")'
请注意序列1,2,4,1
。有关更多详细信息,请参见https://rainforest.engineering/2021-02-09-macos-tcc/。 - Silvan Mühlemann您应该允许您的脚本在“安全性与隐私”系统偏好设置中使用“屏幕录制”功能。
#!/bin/bash
for value in {1..980}
do
/Users/<username>/record_activity_with_screen_capture.bash
sleep 60
done
echo All done
或者
使用launchd(而不是cron)运行此脚本。 有两个示例:
不要玩弄危险的SIP(系统完整性保护),尽管顶部答案建议这样做,但只需将屏幕录制权限授予/usr/sbin/cron
(或某些MacOS版本中的/sbin/cron
)。
为了实现这一点:
/usr/sbin
并按 Enter 键(如果您在接下来的步骤中找不到 cron
,请尝试在此处使用 /sbin
)cron
并点击“打开”cron
旁边的复选框完成,现在应该可以捕获屏幕截图了。
你可以尝试将shebang更改为#!/bin/sh,或将screencapture更改为exec screencapture
man screencapture
表示:“安全注意事项 要在通过ssh登录时捕获屏幕内容,您必须在与loginwindow相同的mach引导层次结构中启动screencapture:PID = loginwindow的pid sudo launchctl bsexec $ PID screencapture [选项]” - TheNextman