• 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
Re: Unique ID for a Window?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unique ID for a Window?


  • Subject: Re: Unique ID for a Window?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 29 Jul 2015 12:59:23 +0200

> Le 29 juil. 2015 à 12:25, Dave <email@hidden> 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 (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: Dave <email@hidden>
References: 
 >Unique ID for a Window? (From: Dave <email@hidden>)

  • Prev by Date: Unique ID for a Window?
  • Next by Date: Re: Unique ID for a Window?
  • Previous by thread: Unique ID for a Window?
  • Next by thread: Re: Unique ID for a Window?
  • Index(es):
    • Date
    • Thread