Unique ID for a Window?
Unique ID for a Window?
- Subject: Unique ID for a Window?
- From: Dave <email@hidden>
- Date: Wed, 29 Jul 2015 11:25:19 +0100
Hi,
For reasons that are too complex to go in to, I need to somehow create a Unique ID that is valid for the life of a Window. The Window I am trying to identify is not owned by my App (think Screen Dump, like “Grab”).
I ran this code:
CFArrayRef windowList = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
for (NSMutableDictionary* entry in (NSArray*)windowList)
{
NSString* ownerName = [entry objectForKey:(id)kCGWindowOwnerName];
NSInteger ownerPID = [[entry objectForKey:(id)kCGWindowOwnerPID] integerValue];
NSLog(@"%@:%ld", ownerName, (long)ownerPID);
}
CFRelease(windowList);
This is the dictionary returned for this Email message:
{
kCGWindowAlpha = 1;
kCGWindowBounds = {
Height = 858;
Width = 1003;
X = 874;
Y = 342;
};
kCGWindowIsOnscreen = 1;
kCGWindowLayer = 0;
kCGWindowMemoryUsage = 3462288;
kCGWindowName = "New Message";
kCGWindowNumber = 2895;
kCGWindowOwnerName = Mail;
kCGWindowOwnerPID = 507;
kCGWindowSharingState = 1;
kCGWindowStoreType = 2;
},
Are one or more of these values guaranteed to be Unique (within the Window List) and not to change during the life-time of the Window?
Thanks a lot.
All the Best
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden