screencapture:无法一次运行两个交互式屏幕捕获

时间:2016-10-21 03:43:46

标签: macos macos-sierra

        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不起作用

1 个答案:

答案 0 :(得分:1)

关闭沙箱或添加com.apple.security.temporary-exception.mach-register.global-name作为密钥,com.apple.screencapture.interactive作为权利文件的值。