<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGWindowListCreate",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@F@CGWindowListCreate"
  },
  "title" : "CGWindowListCreate"
}
-->

# CGWindowListCreate

Returns the list of window IDs associated with the specified windows in the current user session.

```
extern CFArrayRefCGWindowListCreate(CGWindowListOption option, CGWindowID relativeToWindow);
```

## Parameters

`option`

The options describing which window IDs to return. Typical options let you obtain IDs for all windows or for windows above or below the window specified in the `relativeToWindow` parameter. For more information, see [Window List Option Constants](/documentation/CoreGraphics/window-list-option-constants).

`relativeToWindow`

The ID of the window to use as a reference point when determining which other windows to return. For options that do not require a reference window, this parameter can be [`kCGNullWindowID`](/documentation/CoreGraphics/kCGNullWindowID).

## Return Value

An array of [`CGWindowID`](/documentation/CoreGraphics/CGWindowID) values corresponding to the desired windows. If there are no windows matching the desired criteria, the function returns an empty array. If you call this function from outside of a GUI security session or when no window server is running, this function returns `NULL`.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)