Skip to content

Instantly share code, notes, and snippets.

View renssies's full-sized avatar

Rens Verhoeven renssies

View GitHub Profile
@chockenberry
chockenberry / ScreenRecordingDetection.m
Created November 21, 2019 22:38
Detecting Screen Recording Permission in macOS Catalina
BOOL canRecordScreen = YES;
if (@available(macOS 10.15, *)) {
canRecordScreen = NO;
NSRunningApplication *runningApplication = NSRunningApplication.currentApplication;
NSNumber *ourProcessIdentifier = [NSNumber numberWithInteger:runningApplication.processIdentifier];
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
NSUInteger numberOfWindows = CFArrayGetCount(windowList);
for (int index = 0; index < numberOfWindows; index++) {
// get information for each window