pub trait Mouse {
// Required methods
fn button(
&mut self,
button: Button,
direction: Direction,
) -> InputResult<()>;
fn move_mouse(
&mut self,
x: i32,
y: i32,
coordinate: Coordinate,
) -> InputResult<()>;
fn scroll(&mut self, length: i32, axis: Axis) -> InputResult<()>;
fn main_display(&self) -> InputResult<(i32, i32)>;
fn location(&self) -> InputResult<(i32, i32)>;
}展开描述
包含控制鼠标和获取显示屏尺寸的函数。 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 坐标。
You can specify absolute coordinates or relative from the current position.
If you use absolute coordinates, the top left corner of your monitor screen is x=0 y=0. Move the cursor down the screen by increasing the y and to the right by increasing x coordinate.
If you use relative coordinates, a positive x value moves the mouse
cursor x pixels to the right. A negative value for x moves the mouse
cursor to the left. A positive value of y moves the mouse cursor down, a
negative one moves the mouse cursor up.
§错误
请参考 InputError 的文档以了解在哪些情况下会返回错误。
源代码fn scroll(&mut self, length: i32, axis: Axis) -> InputResult<()>
fn scroll(&mut self, length: i32, axis: Axis) -> InputResult<()>
发送鼠标滚轮事件
§Arguments
axis- The axis to scroll onlength- Number of 15° (click) rotations of the mouse wheel to scroll. How many lines will be scrolled depends on the current setting of the operating system.
With Axis::Vertical, a positive length will result in scrolling down
and negative ones up. With Axis::Horizontal, a positive length
will result in scrolling to the right and negative ones to the left
§错误
请参考 InputError 的文档以了解在哪些情况下会返回错误。