let imgPath: String = "\(self.tmpDir)captureRegion.png"
//let screencapturePath = NSBundle.mainBundle().pathForAuxiliaryExecutable("/usr/sbin/screencapture")! as String
let task = NSTask()
task.launchPath = "/usr/sbin/screencapture"
task.arguments = ["-i", "-r", imgPath]
task.launch()
task.waitUntilExit()
当执行上面的代码时,它会在输出中显示“screencapture:一次不能运行两个交互式屏幕捕获”,并且ScreenCapture不起作用
答案 0 :(得分:1)
关闭沙箱或添加com.apple.security.temporary-exception.mach-register.global-name
作为密钥,com.apple.screencapture.interactive
作为权利文件的值。