FREE TRIAL: Accelerate your app development career with Hacking with Swift+! >>

MacOS SwiftUI Screenshot

Forums > macOS

I want my MacOS app to be able to take a screenshot of a selected area only, not the whole screen.

I know I can use the build in capabilities of MacOS "Shift+Command+4" and use Pauls code-> to detect the action, but I realy want the functionallity to be handle in app.

I've come accross this piece of code but can't get it to run as my knowledge of extensions is in its infancy: https://gist.github.com/SatoTakeshiX/39e111aa93f896e58c74fdc13d19ba0a

I have alot to learn and any help would be appreciated.

   

This open-source library (https://github.com/nirix/swift-screencapture) provides the API to capture entire screen, capture an area, and record screen. I think this might be useful to you.

   

Oh, great, thanks for the info! I am interested in developing antivirus for macOS that would focus on keeping software settings intact or flagging on an attempt to introduce changes. There are apps around that escalate privalages despite being what is called a 100% legit app e.g. https://applehelpwriter.com/2016/08/29/discovering-how-dropbox-hacks-your-mac/. There are apps that are rather ill-famed yet still are not recognized as culprits. Yahoo redirect generic virus is a good example. So I wonder if Swift is a good language to develop AV focusing on privilage escalation issues, in partticular, I wonder if DetectX Swift could be used as a stub https://sqwarq.com/detectx/? Sorry, the question is a bit irrelevenat and obscure, I appreciate any follow-up.

   

Hacking with Swift is sponsored by Sentry

SPONSORED With Sentry’s error and performance monitoring for iOS you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.

Get started

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.