Repository navigation
Expand file tree
/
Copy pathRobot.cpp
More file actions
314 lines (246 loc) · 6.55 KB
/
Copy pathRobot.cpp
File metadata and controls
314 lines (246 loc) · 6.55 KB
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#include "Robot.hpp"
LONG Robot::coordToIndex(LONG x, LONG y) const {
}
void Robot::setup() {
}
void Robot::destroy() {
}
Robot::Robot() {
}
Robot::Robot(std::string const& windowClass, std::string const& windowDesc) {
}
Robot::~Robot() {
}
// Mouse
/**
* @brief Set the Cursor to a Position
*
* @param p position of the cursor after set
* @return BOOL success or failure
*/
BOOL Robot::setCursorPos(const POINT& p) {
}
/**
* @brief Moves and Presses the Left Mouse Button
*
* @param p position of the cursor for the press
* @return UINT error code
*/
UINT Robot::leftDown(const POINT& p) {
}
/**
* @brief Presses the Left Mouse Button
*
* @return UINT error code
*/
UINT Robot::leftDown() {
}
/**
* @brief Moves and Releases the Left Mouse Button
*
* @param p position of the cursor for the release
* @return UINT error code
*/
UINT Robot::leftUp(const POINT& p) {
}
/**
* @brief Releases the Left Mouse Button
*
* @return UINT error code
*/
UINT Robot::leftUp() {
}
/**
* @brief Moves and Presses the Right Mouse Button
*
* @param p position of the cursor for the press
* @return UINT error code
*/
UINT Robot::rightDown(const POINT& p) {
}
/**
* @brief Presses the Right Mouse Button
*
* @return UINT error code
*/
UINT Robot::rightDown() {
}
/**
* @brief Moves and Releases the Right Mouse Button
*
* @param p position of the cursor for the release
* @return UINT error code
*/
UINT Robot::rightUp(const POINT& p) {
}
/**
* @brief Releases the Right Mouse Button
*
* @return UINT error code
*/
UINT Robot::rightUp() {
}
/**
* @brief Moves and Clicks the Left Mouse Button
*
* @param p position of the cursor for the click
* @param clickDuration milliseconds
* @return UINT error code
*/
UINT Robot::leftClick(const POINT& p, DWORD clickDuration) {
}
/**
* @brief Clicks the Left Mouse Button
*
* @param clickDuration milliseconds
* @return UINT error code
*/
UINT Robot::leftClick(DWORD clickDuration) {
}
/**
* @brief Moves and Clicks the Right Mouse Button
*
* @param p position of the cursor for the click
* @param clickDuration milliseconds
* @return UINT error code
*/
UINT Robot::rightClick(const POINT& p, DWORD clickDuration) {
}
/**
* @brief Clicks the Left Mouse Button
*
* @param clickDuration milliseconds
* @return UINT error code
*/
UINT Robot::rightClick(DWORD clickDuration) {
}
// Keyboard
/**
* @brief Presses the provided key
*
* @param keyStroke character representing the key to press
*/
void Robot::keyDown(char keyStroke) {
}
/**
* @brief Presses the provided keys with the duration between each keystroke
*
* @param keyStrokes characters representing the keys to press
* @param durationBetweenKeyStrokes milliseconds between each keystroke
*/
void Robot::keyDown(const char keyStrokes[], DWORD durationBetweenKeyStrokes = 0) {
}
/**
* @brief Releases the provided key
*
* @param keyStroke character representing the key to release
*/
void Robot::keyUp(char keyStroke) {
}
/**
* @brief Releases the provided keys with the duration between each keystroke
*
* @param keyStrokes characters representing the keys to release
* @param durationBetweenKeyStrokes milliseconds between each keystroke
*/
void Robot::keyUp(const char keyStrokes[], DWORD durationBetweenKeyStrokes) {
}
/**
* @brief Clicks (types) the provided key with the duration between each press and release
*
* @param keyStroke character representing the key to type
* @param clickDuration milliseconds between each action
*/
void Robot::keyClick(char keyStroke, DWORD clickDuration) {
}
/**
* @brief Clicks (types) the provided keys with the duration between each press and release (no additional duration between subsequent characters)
*
* @param keyStrokes characters representing the keys to type
* @param durationBetweenKeyStrokes milliseconds between each action
*/
void Robot::keyClick(const char keyStrokes[], DWORD clickDurationForEachKey) {
}
/**
* @brief Presses Left Control, then the provided keyStroke, waits clickDuration milliseconds, then releases the provided keyStroke, and finally releases Left Control
*
* @param keyStroke character representing the key to type
* @param clickDuration milliseconds between each action
*/
void Robot::ctrlPlusKeyClick(char keyStroke, DWORD clickDuration) {
}
/**
* @brief Presses Left Control, performs keyClick(keystrokes, clickDurationForEachKey), and finally releases Left Control
*
* @param keyStrokes character representing the key to type
* @param clickDurationForEachKey milliseconds between each action
*/
void Robot::ctrlPlusKeyClick(const char keyStrokes[], DWORD clickDurationForEachKey) {
}
/**
* @brief Clicks the Enter Key
*
* @param clickDuration milliseconds
*/
void Robot::enterKeyClick(DWORD clickDuration) {
}
/**
* @brief Clicks the Escape Key
*
* @param clickDuration milliseconds
*/
void Robot::escapeKeyClick(DWORD clickDuration) {
}
// Reader
/**
* @brief Updates the Screen Buffer
*
*/
void Robot::updateScreenBuffer() {
}
/**
* @brief Get the Red value for the POINT
*
* @param p Point in the screen
* @return BYTE red component of the point
*/
[[nodiscard]] BYTE Robot::getRed(const POINT& p) const {
}
/**
* @brief Get the Green value for the POINT
*
* @param p Point in the screen
* @return BYTE green component of the point
*/
[[nodiscard]] BYTE Robot::getGreen(const POINT& p) const {
}
/**
* @brief Get the Blue value for the POINT
*
* @param p Point in the screen
* @return BYTE blue component of the point
*/
[[nodiscard]] BYTE Robot::getBlue(const POINT& p) const {
}
[[nodiscard]] BYTE abs_diff(BYTE x, BYTE y) {
return x < y ? y - x : x - y;
}
/**
* @brief Compares the Euclidean Color Distance between the provided Pixel and the Screen Buffer
*
* @param pix Pixel to compare to the screen buffer
* @param tolerance Value at which (or below) the difference is negligible
* @return BOOL true - close enough; false - different
*/
[[nodiscard]] BOOL Robot::isPixelSimilar(const Pixel& pix, unsigned short tolerance = 0.1) const {
return (abs_diff(getRed(pix.p), pix.r) + abs_diff(getGreen(pix.p), pix.g) + abs_diff(getBlue(pix.p), pix.b)) < 3 * tolerance;
}
/**
* @brief Determines if the provided Pixel matches the Screen Buffer
*
* @param pix Pixel to compare to the screen buffer
* @return BOOL true - equivalent; false - not equivalent
*/
[[nodiscard]] BOOL Robot::getPixelEquiv(const Pixel& pix) const {
return getRed(pix.p) == pix.r && getGreen(pix.p) == pix.g && getBlue(pix.p), pix.b;
}