I managed to get list of windows on the desktop with CGWindowListCopyWindowInfo, but the next time is to try to get the properties of the window, like the pro开发者_C百科gram name, title, and other properties.
What API should I look into and do we have any example on how to do this?
List the windows and retrieve the specific information while looping through:
NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
for (NSDictionary *window in windows) {
NSString *owner = [window objectForKey:@"kCGWindowOwnerName" ];
NSString *name = [window objectForKey:@"kCGWindowName" ];
NSLog(@"%@ - %@",owner,name);
}
Available keys:
kCGWindowIsOnscreen
kCGWindowLayer
kCGWindowMemoryUsage
kCGWindowName
kCGWindowNumber
kCGWindowOwnerName
kCGWindowOwnerPID
kCGWindowSharingState
kCGWindowStoreType
精彩评论