-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblocks.js
More file actions
352 lines (330 loc) · 11.1 KB
/
blocks.js
File metadata and controls
352 lines (330 loc) · 11.1 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
Blockly.Blocks['programstart'] = {
init: function() {
this.appendDummyInput()
.appendField("Script Start");
this.appendStatementInput("program")
.setCheck("command");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
this.setDeletable(false);
this.command = false;
}
};
Blockly.Blocks['click'] = {
init: function() {
this.appendDummyInput()
.appendField("mouse click")
.appendField(new Blockly.FieldDropdown([["left","LEFT"], ["middle","MIDDLE"], ["right","RIGHT"]]), "BUTTON");
this.appendDummyInput()
.appendField("repeat:")
.appendField(new Blockly.FieldNumber(1), "DELAY");
this.appendDummyInput()
.appendField("delay:")
.appendField(new Blockly.FieldNumber(0), "REPEAT");
this.setInputsInline(true);
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Clicks the given button on the mouse \"repeat\" amount of times with \"delay\" milliseconds between each click.");
this.setHelpUrl("");
this.setMovable(true);
this.command = true;
}
};
Blockly.Blocks['movemouse'] = {
init: function() {
this.appendDummyInput()
.appendField("move mouse to x:")
.appendField(new Blockly.FieldNumber(0), "X");
this.appendDummyInput()
.appendField("y:")
.appendField(new Blockly.FieldNumber(0), "Y");
this.setInputsInline(true);
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Moves the mouse pointer to the given X and Y coordinates.");
this.setHelpUrl("");
this.command = true; }
};
Blockly.Blocks['restoremouse'] = {
init: function() {
this.appendDummyInput()
.appendField("restore mouse");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Places the mouse cursor back to its location before the last issued \"mouse move\" command.");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['mousemovepolar'] = {
init: function() {
this.appendDummyInput()
.appendField("move mouse polar; direction:")
.appendField(new Blockly.FieldAngle(90), "DIRECTION");
this.appendDummyInput()
.appendField("distance:")
.appendField(new Blockly.FieldNumber(0), "DISTANCE");
this.setInputsInline(true);
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Moves the mouse to the given polar coordinates on the screen.");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['withwindow'] = {
init: function() {
this.appendValueInput("WINDOW")
.setCheck("window")
.appendField("In Window:");
this.appendStatementInput("COMMANDS")
.setCheck("command");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(30);
this.setTooltip("All commands within this block will be executed within the specified window.");
this.setHelpUrl("");
}
};
Blockly.Blocks['getactivewindow'] = {
init: function() {
this.appendDummyInput()
.appendField("Active Window");
this.setOutput(true, "window");
this.setColour(120);
this.setTooltip("Returns the ID of the currently active window");
this.setHelpUrl("");
}
};
Blockly.Blocks['windowsearch'] = {
init: function() {
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("Find Window; must match:")
.appendField(new Blockly.FieldDropdown([["any","ANY"], ["all","ALL"]]), "MATCHING")
.appendField(", must be visible:")
.appendField(new Blockly.FieldCheckbox("FALSE"), "VISIBLE");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(new Blockly.FieldCheckbox("TRUE"), "USE_NAME")
.appendField("name: ")
.appendField(new Blockly.FieldTextInput(""), "NAME");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(new Blockly.FieldCheckbox("FALSE"), "USE_CLASS")
.appendField("class:")
.appendField(new Blockly.FieldTextInput(""), "CLASS");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(new Blockly.FieldCheckbox("FALSE"), "USE_CLASSNAME")
.appendField("classname:")
.appendField(new Blockly.FieldTextInput(""), "CLASSNAME");
this.setInputsInline(false);
this.setOutput(true, "window");
this.setColour(120);
this.setTooltip("Searches through current windows and returns the ID(s) of the window(s) that match the specified parameters.");
this.setHelpUrl("");
}
};
Blockly.Blocks['selectwindow'] = {
init: function() {
this.appendDummyInput()
.appendField("User Select Window");
this.setOutput(true, "window");
this.setColour(120);
this.setTooltip("Makes the user click on the window that will be acted upon. Returns the ID of the window the user clicked.");
this.setHelpUrl("");
}
};
Blockly.Blocks['resizewindow'] = {
init: function() {
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("Resize Window");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("width:")
.appendField(new Blockly.FieldNumber(100, 0), "WIDTH");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("height:")
.appendField(new Blockly.FieldNumber(100, 0), "HEIGHT");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("use hints:")
.appendField(new Blockly.FieldCheckbox("FALSE"), "USE_HINTS");
this.setInputsInline(false);
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['sync'] = {
init: function() {
this.appendDummyInput()
.appendField("Sync");
this.appendStatementInput("COMMANDS")
.setCheck("command");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(300);
this.setTooltip("Waits until the command is actually completed. This adds on the --sync parameter to the shell command");
this.setHelpUrl("");
}
};
Blockly.Blocks['clearmodifiers'] = {
init: function() {
this.appendDummyInput()
.appendField("Clear Modifiers");
this.appendStatementInput("COMMANDS")
.setCheck("command");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(40);
this.setTooltip("Sets the clear modifiers flag for the following commands.");
this.setHelpUrl("");
}
};
Blockly.Blocks['windowmove'] = {
init: function() {
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("Move Window");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("relative:")
.appendField(new Blockly.FieldCheckbox("TRUE"), "RELATIVE");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("x:")
.appendField(new Blockly.FieldNumber(0), "X");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("y:")
.appendField(new Blockly.FieldNumber(0), "Y");
this.setInputsInline(false);
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['windowfocus'] = {
init: function() {
this.appendDummyInput()
.appendField("Focus window");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Focuses the given window.");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['mousemoverelative'] = {
init: function() {
this.appendDummyInput()
.appendField("move mouse by, x:")
.appendField(new Blockly.FieldNumber(0, 0), "X")
.appendField(", y:")
.appendField(new Blockly.FieldNumber(0, 0), "Y");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Moves the mouse by X pixels and Y pixels.");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['key'] = {
init: function() {
this.appendDummyInput()
.appendField("key stroke:")
.appendField(new Blockly.FieldTextInput("A"), "KEY");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("delay:")
.appendField(new Blockly.FieldNumber(0, 0), "DELAY");
this.setInputsInline(false);
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['specialkey'] = {
init: function() {
this.appendDummyInput()
.appendField("keystroke:")
.appendField(new Blockly.FieldDropdown([["Ctrl","CTRL"], ["Alt","ALT"], ["Shift","SHIFT"], ["Super","SUPER"]]), "MODIFIER")
.appendField("+")
.appendField(new Blockly.FieldTextInput("A"), "KEY");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("delay:")
.appendField(new Blockly.FieldNumber(0, 0), "DELAY");
this.setInputsInline(false);
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['type'] = {
init: function() {
this.appendDummyInput()
.appendField("type in:")
.appendField(new Blockly.FieldTextInput("Hello World!"), "STRING");
this.appendDummyInput()
.setAlign(Blockly.ALIGN_RIGHT)
.appendField("delay:")
.appendField(new Blockly.FieldNumber(0, 0), "DELAY");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Sends a series of given keystrokes with \"delay\" milliseconds between each one.");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['sleep'] = {
init: function() {
this.appendDummyInput()
.appendField("sleep for")
.appendField(new Blockly.FieldNumber(0, 0), "TIME")
.appendField("seconds");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(240);
this.setTooltip("Sleeps/waits for the given amount of seconds.");
this.setHelpUrl("");
this.command = true;
}
};
Blockly.Blocks['execute'] = {
init: function() {
this.appendDummyInput()
.appendField("execute:")
.appendField(new Blockly.FieldTextInput("touch test.txt"), "VALUE");
this.setPreviousStatement(true, "command");
this.setNextStatement(true, "command");
this.setColour(230);
this.setTooltip("Executes the given command.");
this.setHelpUrl("");
this.command = true;
}
};