au3 0.0.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Binary file
Binary file
@@ -0,0 +1,14 @@
1
+ #Encoding: Windows-1252
2
+ =begin
3
+ This file is part of au3.
4
+ Copyright � 2009 Marvin G�lker
5
+
6
+ au3 is published under the same terms as Ruby.
7
+ See http://www.ruby-lang.org/en/LICENSE.txt
8
+ =end
9
+ require "mkmf"
10
+ extension_name = "au3"
11
+ $LOCAL_LIBS += File.file?("libautoitx3.a") ? "libautoitx3.a" : "AutoItX3.lib"
12
+
13
+ dir_config(extension_name)
14
+ create_makefile(extension_name)
@@ -0,0 +1,628 @@
1
+ /*
2
+ *This file is part of au3.
3
+ *Copyright � 2009 Marvin G�lker
4
+ *
5
+ *au3 is published under the same terms as Ruby.
6
+ *See http://www.ruby-lang.org/en/LICENSE.txt
7
+ *
8
+ *=control.c
9
+ *All the functions to work with widgets, controls, or however childwindows
10
+ *are named.
11
+ */
12
+
13
+ void raise_unfound_ctl(VALUE title, VALUE c_id)
14
+ {
15
+ rb_raise(Au3Error, "The control '%s' was not found in the window '%s' (or the window was not found)!", StringValuePtr(c_id), StringValuePtr(title));
16
+ }
17
+ //------------------------------------------------------------------------------------------------------------------------------------------
18
+ VALUE method_init_control(VALUE self, VALUE title, VALUE text, VALUE c_id)
19
+ {
20
+ rb_ivar_set(self, rb_intern("@title"), title);
21
+ rb_ivar_set(self, rb_intern("@text"), text);
22
+ rb_ivar_set(self, rb_intern("@c_id"), rb_funcall(c_id, rb_intern("to_s"), 0)); //To allow integers to be used as IDs
23
+ return self;
24
+ }
25
+ //------------------------------------------------------------------------------------------------------------------------------------------
26
+ VALUE method_click_ctl(int argc, VALUE argv[], VALUE self)
27
+ {
28
+ LPCWSTR button = to_wchar_t("Primary");
29
+ long clicks = 1;
30
+ long x = AU3_INTDEFAULT;
31
+ long y = AU3_INTDEFAULT;
32
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
33
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
34
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
35
+
36
+ check_for_arg_error(argc, 0, 4);
37
+
38
+ if (argc >= 1)
39
+ button = rstr_to_wstr(argv[0]);
40
+ if (argc >= 2)
41
+ clicks = NUM2LONG(argv[1]);
42
+ if (argc >= 3)
43
+ x = NUM2LONG(argv[2]);
44
+ if (argc >= 4)
45
+ y = NUM2LONG(argv[3]);
46
+
47
+ if (AU3_ControlClick(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), button, clicks, x, y))
48
+ return Qtrue;
49
+ else
50
+ rb_raise(Au3Error, "Could not click control '%s' in '%s' for some reason!", StringValuePtr(c_id), StringValuePtr(title));
51
+ }
52
+ //------------------------------------------------------------------------------------------------------------------------------------------
53
+ VALUE method_disable_ctl(VALUE self)
54
+ {
55
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
56
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
57
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
58
+
59
+ if ( AU3_ControlDisable(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id)) )
60
+ return Qtrue;
61
+ else
62
+ rb_raise(Au3Error, "Could not disable control '%s' in '%s' for some reason!", StringValuePtr(c_id), StringValuePtr(title));
63
+ }
64
+ //------------------------------------------------------------------------------------------------------------------------------------------
65
+ VALUE method_enable_ctl(VALUE self)
66
+ {
67
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
68
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
69
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
70
+
71
+ if ( AU3_ControlEnable(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id)) )
72
+ return Qtrue;
73
+ else
74
+ rb_raise(Au3Error, "Could not enable control '%s' in '%s' for some reason!", StringValuePtr(c_id), StringValuePtr(title));
75
+ }
76
+ //------------------------------------------------------------------------------------------------------------------------------------------
77
+ VALUE method_focus_ctl(VALUE self)
78
+ {
79
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
80
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
81
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
82
+
83
+ if ( AU3_ControlFocus(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id)) )
84
+ return Qtrue;
85
+ else
86
+ rb_raise(Au3Error, "Could not focus control '%s' in '%s' for some reason!", StringValuePtr(c_id), StringValuePtr(title));
87
+ }
88
+ //------------------------------------------------------------------------------------------------------------------------------------------
89
+ VALUE method_handle_ctl(VALUE self)
90
+ {
91
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
92
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
93
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
94
+ wchar_t buffer[10000];
95
+
96
+ AU3_ControlGetHandle(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), buffer, 10000);
97
+
98
+ if (AU3_error() == 1)
99
+ raise_unfound_ctl(title, c_id);
100
+ return wstr_to_rstr(buffer);
101
+ }
102
+ //------------------------------------------------------------------------------------------------------------------------------------------
103
+ VALUE method_rect_ctl(VALUE self)
104
+ {
105
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
106
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
107
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
108
+ long x;
109
+ long y;
110
+ long width;
111
+ long height;
112
+
113
+ x = AU3_ControlGetPosX(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id));
114
+ y = AU3_ControlGetPosY(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id));
115
+ width = AU3_ControlGetPosWidth(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id));
116
+ height = AU3_ControlGetPosHeight(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id));
117
+
118
+ if (AU3_error() == 1)
119
+ raise_unfound_ctl(title, c_id);
120
+ return rb_ary_new3(4, LONG2NUM(x), LONG2NUM(y), LONG2NUM(width), LONG2NUM(height));
121
+ }
122
+ //------------------------------------------------------------------------------------------------------------------------------------------
123
+ VALUE method_text_ctl(VALUE self)
124
+ {
125
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
126
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
127
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
128
+ wchar_t buffer[10000];
129
+
130
+ AU3_ControlGetText(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), buffer, 10000);
131
+
132
+ return wstr_to_rstr(buffer);
133
+ }
134
+ //------------------------------------------------------------------------------------------------------------------------------------------
135
+ VALUE method_hide_ctl(VALUE self)
136
+ {
137
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
138
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
139
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
140
+
141
+ if (!AU3_ControlHide(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id)));
142
+ raise_unfound_ctl(title, c_id);
143
+
144
+ return Qtrue;
145
+ }
146
+ //------------------------------------------------------------------------------------------------------------------------------------------
147
+ VALUE method_move_ctl(int argc, VALUE argv[], VALUE self)
148
+ {
149
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
150
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
151
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
152
+ long width = -1;
153
+ long height = -1;
154
+
155
+ if (argc >= 3)
156
+ width = NUM2LONG(argv[2]);
157
+ if (argc >= 4)
158
+ height = NUM2LONG(argv[3]);
159
+
160
+ check_for_arg_error(argc, 2, 4);
161
+
162
+ if ( !AU3_ControlMove(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), NUM2LONG(argv[0]), NUM2LONG(argv[1]), width, height) )
163
+ raise_unfound_ctl(title, c_id);
164
+
165
+ return Qtrue;
166
+ }
167
+ //------------------------------------------------------------------------------------------------------------------------------------------
168
+ VALUE method_send_keys_ctl(int argc, VALUE argv[], VALUE self)
169
+ {
170
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
171
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
172
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
173
+ int flag = 0;
174
+
175
+ check_for_arg_error(argc, 0, 1);
176
+
177
+ if (argc == 1)
178
+ flag = FIX2INT(argv[0]);
179
+
180
+ if ( !AU3_ControlSend(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), rstr_to_wstr(argv[0]), flag) )
181
+ raise_unfound(title, c_id);
182
+ return Qtrue;
183
+ }
184
+ //------------------------------------------------------------------------------------------------------------------------------------------
185
+ VALUE method_set_text_ctl(VALUE self, VALUE str)
186
+ {
187
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
188
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
189
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
190
+
191
+ if ( !AU3_ControlSetText(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), rstr_to_wstr(str)) )
192
+ raise_unfound_ctl(title, c_id);
193
+ return text;
194
+ }
195
+ //------------------------------------------------------------------------------------------------------------------------------------------
196
+ VALUE method_show_ctl(VALUE self)
197
+ {
198
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
199
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
200
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
201
+
202
+ if ( !AU3_ControlShow(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id)) )
203
+ raise_unfound_ctl(title, c_id);
204
+ return Qtrue;
205
+ }
206
+ //------------------------------------------------------------------------------------------------------------------------------------------
207
+ VALUE method_send_command_to_control(int argc, VALUE argv[], VALUE self)
208
+ {
209
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
210
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
211
+ VALUE c_id = rb_funcall(rb_ivar_get(self, rb_intern("@c_id")), rb_intern("to_s"), 0);
212
+ LPCWSTR option = to_wchar_t("");
213
+ wchar_t buffer[10000];
214
+
215
+ check_for_arg_error(argc, 1, 2);
216
+
217
+ if (argc == 2)
218
+ option = rstr_to_wstr(rb_funcall(argv[1], rb_intern("to_s"), 0));
219
+
220
+ AU3_ControlCommand(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), rstr_to_wstr(argv[0]), option, buffer, 10000);
221
+
222
+ if (AU3_error() == 1)
223
+ rb_raise(Au3Error, "Unknown error occured when sending '%s' to '%s' in '%s'! Maybe an invalid window?", StringValuePtr(argv[0]), StringValuePtr(c_id), StringValuePtr(title));
224
+
225
+ return wstr_to_rstr(buffer);
226
+ }
227
+ //------------------------------------------------------------------------------------------------------------------------------------------
228
+ VALUE method_is_visible_ctl(VALUE self)
229
+ {
230
+ VALUE result;
231
+ result = rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("IsVisible"));
232
+ result = rb_funcall(result, rb_intern("=="), 1, rb_str_new2("1"));
233
+ return result;
234
+ }
235
+ //------------------------------------------------------------------------------------------------------------------------------------------
236
+ VALUE method_is_enabled_ctl(VALUE self)
237
+ {
238
+ VALUE result;
239
+ result = rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("IsEnabled"));
240
+ result = rb_funcall(result, rb_intern("=="), 1, rb_str_new2("1"));
241
+ return result;
242
+ }
243
+ /*==================================================
244
+ ListBox methods
245
+ ===================================================*/
246
+ VALUE method_add_string_ib(VALUE self, VALUE string)
247
+ {
248
+ rb_funcall(self, rb_intern("send_command_to_control"), 2, rb_str_new2("AddString"), string);
249
+ return string;
250
+ }
251
+ //------------------------------------------------------------------------------------------------------------------------------------------
252
+ VALUE method_add_string_self_ib(VALUE self, VALUE string)
253
+ {
254
+ method_add_string_ib(self, string);
255
+ return self;
256
+ }
257
+ //------------------------------------------------------------------------------------------------------------------------------------------
258
+ VALUE method_delete_string_ib(VALUE self, VALUE item)
259
+ {
260
+ rb_funcall(self, rb_intern("send_command_to_control"), 2, rb_str_new2("DelString"), rb_funcall(item, rb_intern("to_s"), 0));
261
+ return item;
262
+ }
263
+ //------------------------------------------------------------------------------------------------------------------------------------------
264
+ VALUE method_find_string_ib(VALUE self, VALUE search)
265
+ {
266
+ VALUE result;
267
+ result = rb_funcall(self, rb_intern("send_command_to_control"), 2, rb_str_new2("FindString"), search);
268
+ return rb_funcall(result, rb_intern("to_i"), 0);
269
+ }
270
+ //------------------------------------------------------------------------------------------------------------------------------------------
271
+ VALUE method_set_current_selection_ib(VALUE self, VALUE item)
272
+ {
273
+ rb_funcall(self, rb_intern("send_command_to_control"), 2, rb_str_new2("SetCurrentSelection"), rb_funcall(item, rb_intern("to_i"), 0));
274
+ return item;
275
+ }
276
+ //------------------------------------------------------------------------------------------------------------------------------------------
277
+ VALUE method_select_string_ib(VALUE self, VALUE string)
278
+ {
279
+ rb_funcall(self, rb_intern("send_command_to_control"), 2, rb_str_new2("SelectString"), string);
280
+ return string;
281
+ }
282
+ //------------------------------------------------------------------------------------------------------------------------------------------
283
+ VALUE method_current_selection_ib(VALUE self)
284
+ {
285
+ VALUE result;
286
+ result = rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("GetCurrentSelection"));
287
+ return result;
288
+ }
289
+ /*==================================================
290
+ ComboBox methods
291
+ ===================================================*/
292
+ VALUE method_drop_cb(VALUE self)
293
+ {
294
+ rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("ShowDropDown"));
295
+ return Qtrue;
296
+ }
297
+ //------------------------------------------------------------------------------------------------------------------------------------------
298
+ VALUE method_undrop_cb(VALUE self)
299
+ {
300
+ rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("HideDropDown"));
301
+ return Qtrue;
302
+ }
303
+ /*==================================================
304
+ Button methods (check, radio and normal)
305
+ ===================================================*/
306
+ VALUE method_is_checked_bt(VALUE self)
307
+ {
308
+ VALUE result;
309
+ result = rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("IsChecked"));
310
+ result = rb_funcall(result, rb_intern("=="), 1, rb_str_new2("1"));
311
+ return result;
312
+ }
313
+ //------------------------------------------------------------------------------------------------------------------------------------------
314
+ VALUE method_check_bt(VALUE self)
315
+ {
316
+ rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("Check"));
317
+ return Qtrue;
318
+ }
319
+ //------------------------------------------------------------------------------------------------------------------------------------------
320
+ VALUE method_uncheck_bt(VALUE self)
321
+ {
322
+ rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("UnCheck"));
323
+ return Qtrue;
324
+ }
325
+ /*==================================================
326
+ Edit methods
327
+ ===================================================*/
328
+ VALUE method_caret_pos_ed(VALUE self)
329
+ {
330
+ VALUE result = rb_ary_new();
331
+ VALUE res;
332
+ res = result, rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("GetCurrentLine"));
333
+ rb_ary_push(result, rb_funcall(res, rb_intern("to_i"), 0));
334
+ res = result, rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("GetCurrentCol"));
335
+ rb_ary_push(result, rb_funcall(res, rb_intern("to_i"), 0));
336
+ return result;
337
+ }
338
+ //------------------------------------------------------------------------------------------------------------------------------------------
339
+ VALUE method_lines_ed(VALUE self)
340
+ {
341
+ VALUE result;
342
+ result = rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("GetLineCount"));
343
+ return rb_funcall(result, rb_intern("to_i"), 0);
344
+ }
345
+ //------------------------------------------------------------------------------------------------------------------------------------------
346
+ VALUE method_selected_text_ed(VALUE self)
347
+ {
348
+ return rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("GetSelected"));
349
+ }
350
+ //------------------------------------------------------------------------------------------------------------------------------------------
351
+ VALUE method_paste_ed(VALUE self, VALUE string)
352
+ {
353
+ rb_funcall(self, rb_intern("send_command_to_control"), 2, rb_str_new2("EditPaste"), string);
354
+ return string;
355
+ }
356
+ /*==================================================
357
+ TabBook methods
358
+ ===================================================*/
359
+ VALUE method_current_tab(VALUE self)
360
+ {
361
+ VALUE result;
362
+ result = rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("CurrentTab"));
363
+ return rb_funcall(result, rb_intern("to_i"), 0);
364
+ }
365
+ //------------------------------------------------------------------------------------------------------------------------------------------
366
+ VALUE method_right_tab(VALUE self)
367
+ {
368
+ rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("TabRight"));
369
+ return method_current_tab(self);
370
+ }
371
+ //------------------------------------------------------------------------------------------------------------------------------------------
372
+ VALUE method_left_tab(VALUE self)
373
+ {
374
+ rb_funcall(self, rb_intern("send_command_to_control"), 1, rb_str_new2("TabLeft"));
375
+ return method_current_tab(self);
376
+ }
377
+ /*==================================================
378
+ ListView methods
379
+ ===================================================*/
380
+ VALUE method_send_command_to_list_view(int argc, VALUE argv[], VALUE self)
381
+ {
382
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
383
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
384
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
385
+ LPCWSTR option1 = to_wchar_t("");
386
+ LPCWSTR option2 = to_wchar_t("");
387
+ wchar_t buffer[10000];
388
+
389
+ check_for_arg_error(argc, 1, 3);
390
+
391
+ if (argc >= 2)
392
+ option1 = rstr_to_wstr(argv[1]);
393
+ if (argc == 3)
394
+ option2 = rstr_to_wstr(argv[2]);
395
+
396
+ AU3_ControlListView(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), rstr_to_wstr(argv[0]), option1, option2, buffer, 10000);
397
+
398
+ if (AU3_error() == 1)
399
+ rb_raise(Au3Error, "Unknown error occured when sending '%s' to '%s' in '%s'! Maybe an invalid window?", StringValuePtr(argv[0]), StringValuePtr(c_id), StringValuePtr(title));
400
+
401
+ return wstr_to_rstr(buffer);
402
+ }
403
+ //------------------------------------------------------------------------------------------------------------------------------------------
404
+ VALUE method_deselect_lv(int argc, VALUE argv[], VALUE self)
405
+ {
406
+ VALUE option2 = rb_str_new2("");
407
+
408
+ check_for_arg_error(argc, 1, 2);
409
+
410
+ if (argc == 2)
411
+ option2 = rb_funcall(argv[1], rb_intern("to_s"), 0);
412
+
413
+ rb_funcall(self, rb_intern("send_command_to_list_view"), 3, rb_str_new2("DeSelect"), rb_funcall(argv[0], rb_intern("to_s"), 0), option2);
414
+ return Qnil;
415
+ }
416
+ //------------------------------------------------------------------------------------------------------------------------------------------
417
+ VALUE method_find_lv(int argc, VALUE argv[], VALUE self)
418
+ {
419
+ VALUE option2 = rb_str_new2("");
420
+ long result;
421
+
422
+ check_for_arg_error(argc, 1, 2);
423
+
424
+ if (argc == 2)
425
+ option2 = argv[1];
426
+
427
+ result = NUM2LONG(rb_funcall(rb_funcall(self, rb_intern("send_command_to_list_view"), 3, rb_str_new2("FindItem"), argv[0], option2), rb_intern("to_i"), 0));
428
+
429
+ if (result < 0)
430
+ return Qfalse;
431
+ else
432
+ return result;
433
+ }
434
+ //------------------------------------------------------------------------------------------------------------------------------------------
435
+ VALUE method_item_count_lv(VALUE self)
436
+ {
437
+ return rb_funcall(rb_funcall(self, rb_intern("send_command_to_list_view"), 1, rb_str_new2("GetItemCount")), rb_intern("to_i"), 0);
438
+ }
439
+ //------------------------------------------------------------------------------------------------------------------------------------------
440
+ VALUE method_selected_lv(VALUE self)
441
+ {
442
+ VALUE result;
443
+ int ary_len;
444
+ int i;
445
+
446
+ result = rb_funcall(self, rb_intern("send_command_to_list_view"), 2, rb_str_new2("GetSelected"), 1);
447
+ result = rb_funcall(result, rb_intern("split"), 1, rb_str_new2("|"));
448
+ ary_len = RARRAY_LEN(result);
449
+
450
+ for (i=0; i < ary_len; i++)
451
+ rb_funcall(result, rb_intern("[]="), 2, INT2NUM(i), rb_funcall(rb_funcall(result, rb_intern("[]"), 1, INT2NUM(i)), rb_intern("to_i"), 0));
452
+
453
+ return result;
454
+ }
455
+ //------------------------------------------------------------------------------------------------------------------------------------------
456
+ VALUE method_num_selected_lv(VALUE self)
457
+ {
458
+ return rb_funcall(rb_funcall(self, rb_intern("send_command_to_list_view"), 1, rb_str_new2("GetSelectedCount")), rb_intern("to_i"), 0);
459
+ }
460
+ //------------------------------------------------------------------------------------------------------------------------------------------
461
+ VALUE method_num_subitems_lv(VALUE self)
462
+ {
463
+ return rb_funcall(rb_funcall(self, rb_intern("send_command_to_list_view"), 1, rb_str_new2("GetSubItemCount")), rb_intern("to_i"), 0);
464
+ }
465
+ //------------------------------------------------------------------------------------------------------------------------------------------
466
+ VALUE method_text_at_lv(int argc, VALUE argv[], VALUE self)
467
+ {
468
+ VALUE subitem = rb_str_new2("");
469
+ check_for_arg_error(argc, 1, 2);
470
+
471
+ if (argc == 2)
472
+ subitem = rb_funcall(argv[1], rb_intern("to_s"), 0);
473
+
474
+ return rb_funcall(self, rb_intern("send_command_to_list_view"), 3, rb_str_new2("GetText"), rb_funcall(argv[0], rb_intern("to_s"), 0), subitem);
475
+ }
476
+ //------------------------------------------------------------------------------------------------------------------------------------------
477
+ VALUE method_is_selected_lv(VALUE self, VALUE item)
478
+ {
479
+ int result;
480
+ result = NUM2INT(rb_funcall(self, rb_intern("send_command_to_list_view"), 2, rb_str_new2("IsSelected"), rb_funcall(item, rb_intern("to_s"), 0)));
481
+
482
+ if (result)
483
+ return Qtrue;
484
+ else
485
+ return Qfalse;
486
+ }
487
+ //------------------------------------------------------------------------------------------------------------------------------------------
488
+ VALUE method_select_lv(int argc, VALUE argv[], VALUE self)
489
+ {
490
+ VALUE option2 = rb_str_new2("");
491
+
492
+ check_for_arg_error(argc, 1, 2);
493
+
494
+ if (argc == 2)
495
+ option2 = rb_funcall(argv[1], rb_intern("to_s"), 0);
496
+
497
+ rb_funcall(self, rb_intern("send_command_to_list_view"), 3, rb_str_new2("Select"), rb_funcall(argv[0], rb_intern("to_s"), 0), option2);
498
+ return Qnil;
499
+ }
500
+ //------------------------------------------------------------------------------------------------------------------------------------------
501
+ VALUE method_select_all_lv(VALUE self)
502
+ {
503
+ rb_funcall(self, rb_intern("send_command_to_list_view"), 1, rb_str_new2("SelectAll"));
504
+ return Qnil;
505
+ }
506
+ //------------------------------------------------------------------------------------------------------------------------------------------
507
+ VALUE method_clear_selection_lv(VALUE self)
508
+ {
509
+ rb_funcall(self, rb_intern("send_command_to_list_view"), 1, rb_str_new2("SelectClear"));
510
+ return Qnil;
511
+ }
512
+ //------------------------------------------------------------------------------------------------------------------------------------------
513
+ VALUE method_invert_selection_lv(VALUE self)
514
+ {
515
+ rb_funcall(self, rb_intern("send_command_to_list_view"), 1, rb_str_new2("SelectInvert"));
516
+ return Qnil;
517
+ }
518
+ //------------------------------------------------------------------------------------------------------------------------------------------
519
+ VALUE method_change_view_lv(VALUE self, VALUE view)
520
+ {
521
+ rb_funcall(self, rb_intern("send_command_to_list_view"), 2, rb_str_new2("ViewChange"), view);
522
+ return view;
523
+ }
524
+ /*==================================================
525
+ TreeView methods
526
+ ===================================================*/
527
+ VALUE method_send_command_to_tree_view(int argc, VALUE argv[], VALUE self)
528
+ {
529
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
530
+ VALUE text = rb_ivar_get(self, rb_intern("@text"));
531
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
532
+ LPCWSTR option1 = to_wchar_t("");
533
+ LPCWSTR option2 = to_wchar_t("");
534
+ wchar_t buffer[10000];
535
+
536
+ check_for_arg_error(argc, 1, 3);
537
+
538
+ if (argc >= 2)
539
+ option1 = rstr_to_wstr(argv[1]);
540
+ if (argc == 3)
541
+ option2 = rstr_to_wstr(argv[2]);
542
+
543
+ AU3_ControlTreeView(rstr_to_wstr(title), rstr_to_wstr(text), rstr_to_wstr(c_id), rstr_to_wstr(argv[0]), option1, option2, buffer, 10000);
544
+
545
+ if (AU3_error() == 1)
546
+ rb_raise(Au3Error, "Unknown error occured when sending '%s' to '%s' in '%s'! Maybe an invalid window?", StringValuePtr(argv[0]), StringValuePtr(c_id), StringValuePtr(title));
547
+
548
+ return wstr_to_rstr(buffer);
549
+ }
550
+ //------------------------------------------------------------------------------------------------------------------------------------------
551
+ VALUE method_check_tv(VALUE self, VALUE item)
552
+ {
553
+ rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("Check"), rb_funcall(item, rb_intern("to_s"), 0));
554
+ return Qnil;
555
+ }
556
+ //------------------------------------------------------------------------------------------------------------------------------------------
557
+ VALUE method_collapse_tv(VALUE self, VALUE item)
558
+ {
559
+ rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("Collapse"), rb_funcall(item, rb_intern("to_s"), 0));
560
+ return Qnil;
561
+ }
562
+ //------------------------------------------------------------------------------------------------------------------------------------------
563
+ VALUE method_exists_tv(VALUE self, VALUE item)
564
+ {
565
+ VALUE result;
566
+ result = rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("Exists"), rb_funcall(item, rb_intern("to_s"), 0));
567
+ if (NUM2INT(result))
568
+ return Qtrue;
569
+ else
570
+ return Qfalse;
571
+ }
572
+ //------------------------------------------------------------------------------------------------------------------------------------------
573
+ VALUE method_expand_tv(VALUE self, VALUE item)
574
+ {
575
+ rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("Expand"), rb_funcall(item, rb_intern("to_s"), 0));
576
+ return Qnil;
577
+ }
578
+ //------------------------------------------------------------------------------------------------------------------------------------------
579
+ VALUE method_num_subitems_tv(VALUE self, VALUE item)
580
+ {
581
+ return rb_funcall(rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("GetItemCount"), rb_funcall(item, rb_intern("to_s"), 0)), rb_intern("to_i"), 0);
582
+ }
583
+ //------------------------------------------------------------------------------------------------------------------------------------------
584
+ VALUE method_selected_tv(int argc, VALUE argv[], VALUE self)
585
+ {
586
+ VALUE use_index = Qfalse;
587
+ check_for_arg_error(argc, 0, 1);
588
+
589
+ if (argc == 1)
590
+ use_index = argv[1];
591
+
592
+ if (TYPE(use_index) != T_FALSE && TYPE(use_index) != T_NIL)
593
+ return rb_funcall(rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("GetSelected"), INT2FIX(1)), rb_intern("to_i"), 0);
594
+ else
595
+ return rb_funcall(self, rb_intern("send_command_to_tree_view"), 1, rb_str_new2("GetSelected"));
596
+ }
597
+ //------------------------------------------------------------------------------------------------------------------------------------------
598
+ VALUE method_text_at_tv(VALUE self, VALUE item)
599
+ {
600
+ return rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("GetText"), rb_funcall(item, rb_intern("to_s"), 0));
601
+ }
602
+ //------------------------------------------------------------------------------------------------------------------------------------------
603
+ VALUE method_is_checked_tv(VALUE self, VALUE item)
604
+ {
605
+ int result;
606
+ VALUE title = rb_ivar_get(self, rb_intern("@title"));
607
+ VALUE c_id = rb_ivar_get(self, rb_intern("@c_id"));
608
+
609
+ result = NUM2INT(rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("IsChecked"), rb_funcall(item, rb_intern("to_s"), 0)));
610
+
611
+ if (result == -1)
612
+ rb_raise(Au3Error, "'%s' in '%s' is not a checkbox!", StringValuePtr(c_id), StringValuePtr(title));
613
+ else if (result == 0)
614
+ return Qfalse;
615
+ return Qtrue;
616
+ }
617
+ //------------------------------------------------------------------------------------------------------------------------------------------
618
+ VALUE method_select_tv(VALUE self, VALUE item)
619
+ {
620
+ rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("Select"), rb_funcall(item, rb_intern("to_s"), 0));
621
+ return Qnil;
622
+ }
623
+ //------------------------------------------------------------------------------------------------------------------------------------------
624
+ VALUE method_uncheck_tv(VALUE self, VALUE item)
625
+ {
626
+ rb_funcall(self, rb_intern("send_command_to_tree_view"), 2, rb_str_new2("Uncheck"), rb_funcall(item, rb_intern("to_s"), 0));
627
+ return Qnil;
628
+ }