Post

Replies

Boosts

Views

Activity

Reply to App with sandbox TCC deny IOHIDDeviceOpen
Following code i tried to implement in my MacOS App, but it can't able to create CGEvent.tapCreate import Foundation import CoreGraphics func myCGEventCallback(proxy : CGEventTapProxy, type : CGEventType, event : CGEvent, refcon : UnsafeMutableRawPointer?) -> Unmanaged<CGEvent>? {   if type == .keyDown || type == .keyUp || type == .flagsChanged {          let keyCode = event.getIntegerValueField(.keyboardEventKeycode)     print(keyCode)   }   return Unmanaged.passRetained(event) } func KeyCounterEvent() {   let eventMask = (1 << CGEventType.keyDown.rawValue) | (1 << CGEventType.keyUp.rawValue) | (1 << CGEventType.flagsChanged.rawValue)   guard let eventTap = CGEvent.tapCreate(tap: .cgSessionEventTap, place: .headInsertEventTap, options: .defaultTap, eventsOfInterest: CGEventMask(eventMask), callback: myCGEventCallback, userInfo: nil) else {     debugPrint("Failed to create event tap")     exit(1)   }   let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0)   CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, .commonModes)   CGEvent.tapEnable(tap: eventTap, enable: true)   CFRunLoopRun() } Note: tried this code in separate console app works fine, but problem occurs when creating it in MacOS App with SandBox
Feb ’23
Reply to Capture screenshot in MacOS App issue
Hi, Following is my current code which is trying to implement in macOS App var displayCount: UInt32 = 0;       var result = CGGetActiveDisplayList(0, nil, &displayCount)       if result != CGError.success {         print("error: \(result)")         return       }       let allocated = Int(displayCount)       let activeDisplays = UnsafeMutablePointer<CGDirectDisplayID>.allocate(capacity: allocated)       result = CGGetActiveDisplayList(displayCount, activeDisplays, &displayCount)               if result != CGError.success {         print("error: \(result)")         return       }                            for i in 1...displayCount {                                   let fileUrl = URL(fileURLWithPath: "image\(i).jpg", isDirectory: true)                   let screenShot:CGImage = CGDisplayCreateImage(activeDisplays[Int(i-1)])!         let bitmapRep = NSBitmapImageRep(cgImage: screenShot)         let jpegData = bitmapRep.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:])!                             do {           try jpegData.write(to: fileUrl, options: .atomic)         } catch { print("error: \(error)") }       } Note: I am implement same code in console app separately which it woks fine, but issue in macOS App
Feb ’23
Reply to Capture screenshot in MacOS App issue
Tried using CGRequestScreenCaptureAccess first time it returns true, then after there is no return from that function which leads to stop executing the code. As per my functionality calling permissions every time when application starts and executing particular code means it will be issue to user. Is there any option to authenticate for the first time then after it need to run without authentication.
Feb ’23
Reply to Suddenly URLSession.shared.dataTask not working
Do you receive an error message ? If so, which ? No Did it stop running on all 3 Mac ? Yes If the exact same code was running on all 3 Mac before with the same code are you absolutely sure you did not change anything to the app ? Yes I tried all the above mentioned probabilities. Same url is working with postman same url is working in windows system
Mar ’23
Reply to How to run command line App in Main App using swift/SwiftUI (MacOS).
Hi, i am trying to implemented block websites functionality as xpc service. link i am getting following error [22516:3818158] [general] Attempting to perform block on main runloop, but the main thread has exited. This message will only log once. Break on _CFRunLoopError_MainThreadHasExited to debug [22516:3818158] [general] Attempting to wake up main runloop, but the main thread as exited. This message will only log once. Break on _CFRunLoopError_MainThreadHasExited to debug. which it terminates the xpc service saying Message from debugger: Terminated due to memory issue
Mar ’23
Reply to How to run command line App in Main App using swift/SwiftUI (MacOS).
Hi, I am trying to run Console App code in Swiftui project. The Code with consists of SBApplication to get data from bundle identifier which is not working. let safariObject: SafariApplication = SBApplication(bundleIdentifier: "com.apple.Safari")! let frontWindow = safariObject.windows!()[0] as! SafariWindow let activeTab = frontWindow.currentTab! let url = activeTab.URL let activeTab = BrowserTab.safari(activeTab) Note: Same code working fine when it is implemented in console app
Mar ’23