pub struct WindowHandle { /* private fields */ }ui only.Expand description
A (non-null) handle to a window.
Implementations§
Source§impl WindowHandle
impl WindowHandle
Sourcepub fn get_console_window() -> Option<Self>
pub fn get_console_window() -> Option<Self>
Returns the console window associated with the current process, if there is one.
Sourcepub fn get_foreground_window() -> Option<Self>
pub fn get_foreground_window() -> Option<Self>
Returns the current foreground window, if any.
Sourcepub fn get_desktop_window() -> Result<Self>
pub fn get_desktop_window() -> Result<Self>
Returns the ‘desktop’ window.
Sourcepub fn get_toplevel_windows() -> Result<Vec<Self>>
pub fn get_toplevel_windows() -> Result<Vec<Self>>
Returns all top-level windows of desktop apps.
pub fn is_visible(self) -> bool
Sourcepub fn is_cloaked(self) -> Result<bool>
pub fn is_cloaked(self) -> Result<bool>
Checks if the window is cloaked.
See also: https://devblogs.microsoft.com/oldnewthing/20200302-00/?p=103507
Sourcepub fn get_caption_text(self) -> String
pub fn get_caption_text(self) -> String
Returns the window caption text, converted to UTF-8 in a potentially lossy way.
Sourcepub fn set_caption_text(self, text: &str) -> Result<()>
pub fn set_caption_text(self, text: &str) -> Result<()>
Sets the window caption text.
Sourcepub fn set_as_foreground(self) -> Result<()>
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.
Sourcepub fn set_as_active(self) -> Result<()>
pub fn set_as_active(self) -> Result<()>
Sets the window as the currently active (selected) window.
Sourcepub fn set_show_state(self, state: WindowShowState) -> Result<()>
pub fn set_show_state(self, state: WindowShowState) -> Result<()>
Changes the window show state.
Sourcepub fn get_placement(self) -> Result<WindowPlacement>
pub fn get_placement(self) -> Result<WindowPlacement>
Returns the window’s show state and positions.
Sourcepub fn set_placement(self, placement: &WindowPlacement) -> Result<()>
pub fn set_placement(self, placement: &WindowPlacement) -> Result<()>
Sets the window’s show state and positions.
pub fn modify_placement_with<F>(self, f: F) -> Result<()>
pub fn set_z_position(self, z_position: WindowZPosition) -> Result<()>
Sourcepub fn get_client_area_coords(self) -> Result<Rectangle>
pub fn get_client_area_coords(self) -> Result<Rectangle>
Returns the window’s client area rectangle relative to the screen.
pub fn get_region(self) -> Result<Option<Region>>
Sourcepub fn set_region(self, region: Region) -> Result<()>
pub fn set_region(self, region: Region) -> Result<()>
Sets the window’s interaction region.
Will potentially remove visual styles from the window.
pub fn redraw(self) -> Result<()>
Sourcepub fn get_class_name(self) -> Result<String>
pub fn get_class_name(self) -> Result<String>
Returns the class name of the window’s associated WindowClass.
Sourcepub fn send_command(self, action: WindowCommand) -> Result<()>
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.
Sourcepub fn flash(self)
pub fn flash(self)
Flashes the window using default flash settings.
Same as Self::flash_custom using Default::default for all parameters.
Sourcepub fn flash_custom(
self,
element: FlashElement,
duration: FlashDuration,
frequency: FlashInterval,
)
pub fn flash_custom( self, element: FlashElement, duration: FlashDuration, frequency: FlashInterval, )
Flashes the window, allowing various customization parameters.
Sourcepub fn flash_stop(self)
pub fn flash_stop(self)
Stops the window from flashing.
pub fn set_timer(self, timer_id: usize, interval_ms: u32) -> Result<()>
pub fn kill_timer(self, timer_id: usize) -> Result<()>
pub fn send_user_message(self, message: CustomUserMessage) -> Result<()>
Sourcepub fn get_creator_thread_id(self) -> ThreadId
Available on crate feature process only.
pub fn get_creator_thread_id(self) -> ThreadId
process only.Returns the thread ID that created this window.
Sourcepub fn get_creator_process_id(self) -> ProcessId
Available on crate feature process only.
pub fn get_creator_process_id(self) -> ProcessId
process only.Returns the process ID that created this window.
Sourcepub fn get_nonchild_windows(thread_id: ThreadId) -> Vec<Self>
Available on crate feature process only.
pub fn get_nonchild_windows(thread_id: ThreadId) -> Vec<Self>
process only.Returns all top-level (non-child) windows created by the thread.
Sourcepub fn set_monitor_power(self, level: MonitorPower) -> Result<()>
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
impl Clone for WindowHandle
Source§fn clone(&self) -> WindowHandle
fn clone(&self) -> WindowHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WindowHandle
impl Debug for WindowHandle
Source§impl From<WindowHandle> for HWND
impl From<WindowHandle> for HWND
Source§fn from(value: WindowHandle) -> Self
fn from(value: WindowHandle) -> Self
Returns the underlying raw window handle used by [windows].