跳到主要内容

Enigo

搜索

结构体 Enigo 

源代码
pub struct Enigo { /* 私有字段 */ }
展开描述

用于处理事件发送的主结构体

实现§

源代码§

impl Enigo

源代码

pub fn new(settings: &Settings) -> Result<Self, NewConError>

创建一个新的 Enigo 结构体,以使用指定的设置建立连接来模拟输入

§错误

请参考 NewConError 的文档以了解在哪些情况下会返回错误。

源代码

pub fn held(&mut self) -> (Vec<Key>, Vec<u16>)

返回当前所有被按下的按键列表

源代码

pub fn get_marker_value(&self) -> usize

返回 enigo 事件标记所使用的值

trait 实现§

源代码§

impl Agent for Enigo

源代码§

fn execute(&mut self, token: &Token) -> InputResult<()>

执行与 token 关联的动作。Token::Text 将输入文本,Token::Scroll 将触发滚动,依此类推。更多信息请参考 Token 枚举的文档。 阅读更多
源代码§

impl Debug for Enigo

源代码§

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

使用给定的格式化器格式化该值。 阅读更多
源代码§

impl Drop for Enigo

源代码§

fn drop(&mut self)

执行该类型的析构函数。 阅读更多
源代码§

impl Keyboard for Enigo

源代码§

fn text(&mut self, text: &str) -> InputResult<()>

一次性输入完整文本字符串,而非逐个按键。输入较长文本时这种方法更快,但代价是无法识别键盘快捷键。

源代码§

fn key(&mut self, key: Key, direction: Direction) -> InputResult<()>

通过 XTest 扩展向 X11 服务器发送按键事件。

源代码§

fn raw(&mut self, scan: u16, direction: Direction) -> InputResult<()>

发送原始 keycode。keycode 在当前布局下可能已映射或未映射,你需要自行确认。如果你希望无论布局如何都模拟同一个按键(如游戏中常用的 WASD),此函数非常有用。请参考 Keyboard::key 函数,如果你只想输入某个特定按键而无需关心布局/键位映射。 仅 Windows:如果你希望输入扩展按键的 keycode(扫描码),需要设置额外的位。例如可以这样:enigo.raw(45 | EXT, Direction::Click) 阅读更多
源代码§

impl Mouse for Enigo

源代码§

fn button(&mut self, button: Button, direction: Direction) -> InputResult<()>

发送单个鼠标按键事件。例如你可以用此方法模拟左键点击。某些按键是平台特有的。 阅读更多
源代码§

fn move_mouse( &mut self, x: i32, y: i32, coordinate: Coordinate, ) -> InputResult<()>

将鼠标光标移动到指定的 x 和 y 坐标。 阅读更多
源代码§

fn scroll(&mut self, length: i32, axis: Axis) -> InputResult<()>

发送鼠标滚轮事件 阅读更多
源代码§

fn main_display(&self) -> InputResult<(i32, i32)>

获取主显示屏的(宽度,高度)像素值。目前仅支持主显示屏 阅读更多
源代码§

fn location(&self) -> InputResult<(i32, i32)>

获取鼠标位置的像素坐标 阅读更多

自动 trait 实现§

§

impl Freeze for Enigo

§

impl RefUnwindSafe for Enigo

§

impl Send for Enigo

§

impl Sync for Enigo

§

impl Unpin for Enigo

§

impl UnsafeUnpin for Enigo

§

impl UnwindSafe for Enigo

blanket 实现§

源代码§

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

源代码§

fn type_id(&self) -> TypeId

获取 selfTypeId阅读更多
源代码§

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

源代码§

fn borrow(&self) -> &T

从拥有的值不可变地借用。 阅读更多
源代码§

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

源代码§

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

从拥有的值可变地借用。 阅读更多
源代码§

impl<T> From<T> for T

源代码§

fn from(t: T) -> T

原样返回参数。

源代码§

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

源代码§

fn into(self) -> U

调用 U::from(self)

也就是说,此转换是 From<T> for U 实现选择执行的操作。

源代码§

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

源代码§

type Error = Infallible

转换出错时返回的类型。
源代码§

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

执行该转换。
源代码§

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

源代码§

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

转换出错时返回的类型。
源代码§

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

执行该转换。