Code Monkey home page Code Monkey logo

swift-screencapture's Introduction

ScreenCapture GitHub license Carthage compatible CocoaPods

This framework makes capturing screenshots within OS X easy.

To capture a region of the screen, it makes use of NSTask to call /usr/sbin/screencapture.

Carthage

github "nirix/swift-screencapture"

How to use it

An example application can be found in the Example directory.

Screenshots

import ScreenCapture

// Capture part of the screen
let regionUrl = ScreenCapture.captureRegion("/path/to/save/to.png")

// Capture the entire screen
let screenUrl = ScreenCapture.captureScreen("/path/to/save/to.png")

Record screen

import ScreenCapture

let recorder = ScreenCapture.recordScreen("/path/to/save/to.mp4")

recorder.start()
...
recorder.stop()

let movieUrl = recorder.destination

License

This framework and it's code is released under the MIT license.

swift-screencapture's People

Contributors

krisyu avatar nirix avatar tulakshana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swift-screencapture's Issues

Crash when execute app directly

Sorry to disturb.
The project can run and work normally in xcode.
But when I run Product/Example.app directly,It crashed.
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (AVPlayerView) for key (NS.objects); the class may be defined in source code or a library that is not linked'

PS:Swift version has upgraded to 4

about screen capture?

hi. i make a app with swift ios9. i used replaykit for screen record. but i want to a part of screen record. is it possible? i want to record a video which is playing in a webview.

Not Working in the Swift 3!!!!!!!!

I did the upgrade you didn t do and run the code but there is error in the ScreenCapture.swift class and in the captureScreen function. Error is

2016-11-15 14:29:43.128 Test_v2[6157:122664] Couldn't posix_spawn: error 13
2016-11-15 14:29:43.130 Test_v2[6157:122664] (
0 CoreFoundation 0x00007fff8f1704f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff96dcef7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff8f1d74bd +[NSException raise:format:] + 205
3 Foundation 0x00007fff8d661add -[NSConcreteTask launchWithDictionary:] + 3134
4 Test_v2 0x00000001000033f4 TFC7Test_v214ViewController13captureRegionfT11destinationCSo5NSURL_S1 + 804
5 Test_v2 0x0000000100002483 TFC7Test_v214ViewController5btnSSfP_T + 115
6 Test_v2 0x0000000100002643 TToFC7Test_v214ViewController5btnSSfP_T + 67
7 libsystem_trace.dylib 0x00007fff9290e07a _os_activity_initiate + 75
8 AppKit 0x00007fff9180cdbd -[NSApplication sendAction:to:from:] + 460
9 AppKit 0x00007fff9181ef12 -[NSControl sendAction:to:] + 86
10 AppKit 0x00007fff9181ee3c __26-[NSCell _sendActionFrom:]_block_invoke + 131
11 libsystem_trace.dylib 0x00007fff9290e07a _os_activity_initiate + 75
12 AppKit 0x00007fff9181ed99 -[NSCell _sendActionFrom:] + 144
13 libsystem_trace.dylib 0x00007fff9290e07a _os_activity_initiate + 75
14 AppKit 0x00007fff9181d3be -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2693
15 AppKit 0x00007fff91865f04 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 744
16 AppKit 0x00007fff9181bae8 -[NSControl mouseDown:] + 669
17 AppKit 0x00007fff91d703c9 -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322
18 AppKit 0x00007fff91d713ad -[NSWindow _reallySendEvent:isDelayedEvent:] + 212
19 AppKit 0x00007fff917b0539 -[NSWindow sendEvent:] + 517
20 AppKit 0x00007fff91730a38 -[NSApplication sendEvent:] + 2540
21 AppKit 0x00007fff91597df2 -[NSApplication run] + 796
22 AppKit 0x00007fff91561368 NSApplicationMain + 1176
23 Test_v2 0x0000000100004aa4 main + 84
24 libdyld.dylib 0x00007fff938165ad start + 1
)

why it is coming?? Also there is nıo any documentation because of the new version of Swift also there is no any decrements about Screen captures. Please help!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.