CGWindowListCopyWindowInfo(_:_:)
Generates and returns information about the selected windows in the current user session.
Declaration
func CGWindowListCopyWindowInfo(_ option: CGWindowListOption, _ relativeToWindow: CGWindowID) -> CFArray?Parameters
- option:
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
relativeToWindowparameter. For more information, see Window List Option Constants. - relativeToWindow:
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.
Discussion
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
Functions
CGAcquireDisplayFadeReservation(_:_:)CGAssociateMouseAndMouseCursorPosition(_:)CGBeginDisplayConfiguration(_:)CGCancelDisplayConfiguration(_:)CGCaptureAllDisplays()CGCaptureAllDisplaysWithOptions(_:)CGCompleteDisplayConfiguration(_:_:)CGConfigureDisplayFadeEffect(_:_:_:_:_:_:)CGConfigureDisplayMirrorOfDisplay(_:_:_:)CGConfigureDisplayMode(_:_:_:)CGConfigureDisplayOrigin(_:_:_:_:)CGConfigureDisplayStereoOperation(_:_:_:_:)CGConfigureDisplayWithDisplayMode(_:_:_:_:)CGCursorIsDrawnInFramebuffer()CGCursorIsVisible()