跳转到主要内容

Window

搜索

结构体 Window 

源码
pub struct Window { /* private fields */ }
展开描述

表示一个可以被捕获的窗口。

§示例

use windows_capture::window::Window;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let window = Window::foreground()?;
    println!("前台窗口标题: {}", window.title()?);

    Ok(())
}

实现§

Source§

impl Window

Source

pub fn foreground() -> Result<Self, Error>

返回当前位于前台的窗口。

§错误
Source

pub fn from_name(title: &str) -> Result<Self, Error>

通过精确的标题查找窗口。

§错误
Source

pub fn from_contains_name(title: &str) -> Result<Self, Error>

查找标题包含给定子串的窗口。

§错误
Source

pub fn title(&self) -> Result<String, Error>

返回窗口的标题。

§错误
Source

pub fn process_id(&self) -> Result<u32, Error>

返回窗口的进程 ID。

§错误
Source

pub fn process_name(&self) -> Result<String, Error>

返回拥有该窗口的进程名称。

此函数需要 PROCESS_QUERY_INFORMATIONPROCESS_VM_READ 权限。

§错误
Source

pub fn monitor(&self) -> Option<Monitor>

返回与窗口相交面积最大的显示器。

如果窗口不与任何显示器相交,则返回 None

Source

pub fn rect(&self) -> Result<RECT, Error>

返回窗口在屏幕坐标中的边界矩形。

§错误
Source

pub fn title_bar_height(&self) -> Result<u32, Error>

计算窗口标题栏的高度(以像素为单位)。

§错误
Source

pub fn is_valid(&self) -> bool

检查窗口是否是有效的捕获目标。

§返回值

如果窗口可见、不是工具窗口且不是子窗口,则返回 true。 否则返回 false

Source

pub fn enumerate() -> Result<Vec<Self>, Error>

返回所有可捕获窗口的列表。

§错误
Source

pub fn width(&self) -> Result<i32, Error>

返回窗口的宽度(以像素为单位)。

§错误
Source

pub fn height(&self) -> Result<i32, Error>

返回窗口的高度(以像素为单位)。

§错误
Source

pub const fn from_raw_hwnd(hwnd: *mut c_void) -> Self

从原始的 HWND 句柄构造一个 Window 实例。

Source

pub const fn as_raw_hwnd(&self) -> *mut c_void

返回窗口的原始 HWND 句柄。

trait 实现§

Source§

impl Clone for Window

Source§

fn clone(&self) -> Window

返回该值的副本。 了解更多
1.0.0 · Source§

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

source 执行复制赋值。 了解更多
Source§

impl Debug for Window

Source§

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

使用给定的格式化器格式化该值。 了解更多
Source§

impl PartialEq for Window

Source§

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

测试 selfother 的值是否相等,由 == 使用。
1.0.0 · Source§

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

测试 !=。默认实现几乎总是足够的,除非有非常充分的理由,否则不应被重写。
Source§

impl TryInto<GraphicsCaptureItemType> for Window

Source§

type Error = Error

在转换出错时返回的类型。
Source§

fn try_into(self) -> Result<GraphicsCaptureItemType, Self::Error>

执行转换。
Source§

impl Copy for Window

Source§

impl Eq for Window

Source§

impl Send for Window

Source§

impl StructuralPartialEq for Window

自动 trait 实现§

Blanket 实现§

Source§

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

Source§

fn type_id(&self) -> TypeId

获取 selfTypeId了解更多
Source§

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

Source§

fn borrow(&self) -> &T

从拥有的值不可变地借用。 了解更多
Source§

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

Source§

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

从拥有的值可变地借用。 了解更多
Source§

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

Source§

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

🔬这是 nightly-only 实验性 API。(clone_to_uninit
selfdest 执行复制赋值。 了解更多
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回参数。

Source§

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

Source§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换由 From<T> for U 的实现决定。

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

into_lefttrue 时,将 self 转换为 Left 变体的 Either<Self, Self>; 否则将其转换为 Right 变体的 Either<Self, Self>了解更多
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

into_left(&self) 返回 true 时,将 self 转换为 Left 变体的 Either<Self, Self>; 否则将其转换为 Right 变体的 Either<Self, Self>了解更多
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

指针的对齐方式。
Source§

type Init = T

用于初始化的类型。
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

使用给定的初始化器初始化 a。 了解更多
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

解引用给定的指针。 了解更多
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

可变地解引用给定的指针。 了解更多
Source§

unsafe fn drop(ptr: usize)

丢弃给定指针所指向的对象。 了解更多
Source§

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

Source§

type Owned = T

获得所有权后得到的类型。
Source§

fn to_owned(&self) -> T

从借用的数据创建拥有的数据,通常通过克隆。 了解更多
Source§

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

使用借用的数据替换拥有的数据,通常通过克隆。 了解更多
Source§

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

Source§

type Error = Infallible

在转换出错时返回的类型。
Source§

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

执行转换。
Source§

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

Source§

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

在转换出错时返回的类型。
Source§

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

执行转换。