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
//! The ahk language: a lexer, an AST, a parser and an interpreter
//! for AutoHotkey-style scripts.
//!
//! The crate is portable and does no I/O of its own: the script is parsed
//! here and executed against a [`runtime::Desktop`], which is whatever
//! implements it. The real one lives on the lab box (the `ahk-box`
//! crate); the tests use a fake that records the calls.
//!
//! ## Without the standard library
//!
//! The crate runs on a target that has no `std` at all. Turn the `std`
//! feature off and the language is the same; what the host has to supply
//! is the clock -- the time the runtime measures itself with, and the
//! pause the `Sleep` statement asks for -- through the [`runtime::Clock`]
//! trait.
//!
//! ```
//! use ahk::runtime::{Clock, Runtime};
//! # use ahk::desktop::{Clipboard, Desktop, Dialogs, Files, Hotkeys, Keyboard, Machine, Native, Network, Pictures, Pointer, Processes, Screen, Sound, Timers, Windows};
//! # use core::time::Duration;
//! # #[derive(Default)]
//! # struct Fake;
//! # impl Desktop for Fake {}
//! # impl Keyboard for Fake {
//! # fn type_text(&mut self, _: &str) -> Result<String, String> { Ok(String::new()) }
//! # fn press_key(&mut self, _: &str, _: &[String]) -> Result<String, String> { Ok(String::new()) }
//! # }
//! # impl Pointer for Fake {
//! # fn click(&mut self, _: i64, _: i64, _: &str, _: u32) -> Result<String, String> { Ok(String::new()) }
//! # }
//! # impl Screen for Fake {
//! # fn capture(&mut self, _: i64, _: i64, _: i64, _: i64, _: &str) -> Result<String, String> { Ok(String::new()) }
//! # fn pixel(&mut self, _: i64, _: i64) -> Result<String, String> { Ok("#000000".into()) }
//! # }
//! # impl Processes for Fake {
//! # fn run(&mut self, _: &str, _: &str) -> Result<(i32, String, String), String> { Ok((0, String::new(), String::new())) }
//! # }
//! # impl Windows for Fake {}
//! # impl Files for Fake {}
//! # impl Clipboard for Fake {}
//! # impl Timers for Fake {}
//! # impl Hotkeys for Fake {}
//! # impl Native for Fake {}
//! # impl Sound for Fake {}
//! # impl Machine for Fake {}
//! # impl Dialogs for Fake {}
//! # impl Network for Fake {}
//! # impl Pictures for Fake {}
//! # struct TheClock;
//! # impl Clock for TheClock {
//! # fn now_ms(&self) -> u64 { 0 }
//! # fn sleep_ms(&mut self, _: u64) {}
//! # }
//! # let script = "x := 40 + 2\nMsgBox \"the answer is %x%\"";
//! # let statements = ahk::parse(script).expect("parses");
//! # let mut desktop = Fake::default();
//! # let mut clock = TheClock;
//! # let report = Runtime::with_clock(&mut desktop, &mut clock, Duration::from_secs(10)).run(&statements);
//! # assert!(report.ok);
//! ```
//!
//! ```
//! use ahk::{parse, runtime::{Runtime, Value}};
//!
//! let script = "x := 40 + 2\nMsgBox \"the answer is %x%\"";
//! let statements = parse(script).expect("parses");
//! let mut desktop = Fake::default();
//! let report = Runtime::new(&mut desktop, core::time::Duration::from_secs(10)).run(&statements);
//! assert!(report.ok);
//! assert_eq!(report.output, vec!["the answer is 42"]);
//! # use ahk::desktop::{Clipboard, Desktop, Dialogs, Files, Hotkeys, Keyboard, Machine, Native, Network, Pictures, Pointer, Processes, Screen, Sound, Timers, Windows};
//! # #[derive(Default)]
//! # struct Fake;
//! # impl Desktop for Fake {}
//! # impl Keyboard for Fake {
//! # fn type_text(&mut self, _: &str) -> Result<String, String> { Ok(String::new()) }
//! # fn press_key(&mut self, _: &str, _: &[String]) -> Result<String, String> { Ok(String::new()) }
//! # }
//! # impl Pointer for Fake {
//! # fn click(&mut self, _: i64, _: i64, _: &str, _: u32) -> Result<String, String> { Ok(String::new()) }
//! # }
//! # impl Screen for Fake {
//! # fn capture(&mut self, _: i64, _: i64, _: i64, _: i64, _: &str) -> Result<String, String> { Ok(String::new()) }
//! # fn pixel(&mut self, _: i64, _: i64) -> Result<String, String> { Ok("#000000".into()) }
//! # }
//! # impl Processes for Fake {
//! # fn run(&mut self, _: &str, _: &str) -> Result<(i32, String, String), String> { Ok((0, String::new(), String::new())) }
//! # }
//! # impl Windows for Fake {}
//! # impl Files for Fake {}
//! # impl Clipboard for Fake {}
//! # impl Timers for Fake {}
//! # impl Hotkeys for Fake {}
//! # impl Native for Fake {}
//! # impl Sound for Fake {}
//! # impl Machine for Fake {}
//! # impl Dialogs for Fake {}
//! # impl Network for Fake {}
//! # impl Pictures for Fake {}
//! ```
extern crate alloc;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use SystemClock;
pub use ;