Class OSDesktopWindow
java.lang.Object
oshi.software.os.OSDesktopWindow
This class encapsulates information about a window on the operating system's GUI desktop
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOSDesktopWindow(long windowId, String title, String command, Rectangle locAndSize, long owningProcessId, int order, boolean visible) -
Method Summary
Modifier and TypeMethodDescriptionGets the command name (possibly the full file path) of the window's executable program, if known.Gets aRectanglerepresenting the window's location and size.intgetOrder()Makes a best effort to get the order in which this window appears on the desktop.longGets the process ID of the process which owns this window, if known.getTitle()Gets the Window title, if any.longGets the operating system's handle, window ID, or other unique identifier for this window.booleanMakes a best effort to report whether the window is visible to the user.toString()
-
Field Details
-
windowId
private final long windowId -
title
-
command
-
locAndSize
-
owningProcessId
private final long owningProcessId -
order
private final int order -
visible
private final boolean visible
-
-
Constructor Details
-
OSDesktopWindow
-
-
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.HWNDusingnew 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
Gets the Window title, if any.- Returns:
- the title, which may be an empty string if the window has no title.
-
getCommand
Gets the command name (possibly the full file path) of the window's executable program, if known.- Returns:
- the command
-
getLocAndSize
-
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:
trueif the window is visible to users or if visibility can not be determined,falseotherwise.
-
toString
-