WindowHandle

Struct WindowHandle 

Source
pub struct WindowHandle { /* private fields */ }
Available on crate feature ui only.
Expand description

A (non-null) handle to a window.

Implementations§

Source§

impl WindowHandle

Source

pub fn get_console_window() -> Option<Self>

Returns the console window associated with the current process, if there is one.

Source

pub fn get_foreground_window() -> Option<Self>

Returns the current foreground window, if any.

Source

pub fn get_desktop_window() -> Result<Self>

Returns the ‘desktop’ window.

Source

pub fn get_toplevel_windows() -> Result<Vec<Self>>

Returns all top-level windows of desktop apps.

Source

pub fn is_window(self) -> bool

Checks if the handle points to an existing window.

Source

pub fn is_visible(self) -> bool

Source

pub fn is_cloaked(self) -> Result<bool>

Checks if the window is cloaked.

See also: https://devblogs.microsoft.com/oldnewthing/20200302-00/?p=103507

Source

pub fn get_caption_text(self) -> String

Returns the window caption text, converted to UTF-8 in a potentially lossy way.

Source

pub fn set_caption_text(self, text: &str) -> Result<()>

Sets the window caption text.

Source

pub fn set_as_foreground(self) -> Result<()>

Brings the window to the foreground.

May interfere with the Z-position of other windows created by this process.

Source

pub fn set_as_active(self) -> Result<()>

Sets the window as the currently active (selected) window.

Source

pub fn set_show_state(self, state: WindowShowState) -> Result<()>

Changes the window show state.

Source

pub fn get_placement(self) -> Result<WindowPlacement>

Returns the window’s show state and positions.

Source

pub fn set_placement(self, placement: &WindowPlacement) -> Result<()>

Sets the window’s show state and positions.

Source

pub fn modify_placement_with<F>(self, f: F) -> Result<()>
where F: FnOnce(&mut WindowPlacement) -> Result<()>,

Source

pub fn set_z_position(self, z_position: WindowZPosition) -> Result<()>

Source

pub fn get_client_area_coords(self) -> Result<Rectangle>

Returns the window’s client area rectangle relative to the screen.

Source

pub fn get_region(self) -> Result<Option<Region>>

Source

pub fn set_region(self, region: Region) -> Result<()>

Sets the window’s interaction region.

Will potentially remove visual styles from the window.

Source

pub fn redraw(self) -> Result<()>

Source

pub fn get_class_name(self) -> Result<String>

Returns the class name of the window’s associated WindowClass.

Source

pub fn send_command(self, action: WindowCommand) -> Result<()>

Sends a command to the window, same as if one of the symbols in its top right were clicked.

Source

pub fn flash(self)

Flashes the window using default flash settings.

Same as Self::flash_custom using Default::default for all parameters.

Source

pub fn flash_custom( self, element: FlashElement, duration: FlashDuration, frequency: FlashInterval, )

Flashes the window, allowing various customization parameters.

Source

pub fn flash_stop(self)

Stops the window from flashing.

Source

pub fn set_timer(self, timer_id: usize, interval_ms: u32) -> Result<()>

Source

pub fn kill_timer(self, timer_id: usize) -> Result<()>

Source

pub fn send_user_message(self, message: CustomUserMessage) -> Result<()>

Source

pub fn get_creator_thread_id(self) -> ThreadId

Available on crate feature process only.

Returns the thread ID that created this window.

Source

pub fn get_creator_process_id(self) -> ProcessId

Available on crate feature process only.

Returns the process ID that created this window.

Source

pub fn get_nonchild_windows(thread_id: ThreadId) -> Vec<Self>

Available on crate feature process only.

Returns all top-level (non-child) windows created by the thread.

Source

pub fn set_monitor_power(self, level: MonitorPower) -> Result<()>

Turns the monitor on or off.

Windows requires this command to be sent through a window, e.g. using WindowHandle::get_foreground_window.

Trait Implementations§

Source§

impl Clone for WindowHandle

Source§

fn clone(&self) -> WindowHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WindowHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<WindowHandle> for HWND

Source§

fn from(value: WindowHandle) -> Self

Returns the underlying raw window handle used by [windows].

Source§

impl PartialEq for WindowHandle

Source§

fn eq(&self, other: &WindowHandle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<HWND> for WindowHandle

Source§

fn try_from(value: HWND) -> Result<Self, Self::Error>

Returns a new window handle from a raw handle if it is non-null.

Source§

type Error = TryFromHWNDError

The type returned in the event of a conversion error.
Source§

impl Copy for WindowHandle

Source§

impl Eq for WindowHandle

Source§

impl Send for WindowHandle

Source§

impl StructuralPartialEq for WindowHandle

Source§

impl Sync for WindowHandle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V