Class OSDesktopWindow

java.lang.Object
oshi.software.os.OSDesktopWindow

@Immutable public class OSDesktopWindow extends Object
This class encapsulates information about a window on the operating system's GUI desktop
  • Constructor Details

    • OSDesktopWindow

      public OSDesktopWindow(long windowId, String title, String command, Rectangle locAndSize, long owningProcessId, int order, boolean visible)
  • Method Details

    • getWindowId

      public long getWindowId()
      Gets the operating system's handle, window ID, or other unique identifier for this window.

      On Winodws, this can be converted to a WinDef.HWND using new HWND(new Pointer(windowId)). On macOS, this is the Core Graphics Window ID. On Unix-like systems, this is the X11 Window ID.

      Returns:
      the windowId
    • getTitle

      public String getTitle()
      Gets the Window title, if any.
      Returns:
      the title, which may be an empty string if the window has no title.
    • getCommand

      public String getCommand()
      Gets the command name (possibly the full file path) of the window's executable program, if known.
      Returns:
      the command
    • getLocAndSize

      public Rectangle getLocAndSize()
      Gets a Rectangle representing the window's location and size.
      Returns:
      the location and size
    • getOwningProcessId

      public long getOwningProcessId()
      Gets the process ID of the process which owns this window, if known.
      Returns:
      the owningProcessId
    • getOrder

      public int getOrder()
      Makes a best effort to get the order in which this window appears on the desktop. Higher values are more in the foreground.

      On Windows, this represents the Z Order of the window, and is not guaranteed to be atomic, as it could be impacted by race conditions.

      On macOS this is the window layer. Note that multiple windows may share the same layer.

      On X11 this represents the stacking order of the windows.

      Returns:
      a best effort identification of the window's Z order relative to other windows
    • isVisible

      public boolean isVisible()
      Makes a best effort to report whether the window is visible to the user. A "visible" window may be completely transparent.
      Returns:
      true if the window is visible to users or if visibility can not be determined, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object