-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.comp
277 lines (178 loc) · 4.83 KB
/
test.comp
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
-- Test Case 1: Basic Mouse and Key Operations
PRINTLN "Test Case 1: Basic Mouse and Key Operations";
HOLD KEY SHIFT;
MOVE MOUSE TO (300, 400);
PRESS BUTTON LEFT;
WAIT 2s;
MOVE MOUSE TO (500, 600);
HOLD KEY SHIFT; -- Release SHIFT key
PRINT "\n\n\n\n";
-- Test Case 2: Window Movement and Typing
PRINTLN "Test Case 2: Window Movement and Typing";
OPEN APP "Notepad";
WAIT 3s;
MOVE WINDOW "Notepad" TO (100, 100);
TYPE "This is a test.";
PRESS KEY ENTER;
TYPE "Another line.";
PRINT "\n\n\n\n";
-- Test Case 3: Repeating Actions
PRINTLN "Test Case 3: Repeating Actions";
REPEAT 3 TIMES {
PRESS KEY SPACE;
WAIT 1s;
};
PRINT "\n\n\n\n";
-- Test Case 4: Conditional Logic
PRINTLN "Test Case 4: Conditional Logic";
IF WINDOW "Calculator" EXISTS THEN
FOCUS WINDOW "Calculator";
MOVE WINDOW "Calculator" TO (150, 150);
END IF;
PRINT "\n\n\n\n";
-- Test Case 5: Scrolling and Holding Keys
PRINTLN "Test Case 5: Scrolling and Holding Keys";
SCROLL MOUSE DOWN 5;
WAIT 1s;
HOLD KEY CTRL;
SCROLL MOUSE UP 3;
HOLD KEY CTRL; -- Release CTRL key
PRINT "\n\n\n\n";
-- Test Case 6: Opening, Closing, and Focusing Windows
PRINTLN "Test Case 6: Opening, Closing, and Focusing Windows";
OPEN APP "Calculator";
WAIT 2s;
FOCUS WINDOW "Calculator";
MOVE WINDOW "Calculator" TO (200, 200);
WAIT 1s;
CLOSE WINDOW "Calculator";
PRINT "\n\n\n\n";
-- Test Case 7: Typing a URL in a Browser
PRINTLN "Test Case 7: Typing a URL in a Browser";
OPEN APP "Browser";
WAIT 3s;
TYPE "https://example.com";
PRESS KEY ENTER;
PRINT "\n\n\n\n";
-- Test Case 8: Hold and Release Mouse Button
PRINTLN "Test Case 8: Hold and Release Mouse Button";
HOLD BUTTON LEFT;
MOVE MOUSE TO (100, 200);
MOVE MOUSE TO (400, 300);
HOLD BUTTON LEFT; -- Release LEFT button
PRINT "\n\n\n\n";
-- Test Case 9: Complex Sequence of Window Operations
PRINTLN "Test Case 9: Complex Sequence of Window Operations";
OPEN APP "Terminal";
WAIT 2s;
MOVE WINDOW "Terminal" TO (50, 50);
FOCUS WINDOW "Terminal";
TYPE "ping example.com";
PRESS KEY ENTER;
WAIT 5s;
CLOSE WINDOW "Terminal";
PRINT "\n\n\n\n";
-- Test Case 10: Nested Conditional Logic and Repeating Actions
PRINTLN "Test Case 10: Nested Conditional Logic and Repeating Actions";
IF WINDOW "Editor" EXISTS THEN
FOCUS WINDOW "Editor";
REPEAT 2 TIMES {
TYPE "Automated test.";
PRESS KEY ENTER;
};
END IF;
PRINT "\n\n\n\n";
-- Test Case 11: Nested Conditional Logic
PRINTLN "Test Case 11: Nested Conditional Logic";
IF WINDOW "Editor" EXISTS THEN
FOCUS WINDOW "Editor";
IF WINDOW "VS" EXISTS THEN {
TYPE "Automated test.";
PRESS KEY ENTER;
};
END IF;
PRINT "\n\n\n\n";
-- Test Case 12: Nested Repeating Actions
PRINTLN "Test Case 12: Nested Repeating Actions";
REPEAT 4 TIMES {
FOCUS WINDOW "Editor";
REPEAT 2 TIMES {
TYPE "Automated test.";
PRESS KEY ENTER;
};
};
PRINT "\n\n\n\n";
-- Function definition
PRINTLN "Function definition";
DEFFUN MoveAndWait(x, y, waitTime) {
MOVE MOUSE TO (x, y);
WAIT waitTime;
};
-- Variable declarations
PRINTLN "Variable declarations";
SET myX = 200;
SET myY = 300;
SET myWaitTime = 2s;
-- Function call using variables
PRINTLN "Function call using variables";
MoveAndWait(myX, myY, myWaitTime);
IF WINDOW "notepad" EXISTS THEN
MOVE MOUSE TO (myX, myY);
WAIT 1s;
END IF;
PRINT "\n\n\n\n";
-- Direct time values
PRINTLN "Direct time values";
WAIT 1.5h;
WAIT 30m;
WAIT 45s;
WAIT 500ms;
PRINT "\n\n\n\n";
-- Time variables
PRINTLN "Time variables";
SET longWait = 1.5h;
SET shortWait = 500ms;
WAIT longWait;
WAIT shortWait;
PRINT "\n\n\n\n";
-- In functions
PRINTLN "In functions";
DEFFUN WaitAndMove(waitTime, x, y) {
WAIT waitTime;
MOVE MOUSE TO (x, y);
};
DEFFUN WaitAndMove(waitTime, x, y) {
WAIT waitTime;
MOVE MOUSE TO (x, y);
};
WaitAndMove(10s, 900, 500);
PRINT "\n\n\n\n";
-- Function to get user info and print it
DEFFUN getUserInfo() {
INPUT "Enter your name: " TO userName;
INPUT "Enter your age: " TO userAge;
PRINTLN "Hello, " + userName + "! You are " + userAge + " years old.";
};
-- Variables for demonstration
SET message = "Welcome to CommandPro!";
PRINTLN message;
-- Function call to get user info
getUserInfo();
-- Example of type-specific input
PRINTLN "Example of type-specific input";
INPUT "Enter a number to multiply by 2: " TO num AS INT;
SET result = num * 2;
PRINTLN "Result: " + result;
-- Try different types
INPUT "Enter a floating point number: " TO float_num AS FLOAT;
PRINTLN "Float value: " + float_num;
INPUT "Enter your name: " TO name AS STR;
PRINTLN "Hello " + name;
-- Basic arithmetic with typed inputs
INPUT "Enter first number: " TO a AS INT;
INPUT "Enter second number: " TO b AS INT;
SET sum = a + b;
PRINTLN "Sum is: " + sum;
PRINT "\n\n\n\n";
-- Demonstrate mixing variables and strings
PRINTLN "Hello " + name + "! The count is " + count;