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
mod linux;
#[deprecated(since="0.2.3", note="This function was an anti-pattern. Use Bot::new() instead")]
pub fn new_bot() -> Bot {
Bot::new()
}
pub struct Bot {
display: linux::Display,
root_window: Option<linux::Window>,
}
impl Bot {
pub fn new() -> Bot {
Bot {
display: linux::open_display(None),
root_window: None,
}
}
#[cfg(target_os = "linux")]
pub fn push_key(&self, string: &str) {
linux::push_key(self.display, string);
}
#[cfg(target_os = "macos")]
pub fn push_key(&self, string: &str) {
unimplemented!();
}
#[cfg(target_os = "windows")]
pub fn push_key(&self, string: &str) {
unimplemented!();
}
#[cfg(target_os = "linux")]
pub fn type_keys(&self, string: &str) {
linux::type_keys(self.display, string);
}
#[cfg(target_os = "macos")]
pub fn type_keys(&self, string: &str) {
unimplemented!();
}
#[cfg(target_os = "windows")]
pub fn type_keys(&self, string: &str) {
unimplemented!();
}
#[cfg(target_os = "linux")]
pub fn set_mouse_pos(&mut self, x: i32, y: i32) {
if self.root_window.is_none() {
self.root_window = Some(linux::root_window(self.display, 0));
}
linux::set_mouse_pos(self.display, self.root_window.unwrap(), x, y);
}
#[cfg(target_os = "macos")]
pub fn set_mouse_pos(&mut self, x: i32, y: i32) {
unimplemented!();
}
#[cfg(target_os = "windows")]
pub fn set_mouse_pos(&mut self, x: i32, y: i32) {
unimplemented!();
}
#[cfg(target_os = "linux")]
pub fn move_mouse(&self, x: i32, y: i32) {
linux::move_mouse(self.display, x, y);
}
#[cfg(target_os = "macos")]
pub fn move_mouse(&self, x: i32, y: i32) {
unimplemented!();
}
#[cfg(target_os = "windows")]
pub fn move_mouse(&self, x: i32, y: i32) {
unimplemented!();
}
}