11
22
3- pub fn mouse_to_engin ( key : u8 ) -> Option < enigo:: MouseButton > {
3+ pub fn mouse_to_engin ( key : u8 ) -> Option < enigo:: Button > {
44 match key {
5- 233 => Some ( enigo:: MouseButton :: Left ) ,
6- 235 => Some ( enigo:: MouseButton :: Right ) ,
5+ 0 => Some ( enigo:: Button :: Left ) ,
6+ 1 => Some ( enigo:: Button :: Middle ) ,
7+ 2 => Some ( enigo:: Button :: Right ) ,
78 _ => None ,
89 }
910}
1011
1112pub fn key_to_enigo ( key : u8 ) -> Option < enigo:: Key > {
1213 match key {
1314 27 => Some ( enigo:: Key :: Escape ) ,
14- 190 => Some ( enigo:: Key :: F1 ) ,
15- 191 => Some ( enigo:: Key :: F2 ) ,
16- 192 => Some ( enigo:: Key :: F3 ) ,
17- 193 => Some ( enigo:: Key :: F4 ) ,
18- 194 => Some ( enigo:: Key :: F5 ) ,
19- 195 => Some ( enigo:: Key :: F6 ) ,
20- 196 => Some ( enigo:: Key :: F7 ) ,
21- 197 => Some ( enigo:: Key :: F8 ) ,
22- 198 => Some ( enigo:: Key :: F9 ) ,
23- 199 => Some ( enigo:: Key :: F10 ) ,
24- 200 => Some ( enigo:: Key :: F11 ) ,
25- 201 => Some ( enigo:: Key :: F12 ) ,
15+ 112 => Some ( enigo:: Key :: F1 ) ,
16+ 113 => Some ( enigo:: Key :: F2 ) ,
17+ 114 => Some ( enigo:: Key :: F3 ) ,
18+ 115 => Some ( enigo:: Key :: F4 ) ,
19+ 116 => Some ( enigo:: Key :: F5 ) ,
20+ 117 => Some ( enigo:: Key :: F6 ) ,
21+ 118 => Some ( enigo:: Key :: F7 ) ,
22+ 119 => Some ( enigo:: Key :: F8 ) ,
23+ 120 => Some ( enigo:: Key :: F9 ) ,
24+ 121 => Some ( enigo:: Key :: F10 ) ,
25+ 122 => Some ( enigo:: Key :: F11 ) ,
26+ 123 => Some ( enigo:: Key :: F12 ) ,
2627 // 19 => Some(enigo::Key::Pause), // Pause
2728 // 97 => Some(enigo::Key::Print), // Print
28- 255 => Some ( enigo:: Key :: Delete ) ,
29- 87 => Some ( enigo:: Key :: End ) ,
30- 96 => Some ( enigo:: Key :: Layout ( '`' ) ) ,
31- 48 => Some ( enigo:: Key :: Layout ( '0' ) ) ,
32- 49 => Some ( enigo:: Key :: Layout ( '1' ) ) ,
33- 50 => Some ( enigo:: Key :: Layout ( '2' ) ) ,
34- 51 => Some ( enigo:: Key :: Layout ( '3' ) ) ,
35- 52 => Some ( enigo:: Key :: Layout ( '4' ) ) ,
36- 53 => Some ( enigo:: Key :: Layout ( '5' ) ) ,
37- 54 => Some ( enigo:: Key :: Layout ( '6' ) ) ,
38- 55 => Some ( enigo:: Key :: Layout ( '7' ) ) ,
39- 56 => Some ( enigo:: Key :: Layout ( '8' ) ) ,
40- 57 => Some ( enigo:: Key :: Layout ( '9' ) ) ,
41- 45 => Some ( enigo:: Key :: Layout ( '-' ) ) ,
42- 61 => Some ( enigo:: Key :: Layout ( '=' ) ) ,
29+ 46 => Some ( enigo:: Key :: Delete ) ,
30+ 35 => Some ( enigo:: Key :: End ) ,
31+ 192 => Some ( enigo:: Key :: Unicode ( '`' ) ) ,
32+ 48 => Some ( enigo:: Key :: Unicode ( '0' ) ) ,
33+ 49 => Some ( enigo:: Key :: Unicode ( '1' ) ) ,
34+ 50 => Some ( enigo:: Key :: Unicode ( '2' ) ) ,
35+ 51 => Some ( enigo:: Key :: Unicode ( '3' ) ) ,
36+ 52 => Some ( enigo:: Key :: Unicode ( '4' ) ) ,
37+ 53 => Some ( enigo:: Key :: Unicode ( '5' ) ) ,
38+ 54 => Some ( enigo:: Key :: Unicode ( '6' ) ) ,
39+ 55 => Some ( enigo:: Key :: Unicode ( '7' ) ) ,
40+ 56 => Some ( enigo:: Key :: Unicode ( '8' ) ) ,
41+ 57 => Some ( enigo:: Key :: Unicode ( '9' ) ) ,
42+ 189 => Some ( enigo:: Key :: Unicode ( '-' ) ) ,
43+ 187 => Some ( enigo:: Key :: Unicode ( '=' ) ) ,
4344 8 => Some ( enigo:: Key :: Backspace ) ,
4445 9 => Some ( enigo:: Key :: Tab ) ,
45- 91 => Some ( enigo:: Key :: Layout ( '[' ) ) ,
46- 93 => Some ( enigo:: Key :: Layout ( ']' ) ) ,
47- 92 => Some ( enigo:: Key :: Layout ( '\\' ) ) ,
48- 229 => Some ( enigo:: Key :: CapsLock ) ,
49- 59 => Some ( enigo:: Key :: Layout ( ';' ) ) ,
50- 39 => Some ( enigo:: Key :: Layout ( '\'' ) ) ,
46+ 219 => Some ( enigo:: Key :: Unicode ( '[' ) ) ,
47+ 221 => Some ( enigo:: Key :: Unicode ( ']' ) ) ,
48+ 220 => Some ( enigo:: Key :: Unicode ( '\\' ) ) ,
49+ 20 => Some ( enigo:: Key :: CapsLock ) ,
50+ 186 => Some ( enigo:: Key :: Unicode ( ';' ) ) ,
51+ 222 => Some ( enigo:: Key :: Unicode ( '\'' ) ) ,
5152 13 => Some ( enigo:: Key :: Return ) ,
52- 225 => Some ( enigo:: Key :: Shift ) , // ShiftL
53- 44 => Some ( enigo:: Key :: Layout ( ',' ) ) ,
54- 46 => Some ( enigo:: Key :: Layout ( '.' ) ) ,
55- 47 => Some ( enigo:: Key :: Layout ( '/' ) ) ,
56- 226 => Some ( enigo:: Key :: Shift ) , // ShiftR
57- 82 => Some ( enigo:: Key :: UpArrow ) ,
58- 227 => Some ( enigo:: Key :: Control ) , // ControlL
59- 233 => Some ( enigo:: Key :: Alt ) , // AltL
53+ 16 => Some ( enigo:: Key :: Shift ) , // ShiftL
54+ 188 => Some ( enigo:: Key :: Unicode ( ',' ) ) ,
55+ 190 => Some ( enigo:: Key :: Unicode ( '.' ) ) ,
56+ 191 => Some ( enigo:: Key :: Unicode ( '/' ) ) ,
57+ 161 => Some ( enigo:: Key :: Shift ) , // ShiftR
58+ 38 => Some ( enigo:: Key :: UpArrow ) ,
59+ 17 => Some ( enigo:: Key :: Control ) , // ControlL
60+ 18 => Some ( enigo:: Key :: Alt ) , // AltL
6061 32 => Some ( enigo:: Key :: Space ) ,
61- 234 => Some ( enigo:: Key :: Alt ) , // AltR
62+ 165 => Some ( enigo:: Key :: Alt ) , // AltR
6263 // 103 => Some(enigo::Key::Menu),
63- 228 => Some ( enigo:: Key :: Control ) , // ControlR
64- 81 => Some ( enigo:: Key :: LeftArrow ) ,
65- 84 => Some ( enigo:: Key :: DownArrow ) ,
66- 83 => Some ( enigo:: Key :: RightArrow ) ,
64+ 163 => Some ( enigo:: Key :: Control ) , // ControlR
65+ 37 => Some ( enigo:: Key :: LeftArrow ) ,
66+ 40 => Some ( enigo:: Key :: DownArrow ) ,
67+ 39 => Some ( enigo:: Key :: RightArrow ) ,
6768 // 99 => Some(enigo::Key::Raw(45)), // Insert
68- 86 => Some ( enigo:: Key :: PageDown ) ,
69- 80 => Some ( enigo:: Key :: Home ) ,
70- 85 => Some ( enigo:: Key :: PageUp ) ,
71- a if a >= 97 && a <= 122 => Some ( enigo:: Key :: Layout ( ( a - 97 + ( 'a' as u8 ) ) as char ) ) ,
69+ 34 => Some ( enigo:: Key :: PageDown ) ,
70+ 36 => Some ( enigo:: Key :: Home ) ,
71+ 33 => Some ( enigo:: Key :: PageUp ) ,
72+ a if a >= 65 && a <= 90 => Some ( enigo:: Key :: Unicode ( ( a - 65 + ( 'a' as u8 ) ) as char ) ) ,
7273 _ => None ,
7374 }
7475}
0 commit comments