Platforms to show: All Mac Windows Linux Cross-Platform
Back to CGWindowMBS module.
CGWindowMBS.CreateWindowList(windowOption as Integer, WindowID as Integer = 0) as UInt32()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | CoreGraphics | MBS MacFrameworks Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
windowOption: 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.
WindowID: 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.
Returns an array of 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 nil.
Available in Mac OS X v10.5 and later.
May fail and cause a consent prompt on MacOS 10.15 to ask user whether he/she allows your app to take the picture.
CGWindowMBS.CreateWindowListCGImage(left as Double, top as Double, width as Double, height as Double, windowOption as Integer, WindowID as Integer = 0, ImageOption as Integer = 0) as Variant
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | CoreGraphics | MBS MacFrameworks Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
Same as CreateWindowListImage, but returns a CGImageMBS. Declared as Variant to reduce plugin interdependencies.
May fail and cause a consent prompt on MacOS 10.15 to ask user whether he/she allows your app to take the picture.
Some examples using this method:
CGWindowMBS.CreateWindowListImage(left as Double, top as Double, width as Double, height as Double, windowOption as Integer, WindowID as Integer = 0, ImageOption as Integer = 0) as picture
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | CoreGraphics | MBS MacFrameworks Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Parameters:
left | Left coordinate rectangle |
top | Top coordinate rectangle |
width | Width of rectangle |
height | Height of rectangle |
windowOption | A combination of kCGWindowListOption* flags |
WindowID | The window ID or 0. |
ImageOption | A combination of kCGWindowImage* flags |
If you pass a rectangle with all values zero, you select the whole screen.
Returns the screenshot as picture or nil on any error.
Window Options:
kCGWindowListOptionAll | 0 | List all windows in this user session, including both on and off-screen windows. relativeToWindow should be kCGNullWindowID=0. |
kCGWindowListOptionOnScreenOnly | 1 | List all on-screen windows in this user session, ordered from front to back. relativeToWindow should be kCGNullWindowID=0. |
kCGWindowListOptionOnScreenAboveWindow | 2 | List all on-screen windows above the specified window ordered from front to back. relativeToWindow should be the window number. |
kCGWindowListOptionOnScreenBelowWindow | 4 | List all on-screen windows below the specified window ordered from front to back. relativeToWindow should be the window number. |
kCGWindowListOptionIncludingWindow | 8 | Include the named window in any list, effectively creating 'at-or-above' or 'at-or-below' lists. relativeToWindow should be the window number. |
kCGWindowListExcludeDesktopElements | 16 | Exclude any windows from the list that are elements of the desktop, including the background picture and icons on the desktop. |
Image Options:
kCGWindowImageDefault | 0 | Default behavior: If a rect of CGRectNull is used bounds computation includes the framing effects, such as a shadow. |
kCGWindowImageBoundsIgnoreFraming | 1 | If a rect of CGRectNull is used, ignore framing effects for bounds computation |
kCGWindowImageShouldBeOpaque | 2 | The captured image should be opaque. Empty areas are white |
kCGWindowImageOnlyShadows | 4 | Capture only shadows. |
May fail and cause a consent prompt on MacOS 10.15 to ask user whether he/she allows your app to take the picture.
Some examples using this method:
CGWindowMBS.GetWindowID(w as DesktopWindow) as integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | CoreGraphics | MBS MacFrameworks Plugin | 22.0 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
Returns 0 on any error.
This ID can be used for CreateWindowListImage.
See also:
Some examples using this method:
CGWindowMBS.GetWindowID(w as window) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | CoreGraphics | MBS MacFrameworks Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
Returns 0 on any error.
This ID can be used for CreateWindowListImage.
See also:
CGWindowMBS.GetWindowListInfo(windowOption as Integer, WindowID as Integer = 0) as dictionary()
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | CoreGraphics | MBS MacFrameworks Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
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 relativeToWindow parameter. For more information, see "Window List Option Constants."
WindowID: 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 0.
Returns an array of CFDictionaryRef 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 nil.
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 kCGWindow* constants.
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.
Available in Mac OS X v10.5 and later.
Some examples using this method:
The items on this page are in the following plugins: MBS MacFrameworks Plugin.