4/6/2023 0 Comments Mac os screenshot![]() Swift: let windowInfoList = CGWindowListCopyWindowInfo(.optionAll, kCGNullWindowID)!įrom here, we need to filter our windowInfoList down to the specific window that we want. Objective-C: NSArray *windowInfoList = (_bridge_transfer id)ĬGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID) ![]() Also, if you haven’t figured it out already, this is a C API, so we’ll use a bridging cast to work with the friendlier Objective-C containers rather than the Core Foundation ones. To get ALL the windows, we specify kCGWindowListOptionAll, and kCGNullWindowID, respectively. We get that through CGWindowListCopyWindowInfo, which takes CGWindowListOptions and a corresponding CGWindowID that, together, select which windows to include in the resulting list. To go about retrieving that, we’ll first need a list of all of the windows available on the system. So, in order to capture one specific window on the screen, we’ll need its window ID ( CGWindowID). Perfect! Its declaration is as follows: CGImageRef CGWindowListCreateImage(CGRect screenBounds, Our key function here is CGWindowListCreateImage, which “returns a composite image based on a dynamically generated list of windows,” or, in other words, finds windows based on specified criteria and creates an image with the contents of each. Screen capture on macOS is possible through Quartz Window Services, a facility of the Core Graphics framework.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |