• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Unique ID for a Window?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Unique ID for a Window?
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: iOS 8.4: Converting a URL into a PHAsset
  • Next by Date: Re: Unique ID for a Window?
  • Previous by thread: Re: iOS 8.4: Converting a URL into a PHAsset
  • Next by thread: Re: Unique ID for a Window?
  • Index(es):
    • Date
    • Thread