NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

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.

1      

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.

1      

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.

1      

Hacking with Swift is sponsored by MadMachine

SPONSORED Want to explore your Swift skill outside of the Apple world? Join the MadMachine community and start to program microcontrollers in Swift.

Get it now

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.