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 process_id(&self) -> Result<u32, Error>
pub fn process_id(&self) -> Result<u32, Error>
Returns the process name of the window.
§Errors
Returns an Error if there is an error retrieving the process name.
Sourcepub fn process_name(&self) -> Result<String, Error>
pub fn process_name(&self) -> Result<String, Error>
Returns the process name of the window.
Requires the PROCESS_QUERY_INFORMATION and PROCESS_VM_READ permissions.
§Errors
Returns an Error if there is an error retrieving the process name.
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 rect(&self) -> Result<RECT, Error>
pub fn rect(&self) -> Result<RECT, Error>
Returns the rectangle of the window in screen coordinates.
§Errors
Returns an Error::WindowsError if there is an error retrieving the window rectangle.
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: *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 of the window.
Trait Implementations§
Source§impl TryFrom<Window> for GraphicsCaptureItem
impl TryFrom<Window> for GraphicsCaptureItem
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