I wanted to know how is it possible to take a screen shot from a portion of mac display for example from point(100,200) till point(400,600) with swift?
Asked
Active
Viewed 1,288 times
2 Answers
1
See CGWindowListCreateImage
– or call /usr/sbin/screencapture
(possibly using a framework) and crop the result.

zoul
- 102,279
- 44
- 260
- 354
-
thanks for your input i found the way i will post the answer – user1288164 Nov 06 '17 at 15:30
0
based on the answer here: https://stackoverflow.com/a/40864231/1288164 i added a CGRect to CGDisplayCreateImage:
let rect = CGRect(x: yourOriginX, y: yourOriginY, width: yourWidth, height :yourHeight);
let screenShot:CGImage = CGDisplayCreateImage(activeDisplays[Int(i-1)],rect: rect)!

user1288164
- 21
- 6