pub struct Enigo { /* 私有字段 */ }展开描述
用于处理事件发送的主结构体
实现§
trait 实现§
源代码§impl Keyboard for Enigo
impl Keyboard for Enigo
源代码§fn text(&mut self, text: &str) -> InputResult<()>
fn text(&mut self, text: &str) -> InputResult<()>
一次性输入完整文本字符串,而非逐个按键。输入较长文本时这种方法更快,但代价是无法识别键盘快捷键。
源代码§fn raw(&mut self, scan: u16, direction: Direction) -> InputResult<()>
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
impl Mouse for Enigo
发送单个鼠标按键事件。例如你可以用此方法模拟左键点击。某些按键是平台特有的。 阅读更多
源代码§fn move_mouse(
&mut self,
x: i32,
y: i32,
coordinate: Coordinate,
) -> InputResult<()>
fn move_mouse( &mut self, x: i32, y: i32, coordinate: Coordinate, ) -> InputResult<()>
将鼠标光标移动到指定的 x 和 y 坐标。 阅读更多
源代码§fn main_display(&self) -> InputResult<(i32, i32)>
fn main_display(&self) -> InputResult<(i32, i32)>
获取主显示屏的(宽度,高度)像素值。目前仅支持主显示屏 阅读更多