0

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?

2 Answers2

1

See CGWindowListCreateImage – or call /usr/sbin/screencapture (possibly using a framework) and crop the result.

zoul
  • 102,279
  • 44
  • 260
  • 354
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)!