> Le 29 juil. 2015 à 12:25, Dave <d...@looktowindward.com> a écrit : > > 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
From the Window Services Reference: kCGWindowNumber The value for this key is a CFNumberRef <https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFNumberRef/index.html#//apple_ref/c/tdef/CFNumberRef> type (encoded as kCGWindowIDCFNumberType <https://developer.apple.com/library/mac/documentation/Carbon/Reference/CGWindow_Reference/Constants/Constants.html#//apple_ref/c/macro/kCGWindowIDCFNumberType>) that contains the window ID. The window ID is unique within the current user session. <> <> <> <> _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com