Struct windows_capture::window::Window
source · pub struct Window { /* private fields */ }Expand description
Represents a window in the Windows operating system.
§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 foreground window.
§Errors
Returns an Error::NoActiveWindow if there is no active window.
sourcepub fn from_contains_name(title: &str) -> Result<Self, Error>
pub fn from_contains_name(title: &str) -> Result<Self, Error>
sourcepub fn title(&self) -> Result<String, Error>
pub fn title(&self) -> Result<String, Error>
Returns the title of the window.
§Errors
Returns an Error if there is an error retrieving the window title.
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 doesn’t intersect with any monitor.
sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks if the window is a valid window.
§Returns
Returns true if the window is valid, false otherwise.
sourcepub fn enumerate() -> Result<Vec<Self>, Error>
pub fn enumerate() -> Result<Vec<Self>, Error>
Returns a list of all windows.
§Errors
Returns an Error if there is an error enumerating the windows.
sourcepub const fn from_raw_hwnd(hwnd: isize) -> Self
pub const fn from_raw_hwnd(hwnd: isize) -> Self
sourcepub const fn as_raw_hwnd(&self) -> isize
pub const fn as_raw_hwnd(&self) -> isize
Returns the raw HWND of the window.
Trait Implementations§
source§impl PartialEq for Window
impl PartialEq for Window
impl Copy for Window
impl Eq for Window
impl StructuralPartialEq for Window
Auto Trait Implementations§
impl Freeze for Window
impl RefUnwindSafe for Window
impl Send 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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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