Platforms to show: All Mac Windows Linux Cross-Platform

The module CGWindowMBS

module CGWindowMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
module CoreGraphics MBS MacFrameworks Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
This module contains CoreGraphics functions related to windows.
Example
// screenshot of all windows on screens
Backdrop = CGWindowMBS.CreateWindowListImage(0, 0, 0, 0, 0, 0, 0)
  • method CreateWindowList(windowOption as Integer, WindowID as Integer = 0) as UInt32()
  • method 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
  • method 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
  • method GetWindowID(w as DesktopWindow) as integer
  • method GetWindowID(w as window) as Integer
  • method GetWindowListInfo(windowOption as Integer, WindowID as Integer = 0) as dictionary()
  • 30 constants

Constants

Constant Value Description
kCGNullWindowID 0 The number for an invalid window ID.

Backing Store Constants

Constant Value Description
kCGBackingStoreBuffered 2
kCGBackingStoreNonretained 1
kCGBackingStoreRetained 0

Window Info Dictionary Key Constants

Constant Value Description
kCGWindowAlpha "kCGWindowAlpha" The alpha fade of the window. The value of this key is a floating-point value. The value 1.0 is normal (opaque); the value 0.0 is fully transparent (invisible).
kCGWindowBackingLocationVideoMemory "kCGWindowBackingLocationVideoMemory" Optional. If present, true if the window backing store is in video memory, false otherwise. If the key is not present, then the window backing store is in main memory. The value of this key is a Boolean.
kCGWindowBounds "kCGWindowBounds" The bounds of the window in screen space, with the origin at the upper-left corner of the main display. The value of this key is a Dictionary.
Example
kCGWindowIsOnscreen "kCGWindowIsOnscreen" Optional. If present, true if the window is ordered on screen, false otherwise. If the key is not present, then the window is not ordered on screen. The value of this key is a boolean.
kCGWindowLayer "kCGWindowLayer" The window layer number of the window. The value of this key is a 32-bit signed integer value.
kCGWindowMemoryUsage "kCGWindowMemoryUsage" An estimate of the memory in bytes currently used by the window and its supporting data structures. The value of this key is a 64-bit signed integer value.
kCGWindowName "kCGWindowName" Optional. If present, the name of the window. The value of this key is a string.
Example
kCGWindowNumber "kCGWindowNumber" The window ID, a unique value within the user session representing the window. The value of this key is a 32-bit signed integer value.
Example
kCGWindowOwnerName "kCGWindowOwnerName" Optional. If present, the name of the application process which owns the window. The value of this key is a string.
kCGWindowOwnerPID "kCGWindowOwnerPID" The process ID of the process that owns the window. The value of this key is a 32-bit signed integer value.
kCGWindowSharingState "kCGWindowSharingState" The sharing state of the window, one of kCGWindowSharingNone, kCGWindowSharingReadOnly, or kCGWindowSharingReadWrite. The value of this key is a 32-bit signed integer value.
kCGWindowStoreType "kCGWindowStoreType" The backing store type of the window, one of kCGBackingStoreRetained, kCGBackingStoreNonretained, or kCGBackingStoreBuffered. The value of this key is a 32-bit signed integer value.
kCGWindowWorkspace "kCGWindowWorkspace" Optional. If present, the workspace ID of the workspace associated with the window. The value of this key is a 32-bit signed integer value.

Image Options Constants

Constant Value Description
kCGWindowImageBoundsIgnoreFraming 1 If null rect is passed as the screen bounds, then then bounds computation excludes window frame ornamentation, such as a shadow.
kCGWindowImageDefault 0 If null rectangle is passed as the screen bounds, then then bounds computation includes window frame ornamentation, such as a shadow.
kCGWindowImageOnlyShadows 4 Only draw the windows' shadows, not the windows themselves.
kCGWindowImageShouldBeOpaque 2 Force the created image to be opaque. Empty areas are white.

Window list option Constants

Constant Value Description
kCGWindowListExcludeDesktopElements 16 Exclude any windows from the list that are elements of the desktop.
kCGWindowListOptionAll 0 List all windows in this user session, including both on- and off-screen windows. The parameter WindowID should be kCGNullWindowID.
kCGWindowListOptionIncludingWindow 8 Include the window specified by WindowID in any list, effectively creating 'at-or-above' or 'at-or-below' lists.
kCGWindowListOptionOnScreenAboveWindow 2 List all on-screen windows above the window specified by WindowID, ordered from front to back.
kCGWindowListOptionOnScreenBelowWindow 4 List all on-screen windows below the window specified by WindowID, ordered from front to back.
kCGWindowListOptionOnScreenOnly 1 List all on-screen windows in this user session, ordered from front to back. The parameter WindowID should be kCGNullWindowID.

Sharing State Constants

Constant Value Description
kCGWindowSharingNone 0 No sharing.
kCGWindowSharingReadOnly 1 Read only.
kCGWindowSharingReadWrite 2 Read and Write

Some examples which use this module:

Blog Entries


The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...