Post

Replies

Boosts

Views

Activity

Reply to Display several system popups cocoa application
This is the complete example in Obj-C. Just in case you see something:// // main.m // ScreenshotTest // // Created by Raul Sanchez on 24/12/2019. // Copyright © 2019 Raul Sanchez. All rights reserved. // #import <Foundation/Foundation.h> #import <CoreVideo/CVPixelFormatDescription.h> void showPopupIfNotSCreenRecording() { CGDisplayStreamRef stream = CGDisplayStreamCreate(CGMainDisplayID(), 1, 1, kCVPixelFormatType_32BGRA, nil, ^(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef) {}); if (stream) CFRelease(stream); } bool checkIfAccessibilityEnabledAndDisplayPopup() { // Method to check if accessibility is enabled // Passing YES to kAXTrustedCheckOptionPrompt forces showing popup NSDictionary *options = @{(__bridge id)kAXTrustedCheckOptionPrompt: @YES}; Boolean accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options); return (!!accessibilityEnabled); } int main(int argc, const char * argv[]) { @autoreleasepool { NSLog(@"Lets try this"); showPopupIfNotSCreenRecording(); checkIfAccessibilityEnabledAndDisplayPopup(); NSLog(@"End of program"); } return 0; }
May ’20
Reply to Display several system popups cocoa application
Hello,Sorry for the late reply. I Have two functions which are called consecutively. Here is the code:void MacUtils::checkIfScreenRecordingEnabledShowPopupIfNot() { qInfo() << "MacUtils::checkIfScreenRecordingEnabledShowPopupIfNot()"; CGDisplayStreamRef stream = CGDisplayStreamCreate(CGMainDisplayID(), 1, 1, kCVPixelFormatType_32BGRA, nil, ^(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef) { Q_UNUSED(status) Q_UNUSED(displayTime) Q_UNUSED(frameSurface) Q_UNUSED(updateRef) }); if (stream) CFRelease(stream); } bool MacUtils::checkIfAccessibilityEnabledAndDisplayPopup() { // Method to check if accessibility is enabled // Passing YES to kAXTrustedCheckOptionPrompt forces showing popup NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES}; Boolean accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options); return (!!accessibilityEnabled); }First method is for screen recording permission, second one is for accessibilityIf i call first method I see the popup asking for screen recording permissions but then I dont see accesibility popup and if I go to privacy menu it appears like if I had denied permission (app unchecked)Do you have an idea how I can solve this?Thanks in advance
May ’20