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
impl Window
Sourcepub fn foreground() -> Result<Self, Error>
pub fn foreground() -> Result<Self, Error>
Sourcepub fn from_contains_name(title: &str) -> Result<Self, Error>
pub fn from_contains_name(title: &str) -> Result<Self, Error>
查找标题包含给定子串的窗口。
§错误
Error::WindowsError当枚举窗口失败时Error::FailedToConvertWindowsString当从 UTF-16 转换窗口标题失败时Error::NotFound当没有窗口标题包含指定的子串时
Sourcepub fn process_id(&self) -> Result<u32, Error>
pub fn process_id(&self) -> Result<u32, Error>
Sourcepub fn process_name(&self) -> Result<String, Error>
pub fn process_name(&self) -> Result<String, Error>
返回拥有该窗口的进程名称。
此函数需要 PROCESS_QUERY_INFORMATION 和 PROCESS_VM_READ 权限。
§错误
Error::WindowsError当打开进程或查询其基础模块名称失败时Error::FailedToConvertWindowsString当从 UTF-16 转换进程名称失败时
Sourcepub fn title_bar_height(&self) -> Result<u32, Error>
pub fn title_bar_height(&self) -> Result<u32, Error>
Sourcepub const fn from_raw_hwnd(hwnd: *mut c_void) -> Self
pub const fn from_raw_hwnd(hwnd: *mut c_void) -> Self
从原始的 HWND 句柄构造一个 Window 实例。
Sourcepub const fn as_raw_hwnd(&self) -> *mut c_void
pub const fn as_raw_hwnd(&self) -> *mut c_void
返回窗口的原始 HWND 句柄。
trait 实现§
Source§impl TryInto<GraphicsCaptureItemType> for Window
impl TryInto<GraphicsCaptureItemType> for Window
impl Copy for Window
impl Eq for Window
impl Send for Window
impl StructuralPartialEq for Window
自动 trait 实现§
impl Freeze for Window
impl RefUnwindSafe for Window
impl !Sync for Window
impl Unpin for Window
impl UnsafeUnpin for Window
impl UnwindSafe for Window
Blanket 实现§
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>
当
into_left 为 true 时,将 self 转换为
Left 变体的
Either<Self, Self>;
否则将其转换为
Right 变体的
Either<Self, Self>。
了解更多Source§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
当
into_left(&self) 返回 true 时,将 self 转换为
Left 变体的
Either<Self, Self>;
否则将其转换为
Right 变体的
Either<Self, Self>。
了解更多