Generates and returns information about the selected windows in the current user session.


func CGWindowListCopyWindowInfo(_ option: CGWindowListOption, _ relativeToWindow: CGWindowID) -> CFArray?



The options describing which window dictionaries to return. Typical options let you return dictionaries for all windows or for windows above or below the window specified in the relativeToWindow parameter. For more information, see Window List Option Constants.


The ID of the window to use as a reference point when determining which other window dictionaries to return. For options that do not require a reference window, this parameter can be kCGNullWindowID.

Return Value

An array of CFDictionary types, each of which contains information about one of the windows in the current user session. 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.


You can use this function to get detailed information about the configuration of one or more windows in the current user session. For example, you can use this function to get the bounds of the window, its window ID, and information about how it is managed by the window server. For the list of keys and values that may be present in the dictionary, see Required Window List Keys and Optional Window List Keys.

Generating the dictionaries for system windows is a relatively expensive operation. As always, you should profile your code and adjust your usage of this function appropriately for your needs.

See Also

Getting Window Information

func CGWindowListCreateDescriptionFromArray(CFArray?) -> CFArray?

Generates and returns information about windows with the specified window IDs.

func CGWindowListCreateImage(CGRect, CGWindowListOption, CGWindowID, CGWindowImageOption) -> CGImage?

Returns a composite image based on a dynamically generated list of windows.