pub struct Window { /* private fields */ }Expand description
Represents a window that can be captured.
ยงExample
use windows_capture::window::Window;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let window = Window::foreground()?;
println!("Foreground window title: {}", window.title()?);
Ok(())
}Implementationsยง
Sourceยงimpl Window
impl Window
Sourcepub fn foreground() -> Result<Self, Error>
pub fn foreground() -> Result<Self, Error>
Returns the window that is currently in the foreground.
ยงErrors
Returns Error::NoActiveWindow if there is no foreground window.
Sourcepub fn from_contains_name(title: &str) -> Result<Self, Error>
pub fn from_contains_name(title: &str) -> Result<Self, Error>
Sourcepub fn process_id(&self) -> Result<u32, Error>
pub fn process_id(&self) -> Result<u32, Error>
Returns the process ID of the window.
ยงErrors
Returns an Error if the process ID cannot be retrieved.
Sourcepub fn process_name(&self) -> Result<String, Error>
pub fn process_name(&self) -> Result<String, Error>
Returns the name of the process that owns the window.
This function requires the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ permissions.
ยงErrors
Returns an Error if the process name cannot be retrieved.
Sourcepub fn monitor(&self) -> Option<Monitor>
pub fn monitor(&self) -> Option<Monitor>
Returns the monitor that has the largest area of intersection with the window.
Returns None if the window does not intersect with any monitor.
Sourcepub fn rect(&self) -> Result<RECT, Error>
pub fn rect(&self) -> Result<RECT, Error>
Returns the bounding rectangle of the window in screen coordinates.
ยงErrors
Returns Error::WindowsError if the window rectangle cannot be retrieved.
Sourcepub fn title_bar_height(&self) -> Result<u32, Error>
pub fn title_bar_height(&self) -> Result<u32, Error>
Calculates the height of the windowโs title bar in pixels.
ยงErrors
Returns Error if the title bar height cannot be determined.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks if the window is a valid target for capture.
ยงReturns
Returns true if the window is visible, not a tool window, and not a child window.
Returns false otherwise.
Sourcepub fn enumerate() -> Result<Vec<Self>, Error>
pub fn enumerate() -> Result<Vec<Self>, Error>
Returns a list of all capturable windows.
ยงErrors
Returns an Error if the window enumeration fails.
Sourcepub const fn from_raw_hwnd(hwnd: *mut c_void) -> Self
pub const fn from_raw_hwnd(hwnd: *mut c_void) -> Self
Sourcepub const fn as_raw_hwnd(&self) -> *mut c_void
pub const fn as_raw_hwnd(&self) -> *mut c_void
Returns the raw HWND handle of the window.
Trait Implementationsยง
Sourceยงimpl TryIntoCaptureItemWithType for Window
impl TryIntoCaptureItemWithType for Window
Sourceยงfn try_into_capture_item(
self,
) -> Result<(GraphicsCaptureItem, CaptureItemTypes), Error>
fn try_into_capture_item( self, ) -> Result<(GraphicsCaptureItem, CaptureItemTypes), Error>
GraphicsCaptureItem and its corresponding CaptureItemTypes variant.impl Copy for Window
impl Eq for Window
impl Send for Window
impl StructuralPartialEq for Window
Auto Trait Implementationsยง
impl Freeze for Window
impl RefUnwindSafe for Window
impl !Sync for Window
impl Unpin for Window
impl UnwindSafe for Window
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more