diff --git a/alt-tab-macos/ui/Application.swift b/alt-tab-macos/ui/Application.swift index 0b792a39..6b31debc 100644 --- a/alt-tab-macos/ui/Application.swift +++ b/alt-tab-macos/ui/Application.swift @@ -31,6 +31,7 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate, NSCol } func applicationDidFinishLaunching(_ aNotification: Notification) { + ensureScreenRecordingCheckboxIsChecked() ensureAccessibilityCheckboxIsChecked() updateThumbnailMaxSize() makeStatusBarItem() @@ -106,7 +107,16 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate, NSCol func ensureAccessibilityCheckboxIsChecked() { if !AXIsProcessTrustedWithOptions(["AXTrustedCheckOptionPrompt": true] as CFDictionary) { - debugPrint("The user hasn't checked the accessiblity permission checkbox; please authorize and re-launch\nSee https://help.rescuetime.com/article/59-how-do-i-enable-accessibility-permissions-on-mac-osx") + debugPrint("Before using this app, you need to give permission in System Preferences > Security & Privacy > Privacy > Accessibility.\nPlease authorize and re-launch.\nSee https://help.rescuetime.com/article/59-how-do-i-enable-accessibility-permissions-on-mac-osx") + NSApp.terminate(self) + } + } + + func ensureScreenRecordingCheckboxIsChecked() { + let firstWindow = cgWindows()[0] + let windowImage = CGWindowListCreateImage(.null, .optionIncludingWindow, firstWindow[kCGWindowNumber] as! CGWindowID, [.boundsIgnoreFraming, .bestResolution]) + if windowImage == nil { + debugPrint("Before using this app, you need to give permission in System Preferences > Security & Privacy > Privacy > Screen Recording.\nPlease authorize and re-launch.\nSee https://dropshare.zendesk.com/hc/en-us/articles/360033453434-Enabling-Screen-Recording-Permission-on-macOS-Catalina-10-15-") NSApp.terminate(self) } }