1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
//! Convenience functions for the mouse functionality in xdotool.
use fmt;
use Output;
use crate;
use crate;
use crateOptionVec;
use craterun;
/// Move the mouse to the specific x and y coordinates on the screen
///
/// # Options
///
/// - `MouseMoveOption::Window(String)` Specify a window to move relative to. Coordinates 0,0 are at the top left of the window you choose.
/// - `MouseMoveOption::Screen(u8)` Move the mouse to the specified screen to move to.
/// This is only useful if you have multiple screens and ARE NOT using Xinerama. The default is the current screen. If you specify `MouseMoveOption::Window`, the `MouseMoveOption::Screen` option is ignored.
/// - `MouseMoveOption::Polar` Use polar coordinates. This makes `x` an angle (in degrees, 0-360, etc) and `y` the distance. Rotation starts at 'up' (0 degrees) and rotates clockwise: 90 = right, 180 = down, 270 = left. The origin defaults to the center of the current screen. If you specify a `MouseMoveOption::Window`, then the origin is the center of that window.
/// - `MouseMoveOption::Sync` After sending the mouse move request, wait until the mouse is actually moved. If no movement is necessary, we will not wait. This is useful for scripts that depend on actions being completed before moving on.
/// - `MouseMoveOption::ClearModifiers`
///
/// # Examples
///
/// Move mouse to position x=200 y=200:
///
/// ```
/// # use xdotool::{mouse, OptionVec};
/// let output = mouse::move_mouse(200, 200, OptionVec::new());
/// println!("{}", output.status);
/// ```
///
/// Move mouse to the top left corner of a window:
///
/// ```
/// # use xdotool::command::options;
/// # use xdotool::{mouse, option_vec, OptionVec};
/// let output = mouse::move_mouse(200, 200, option_vec![
/// options::MouseMoveOption::Window("window-id".to_owned())
/// ]);
/// println!("{}", output.status);
/// ```
/// Move the mouse x,y pixels relative to the current position of the mouse cursor.
///
/// # Options
///
/// - `MouseMoveRelativeOption::Polar` Use polar coordinates. This makes `x` an angle (in degrees, 0-360, etc) and `y` the distance. Rotation starts at 'up' (0 degrees) and rotates clockwise: 90 = right, 180 = down, 270 = left. The origin defaults to the center of the current screen.
/// - `MouseMoveRelativeOption::Sync` After sending the mouse move request, wait until the mouse is actually moved. If no movement is necessary, we will not wait. Note that we wait until the mouse moves at all, not necessarily that it actually reaches your intended destination.
/// - `MouseMoveRelativeOption::ClearModifiers`
///
/// # Examples
///
/// Move the mouse 100 pixels to the right and 300 pixels up and wait for the action to complete:
///
/// ```
/// # use xdotool::command::options;
/// # use xdotool::{mouse, option_vec, OptionVec};
/// let output = mouse::move_mouse_relative(100, -300, option_vec![
/// options::MouseMoveRelativeOption::Sync
/// ]);
/// println!("{}", String::from_utf8(output.stdout)?);
/// # Ok::<(), std::string::FromUtf8Error>(())
/// ```
/// Send a click, that is, a [`click_down`](fn.click_down.html) followed by [`click_up`](fn.click_up.html) for the given button with a short delay between the two (currently 12ms).
///
/// # Options
///
/// - `ClickOption::Repeat(u32)` Specify how many times to click. Default is 1. For a double-click use `ClickOption::Repeat(2)`.
/// - `ClickOption::Delay(u32)` Specify how long, in milliseconds, to delay between clicks. This option is not used if the `ClickOption::Repeat` option is set to 1 (default).
/// - `ClickOption::Window(String)` Specify a window to send a click to.
/// - `ClickOption::ClearModifiers`
///
/// # Examples
///
/// Send a left double-click to the current mouse position:
///
/// ```
/// # use xdotool::command::options;
/// # use xdotool::mouse::{self, Button};
/// # use xdotool::{option_vec, OptionVec};
/// let output = mouse::click(Button::Left, option_vec![
/// options::ClickOption::Repeat(2)
/// ]);
/// ```
/// Same as [`click`](fn.click.html), except only a mouse down is sent.
///
/// # Options
///
/// - `ClickOption::Repeat(u32)` Specify how many times to click. Default is 1. For a double-click use `ClickOption::Repeat(2)`.
/// - `ClickOption::Delay(u32)` Specify how long, in milliseconds, to delay between clicks. This option is not used if the `ClickOption::Repeat` option is set to 1 (default).
/// - `ClickOption::Window(String)` Specify a window to send a click to.
/// - `ClickOption::ClearModifiers`
/// Same as [`click`](fn.click.html), except only a mouse up is sent.
///
/// # Options
///
/// - `ClickOption::Repeat(u32)` Specify how many times to click. Default is 1. For a double-click use `ClickOption::Repeat(2)`.
/// - `ClickOption::Delay(u32)` Specify how long, in milliseconds, to delay between clicks. This option is not used if the `ClickOption::Repeat` option is set to 1 (default).
/// - `ClickOption::Window(String)` Specify a window to send a click to.
/// - `ClickOption::ClearModifiers`
/// Outputs the x, y, screen, and window id of the mouse cursor. Screen numbers will be nonzero if you have multiple monitors and are not using Xinerama.
///
/// # Examples
///
/// Print the x, y, screen and window id of the mouse cursor:
///
/// ```
/// # use xdotool::command::options;
/// # use xdotool::mouse;
/// let output = mouse::get_mouse_location();
/// println!("{}", String::from_utf8(output.stdout)?);
/// # Ok::<(), std::string::FromUtf8Error>(())
/// ```
/// Bind an action to events when the mouse hits the screen edge or corner.
///
/// # Options
///
/// - `BehaveScreenEdgeOption::Delay(u32)` Delay in milliseconds before running the command. This allows you to require a given edge or corner to be held for a short period before your command will run. If you leave the edge or corner before the delay expires then the time will reset.
/// - `BehaveScreenEdgeOption::Quiesce(u32)` Delay in milliseconds before the next command will run. This helps prevent accidentally running your command extra times; especially useful if you have a very short --delay (like the default of 0).
///
/// # Examples
///
/// Open firefox if mouse is in top right corner for half a second:
///
/// ```no_run
/// # use xdotool::command::{options, sub_commands, Command};
/// # use xdotool::mouse::{self, ScreenEdge};
/// # use xdotool::{option_vec, OptionVec};
/// let output = mouse::behave_screen_edge(
/// ScreenEdge::TopRight,
/// Command::Keyboard(sub_commands::Keyboard::Key(OptionVec::new())),
/// option_vec![options::BehaveScreenEdgeOption::Delay(500)]
/// );
/// ```
// TODO: Fix the command argument. Currently it only supports commands without arguments and it's not possible to pass shell commands