au3 0.0.1-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/README.rdoc +84 -0
- data/ext/au3.c +2225 -0
- data/ext/au3.so +0 -0
- data/ext/extconf.rb +14 -0
- data/ext/parts/control.c +628 -0
- data/ext/parts/filedir.c +121 -0
- data/ext/parts/graphic.c +51 -0
- data/ext/parts/keyboard.c +29 -0
- data/ext/parts/misc.c +107 -0
- data/ext/parts/mouse.c +130 -0
- data/ext/parts/process.c +143 -0
- data/ext/parts/utils.c +53 -0
- data/ext/parts/wconv.c +40 -0
- data/ext/parts/window.c +497 -0
- data/test/test_clipboard.rb +19 -0
- data/test/test_ini.rb +48 -0
- data/test/test_keyboard.rb +61 -0
- data/test/test_mouse.rb +43 -0
- data/test/test_process.rb +50 -0
- data/test/test_tray.rb +29 -0
- data/test/test_window.rb +104 -0
- metadata +82 -0
data/ext/parts/filedir.c
ADDED
@@ -0,0 +1,121 @@
|
|
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
|
+
*=filedir.c
|
9
|
+
*Methods that deal with file and directory management.
|
10
|
+
*/
|
11
|
+
|
12
|
+
VALUE method_add_drive_map(int argc, VALUE argv[], VALUE self)
|
13
|
+
{
|
14
|
+
wchar_t username[1000];
|
15
|
+
wchar_t password[1000];
|
16
|
+
int flags = 0;
|
17
|
+
wchar_t buffer[1000];
|
18
|
+
char err[60];
|
19
|
+
|
20
|
+
//Argumentanzahl pr�fen
|
21
|
+
check_for_arg_error(argc, 2, 5);
|
22
|
+
|
23
|
+
//Optionale Argumente zuweisen
|
24
|
+
if (argc >= 3)
|
25
|
+
flags = NUM2INT(argv[2]);
|
26
|
+
if (argc >= 4)
|
27
|
+
wcscpy(username, rstr_to_wstr(argv[3]));
|
28
|
+
if (argc >= 5)
|
29
|
+
wcscpy(password, rstr_to_wstr(argv[4]));
|
30
|
+
|
31
|
+
//AutoItX-Aufruf durchf�hren
|
32
|
+
AU3_DriveMapAdd(rstr_to_wstr(argv[0]), rstr_to_wstr(argv[1]), flags, username, password, buffer, 1000);
|
33
|
+
|
34
|
+
//Auf Fehler pr�fen
|
35
|
+
switch (AU3_error())
|
36
|
+
{
|
37
|
+
case 1:
|
38
|
+
{
|
39
|
+
rb_raise(Au3Error, "Unknown error occured while mapping network drive!");
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
case 2:
|
43
|
+
{
|
44
|
+
rb_raise(Au3Error, "Access denied!");
|
45
|
+
break;
|
46
|
+
}
|
47
|
+
case 3:
|
48
|
+
{
|
49
|
+
sprintf(err, "Device '%s' is already assigned!", StringValuePtr(argv[0]));
|
50
|
+
rb_raise(Au3Error, err);
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
case 4:
|
54
|
+
{
|
55
|
+
sprintf(err, "Invalid device name '%s'!", StringValuePtr(argv[0]));
|
56
|
+
rb_raise(Au3Error, err);
|
57
|
+
break;
|
58
|
+
}
|
59
|
+
case 5:
|
60
|
+
{
|
61
|
+
sprintf(err, "Invalid remote share '%s'!", StringValuePtr(argv[1]));
|
62
|
+
rb_raise(Au3Error, err);
|
63
|
+
break;
|
64
|
+
}
|
65
|
+
case 6:
|
66
|
+
{
|
67
|
+
rb_raise(Au3Error, "The password is incorrect!");
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
//Return returned string
|
73
|
+
return wstr_to_rstr(buffer);
|
74
|
+
}
|
75
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
76
|
+
VALUE method_delete_drive_map(VALUE self, VALUE device)
|
77
|
+
{
|
78
|
+
if (AU3_DriveMapDel(rstr_to_wstr(device)))
|
79
|
+
return Qtrue;
|
80
|
+
else
|
81
|
+
return Qfalse;
|
82
|
+
}
|
83
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
84
|
+
VALUE method_get_drive_map(VALUE self, VALUE device)
|
85
|
+
{
|
86
|
+
wchar_t buffer[1000];
|
87
|
+
char err[100];
|
88
|
+
AU3_DriveMapGet(rstr_to_wstr(device), buffer, 1000);
|
89
|
+
|
90
|
+
if (AU3_error() == 1)
|
91
|
+
{
|
92
|
+
sprintf(err, "Failed to retrieve information about device '%s'!", StringValuePtr(device));
|
93
|
+
rb_raise(Au3Error, err);
|
94
|
+
}
|
95
|
+
|
96
|
+
return wstr_to_rstr(buffer);
|
97
|
+
}
|
98
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
99
|
+
VALUE method_delete_ini_entry(VALUE self, VALUE filename, VALUE section, VALUE key)
|
100
|
+
{
|
101
|
+
if (AU3_IniDelete(rstr_to_wstr(filename), rstr_to_wstr(section), rstr_to_wstr(key)))
|
102
|
+
return Qtrue;
|
103
|
+
else
|
104
|
+
return Qfalse;
|
105
|
+
}
|
106
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
107
|
+
VALUE method_read_ini_entry(VALUE self, VALUE filename, VALUE section, VALUE key, VALUE def)
|
108
|
+
{
|
109
|
+
wchar_t buffer[10000];
|
110
|
+
AU3_IniRead(rstr_to_wstr(filename), rstr_to_wstr(section), rstr_to_wstr(key), rstr_to_wstr(def), buffer, 10000);
|
111
|
+
return wstr_to_rstr(buffer);
|
112
|
+
}
|
113
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
114
|
+
VALUE method_write_ini_entry(VALUE self, VALUE filename, VALUE section, VALUE key, VALUE value)
|
115
|
+
{
|
116
|
+
if (AU3_IniWrite(rstr_to_wstr(filename), rstr_to_wstr(section), rstr_to_wstr(key), rstr_to_wstr(value)))
|
117
|
+
return value;
|
118
|
+
else
|
119
|
+
rb_raise(Au3Error, "Cannot open file for write access!");
|
120
|
+
return Qfalse;
|
121
|
+
}
|
data/ext/parts/graphic.c
ADDED
@@ -0,0 +1,51 @@
|
|
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
|
+
*=graphic.c
|
9
|
+
*This file contains graphical related methods.
|
10
|
+
*/
|
11
|
+
|
12
|
+
VALUE method_pixel_checksum(int argc, VALUE argv[], VALUE self)
|
13
|
+
{
|
14
|
+
int step = 1;
|
15
|
+
unsigned long result;
|
16
|
+
|
17
|
+
check_for_arg_error(argc, 4, 5);
|
18
|
+
|
19
|
+
if (argc == 5)
|
20
|
+
step = FIX2INT(argv[4]);
|
21
|
+
|
22
|
+
result = AU3_PixelChecksum(FIX2INT(argv[0]), FIX2INT(argv[1]), FIX2INT(argv[2]), FIX2INT(argv[3]), step);
|
23
|
+
return NUM2INT(result);
|
24
|
+
}
|
25
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
26
|
+
VALUE method_get_pixel_color(VALUE self, VALUE x, VALUE y)
|
27
|
+
{
|
28
|
+
return INT2NUM(AU3_PixelGetColor(FIX2INT(x), FIX2INT(y)));
|
29
|
+
}
|
30
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
31
|
+
VALUE method_search_for_pixel(int argc, VALUE argv[], VALUE self)
|
32
|
+
{
|
33
|
+
int shade_var = 0;
|
34
|
+
int step = 1;
|
35
|
+
int result[2];
|
36
|
+
LPPOINT presult = (LPPOINT) result;
|
37
|
+
|
38
|
+
//This function doesn't work correctly.
|
39
|
+
rb_raise(rb_eNotImpError, "This function isn't yet implemented.");
|
40
|
+
|
41
|
+
check_for_arg_error(argc, 5, 7);
|
42
|
+
|
43
|
+
if (argc >= 6)
|
44
|
+
shade_var = FIX2INT(argv[5]);
|
45
|
+
if (argc >= 7)
|
46
|
+
step = FIX2INT(argv[6]);
|
47
|
+
|
48
|
+
AU3_PixelSearch(FIX2INT(argv[0]), FIX2INT(argv[1]), FIX2INT(argv[2]), FIX2INT(argv[3]), NUM2INT(argv[4]), shade_var, step, presult);
|
49
|
+
|
50
|
+
return rb_ary_new3(2, INT2FIX(result[0]), INT2FIX(result[1]));
|
51
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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
|
+
*=keyboard.c
|
9
|
+
*This file describes the bridge to the keyboard control
|
10
|
+
*function of AutoItX.
|
11
|
+
*/
|
12
|
+
|
13
|
+
VALUE method_send_keys(int argc, VALUE argv[], VALUE self)
|
14
|
+
{
|
15
|
+
VALUE rstr;
|
16
|
+
LPCWSTR flag = to_wchar_t("");
|
17
|
+
|
18
|
+
check_for_arg_error(argc, 1, 2);
|
19
|
+
|
20
|
+
if (argc == 2)
|
21
|
+
{
|
22
|
+
rstr = rb_funcall(argv[1], rb_intern("to_s"), 0);
|
23
|
+
flag = rstr_to_wstr(rstr);
|
24
|
+
}
|
25
|
+
|
26
|
+
AU3_Send(rstr_to_wstr(argv[0]), *flag);
|
27
|
+
|
28
|
+
return Qnil;
|
29
|
+
}
|
data/ext/parts/misc.c
ADDED
@@ -0,0 +1,107 @@
|
|
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
|
+
*=misc.c
|
9
|
+
*Miscellaneous methods that can't be categorized.
|
10
|
+
*/
|
11
|
+
|
12
|
+
VALUE method_last_error(VALUE self)
|
13
|
+
{
|
14
|
+
return INT2FIX(AU3_error());
|
15
|
+
}
|
16
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
17
|
+
VALUE method_set_option(VALUE self, VALUE option, VALUE value)
|
18
|
+
{
|
19
|
+
return INT2NUM(AU3_AutoItSetOption(rstr_to_wstr(option), NUM2INT(value)));
|
20
|
+
}
|
21
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
22
|
+
VALUE method_input_blocked(VALUE self)
|
23
|
+
{
|
24
|
+
return rb_ivar_get(self, rb_intern("@input_blocked"));
|
25
|
+
}
|
26
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
27
|
+
VALUE method_block_input(VALUE self, VALUE block)
|
28
|
+
{
|
29
|
+
int b = 1;
|
30
|
+
VALUE blocked = Qtrue;
|
31
|
+
if (TYPE(block) == T_FALSE || TYPE(block) == T_NIL)
|
32
|
+
{
|
33
|
+
b = 0;
|
34
|
+
blocked = Qfalse;
|
35
|
+
}
|
36
|
+
AU3_BlockInput(b);
|
37
|
+
rb_ivar_set(self, rb_intern("@input_blocked"), blocked);
|
38
|
+
return blocked;
|
39
|
+
}
|
40
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
41
|
+
VALUE method_open_cd_tray(VALUE self, VALUE drive)
|
42
|
+
{
|
43
|
+
return ((AU3_CDTray(rstr_to_wstr(drive), to_wchar_t("open")) == 1) ? Qtrue : Qfalse);
|
44
|
+
}
|
45
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
46
|
+
VALUE method_close_cd_tray(VALUE self, VALUE drive)
|
47
|
+
{
|
48
|
+
return ((AU3_CDTray(rstr_to_wstr(drive), to_wchar_t("closed")) == 1) ? Qtrue : Qfalse);
|
49
|
+
}
|
50
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
51
|
+
VALUE method_is_admin(VALUE self)
|
52
|
+
{
|
53
|
+
if (AU3_IsAdmin() == 0)
|
54
|
+
return Qfalse;
|
55
|
+
else
|
56
|
+
return Qtrue;
|
57
|
+
}
|
58
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
59
|
+
//This method seems to have been removed.
|
60
|
+
/*VALUE method_download_file(VALUE self, VALUE url, VALUE target)
|
61
|
+
{
|
62
|
+
if (AU3_URLDownloadToFile(to_wchar_t(StringValuePtr(url)), to_wchar_t(StringValuePtr(target))))
|
63
|
+
return Qtrue;
|
64
|
+
else
|
65
|
+
return Qfalse;
|
66
|
+
}*/
|
67
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
68
|
+
VALUE method_set_cliptext(VALUE self, VALUE text)
|
69
|
+
{
|
70
|
+
AU3_ClipPut(rstr_to_wstr(text));
|
71
|
+
return Qnil;
|
72
|
+
}
|
73
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
74
|
+
VALUE method_get_cliptext(VALUE self)
|
75
|
+
{
|
76
|
+
wchar_t cliptext[10000];
|
77
|
+
AU3_ClipGet(cliptext, 10000);
|
78
|
+
if (AU3_error() == 1)
|
79
|
+
return rb_str_new2("");
|
80
|
+
else
|
81
|
+
return rb_str_new2(to_char(cliptext));
|
82
|
+
}
|
83
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
84
|
+
VALUE method_tool_tip(int argc, VALUE argv[], VALUE self)
|
85
|
+
{
|
86
|
+
int x = AU3_INTDEFAULT;
|
87
|
+
int y = AU3_INTDEFAULT;
|
88
|
+
|
89
|
+
if (argc == 3)
|
90
|
+
{
|
91
|
+
x = NUM2INT(argv[1]);
|
92
|
+
y = NUM2INT(argv[2]);
|
93
|
+
}
|
94
|
+
else if (argc == 2)
|
95
|
+
rb_raise(rb_eArgError, "Wrong number of arguments. You must specify a Y value.");
|
96
|
+
else
|
97
|
+
check_for_arg_error(argc, 1, 3);
|
98
|
+
|
99
|
+
AU3_ToolTip(rstr_to_wstr(argv[0]), x, y);
|
100
|
+
return Qnil;
|
101
|
+
}
|
102
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
103
|
+
VALUE method_msleep(VALUE self, VALUE msecs)
|
104
|
+
{
|
105
|
+
AU3_Sleep(NUM2INT(msecs));
|
106
|
+
return Qnil;
|
107
|
+
}
|
data/ext/parts/mouse.c
ADDED
@@ -0,0 +1,130 @@
|
|
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
|
+
*=mouse.c
|
9
|
+
*Functions to control the mouse.
|
10
|
+
*/
|
11
|
+
|
12
|
+
VALUE method_mouse_click(int argc, VALUE argv[], VALUE self)
|
13
|
+
{
|
14
|
+
LPCWSTR button = to_wchar_t("Primary");
|
15
|
+
int x = AU3_INTDEFAULT;
|
16
|
+
int y = AU3_INTDEFAULT;
|
17
|
+
int clicks = 1;
|
18
|
+
int speed = 10;
|
19
|
+
char err[100];
|
20
|
+
|
21
|
+
check_for_arg_error(argc, 0, 5);
|
22
|
+
|
23
|
+
if (argc >= 1)
|
24
|
+
x = FIX2INT(argv[0]);
|
25
|
+
if (argc >= 2)
|
26
|
+
y = FIX2INT(argv[1]);
|
27
|
+
if (argc >= 3)
|
28
|
+
button = rstr_to_wstr(argv[2]);
|
29
|
+
if (argc >= 4)
|
30
|
+
clicks = FIX2INT(argv[3]);
|
31
|
+
if (argc >= 5)
|
32
|
+
speed = FIX2INT(argv[4]);
|
33
|
+
|
34
|
+
AU3_MouseClick(button, x, y, clicks, speed);
|
35
|
+
|
36
|
+
if (AU3_error() == 1)
|
37
|
+
{
|
38
|
+
sprintf(err, "Could not find mouse button '%s'!", to_char(button));
|
39
|
+
rb_raise(Au3Error, err);
|
40
|
+
}
|
41
|
+
|
42
|
+
return Qnil;
|
43
|
+
}
|
44
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
45
|
+
VALUE method_drag_mouse(int argc, VALUE argv[], VALUE self)
|
46
|
+
{
|
47
|
+
LPCWSTR button = to_wchar_t("Primary");
|
48
|
+
int speed = 10;
|
49
|
+
char err[100];
|
50
|
+
|
51
|
+
check_for_arg_error(argc, 4, 6);
|
52
|
+
|
53
|
+
if (argc >= 5)
|
54
|
+
button = rstr_to_wstr(argv[4]);
|
55
|
+
if (argc >= 6)
|
56
|
+
speed = FIX2INT(argv[6]);
|
57
|
+
|
58
|
+
AU3_MouseClickDrag(button, FIX2INT(argv[0]), FIX2INT(argv[1]), FIX2INT(argv[2]), FIX2INT(argv[3]), speed);
|
59
|
+
|
60
|
+
if (AU3_error() == 1)
|
61
|
+
{
|
62
|
+
sprintf(err, "Could not find mouse button '%s'!", to_char(button));
|
63
|
+
rb_raise(Au3Error, err);
|
64
|
+
}
|
65
|
+
|
66
|
+
return Qnil;
|
67
|
+
}
|
68
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
69
|
+
VALUE method_hold_mouse_down(int argc, VALUE argv[], VALUE self)
|
70
|
+
{
|
71
|
+
LPCWSTR button = to_wchar_t("Primary");
|
72
|
+
check_for_arg_error(argc, 0, 1);
|
73
|
+
if (argc == 1)
|
74
|
+
button = rstr_to_wstr(argv[0]);
|
75
|
+
AU3_MouseDown(button);
|
76
|
+
return Qnil;
|
77
|
+
}
|
78
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
79
|
+
VALUE method_cursor_id(VALUE self)
|
80
|
+
{
|
81
|
+
return INT2FIX(AU3_MouseGetCursor());
|
82
|
+
}
|
83
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
84
|
+
VALUE method_cursor_pos(VALUE self)
|
85
|
+
{
|
86
|
+
int x = AU3_MouseGetPosX();
|
87
|
+
int y = AU3_MouseGetPosY();
|
88
|
+
return rb_ary_new3(2, INT2NUM(x), INT2NUM(y));
|
89
|
+
}
|
90
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
91
|
+
VALUE method_move_mouse(int argc, VALUE argv[], VALUE self)
|
92
|
+
{
|
93
|
+
int speed = -1;
|
94
|
+
check_for_arg_error(argc, 2, 3);
|
95
|
+
if (argc == 3)
|
96
|
+
speed = INT2FIX(argv[2]);
|
97
|
+
AU3_MouseMove(NUM2INT(argv[0]), NUM2INT(argv[1]), speed);
|
98
|
+
return Qnil;
|
99
|
+
}
|
100
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
101
|
+
VALUE method_release_mouse(int argc, VALUE argv[], VALUE self)
|
102
|
+
{
|
103
|
+
LPCWSTR button = to_wchar_t("Primary");
|
104
|
+
check_for_arg_error(argc, 0, 1);
|
105
|
+
if (argc == 1)
|
106
|
+
button = rstr_to_wstr(argv[0]);
|
107
|
+
AU3_MouseUp(button);
|
108
|
+
return Qnil;
|
109
|
+
}
|
110
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
111
|
+
VALUE method_mouse_wheel(int argc, VALUE argv[], VALUE self)
|
112
|
+
{
|
113
|
+
int clicks = 5;
|
114
|
+
char err[100];
|
115
|
+
|
116
|
+
check_for_arg_error(argc, 1, 2);
|
117
|
+
|
118
|
+
if (argc == 2)
|
119
|
+
clicks = FIX2INT(argv[1]);
|
120
|
+
|
121
|
+
AU3_MouseWheel(rstr_to_wstr(argv[0]), clicks);
|
122
|
+
|
123
|
+
if (AU3_error() == 1)
|
124
|
+
{
|
125
|
+
sprintf(err, "Unrecognized mouse wheel direction '%s'!", StringValuePtr(argv[0]));
|
126
|
+
rb_raise(Au3Error, err);
|
127
|
+
}
|
128
|
+
|
129
|
+
return Qnil;
|
130
|
+
}
|
data/ext/parts/process.c
ADDED
@@ -0,0 +1,143 @@
|
|
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
|
+
*=process.c
|
9
|
+
*Functions to manipulate Windows processes.
|
10
|
+
*/
|
11
|
+
|
12
|
+
VALUE method_close_process(VALUE self, VALUE pid)
|
13
|
+
{
|
14
|
+
LPCWSTR proc = rstr_to_wstr(rb_funcall(pid, rb_intern("to_s"), 0));
|
15
|
+
AU3_ProcessClose(proc);
|
16
|
+
return Qnil;
|
17
|
+
}
|
18
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
19
|
+
VALUE method_process_exists(VALUE self, VALUE pid)
|
20
|
+
{
|
21
|
+
long result;
|
22
|
+
LPCWSTR proc = rstr_to_wstr(rb_funcall(pid, rb_intern("to_s"), 0));
|
23
|
+
|
24
|
+
if (result = AU3_ProcessExists(proc))
|
25
|
+
return INT2NUM(result);
|
26
|
+
else
|
27
|
+
return Qfalse;
|
28
|
+
}
|
29
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
30
|
+
VALUE method_set_process_priority(VALUE self, VALUE pid, VALUE priority)
|
31
|
+
{
|
32
|
+
LPCWSTR proc = rstr_to_wstr(rb_funcall(pid, rb_intern("to_s"), 0));
|
33
|
+
char err[100];
|
34
|
+
|
35
|
+
AU3_ProcessSetPriority(proc, FIX2INT(priority));
|
36
|
+
|
37
|
+
switch (AU3_error())
|
38
|
+
{
|
39
|
+
case 1:
|
40
|
+
{
|
41
|
+
sprintf(err, "Failed to set process priority of process %s!", to_char(proc));
|
42
|
+
rb_raise(Au3Error, err);
|
43
|
+
}
|
44
|
+
case 2:
|
45
|
+
{
|
46
|
+
sprintf(err, "Unsupported priority %i!", FIX2INT(priority));
|
47
|
+
rb_raise(Au3Error, err);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
return FIX2INT(priority);
|
52
|
+
}
|
53
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
54
|
+
VALUE method_wait_for_process(int argc, VALUE argv[], VALUE self)
|
55
|
+
{
|
56
|
+
int timeout = 0;
|
57
|
+
LPCWSTR proc = rstr_to_wstr(rb_funcall(argv[0], rb_intern("to_s"), 0));
|
58
|
+
check_for_arg_error(argc, 1, 2);
|
59
|
+
if (argc == 2)
|
60
|
+
timeout = NUM2INT(argv[1]);
|
61
|
+
return AU3_ProcessWait(proc, timeout) ? Qtrue : Qfalse;
|
62
|
+
}
|
63
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
64
|
+
VALUE method_wait_for_process_close(int argc, VALUE argv[], VALUE self)
|
65
|
+
{
|
66
|
+
int timeout = 0;
|
67
|
+
LPCWSTR proc = rstr_to_wstr(rb_funcall(argv[0], rb_intern("to_s"), 0));
|
68
|
+
check_for_arg_error(argc, 1, 2);
|
69
|
+
if (argc == 2)
|
70
|
+
timeout = NUM2INT(argv[1]);
|
71
|
+
return AU3_ProcessWaitClose(proc, timeout) ? Qtrue : Qfalse;
|
72
|
+
}
|
73
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
74
|
+
VALUE method_run(int argc, VALUE argv[], VALUE self)
|
75
|
+
{
|
76
|
+
LPCWSTR dir = to_wchar_t("");
|
77
|
+
int flag = 1;
|
78
|
+
long int pid;
|
79
|
+
check_for_arg_error(argc, 1, 3);
|
80
|
+
|
81
|
+
if (argc >= 2)
|
82
|
+
dir = rstr_to_wstr(argv[1]);
|
83
|
+
if (argc >= 3)
|
84
|
+
{
|
85
|
+
if (TYPE(argv[2]) == T_FALSE || TYPE(argv[2]) == T_NIL)
|
86
|
+
flag = 0;
|
87
|
+
else
|
88
|
+
flag = 1;
|
89
|
+
}
|
90
|
+
pid = AU3_Run(rstr_to_wstr(argv[0]), dir, flag);
|
91
|
+
|
92
|
+
//Gebe false bei Fehlschlag zur�ck
|
93
|
+
if (AU3_error())
|
94
|
+
return Qfalse;
|
95
|
+
else
|
96
|
+
return INT2NUM(pid);
|
97
|
+
}
|
98
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
99
|
+
VALUE method_run_as_set(int argc, VALUE argv[], VALUE self)
|
100
|
+
{
|
101
|
+
int flag = 1;
|
102
|
+
|
103
|
+
check_for_arg_error(argc, 3, 4);
|
104
|
+
|
105
|
+
if (argc == 4)
|
106
|
+
flag = FIX2INT(argv[3]);
|
107
|
+
|
108
|
+
if (AU3_RunAsSet(rstr_to_wstr(argv[0]), rstr_to_wstr(argv[1]), rstr_to_wstr(argv[2]), flag))
|
109
|
+
return Qtrue;
|
110
|
+
else
|
111
|
+
rb_raise(rb_eNotImpError, "The method 'run_as_set' is not implemented on your system!");
|
112
|
+
}
|
113
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
114
|
+
VALUE method_run_and_wait(int argc, VALUE argv[], VALUE self)
|
115
|
+
{
|
116
|
+
LPCWSTR dir = to_wchar_t("");
|
117
|
+
int flag = 1;
|
118
|
+
long int exitcode;
|
119
|
+
long int err;
|
120
|
+
check_for_arg_error(argc, 1, 3);
|
121
|
+
|
122
|
+
if (argc >= 2)
|
123
|
+
dir = rstr_to_wstr(argv[1]);
|
124
|
+
if (argc >= 3)
|
125
|
+
{
|
126
|
+
if (TYPE(argv[2]) == T_FALSE || TYPE(argv[2]) == T_NIL)
|
127
|
+
flag = 0;
|
128
|
+
else
|
129
|
+
flag = 1;
|
130
|
+
}
|
131
|
+
exitcode = AU3_RunWait(rstr_to_wstr(argv[0]), dir, flag);
|
132
|
+
|
133
|
+
//Gebe den korrekten Exitstatus zur�ck
|
134
|
+
if (err = AU3_error())
|
135
|
+
return LONG2NUM(err);
|
136
|
+
else
|
137
|
+
return LONG2NUM(exitcode);
|
138
|
+
}
|
139
|
+
//------------------------------------------------------------------------------------------------------------------------------------------
|
140
|
+
VALUE method_shutdown(VALUE self, VALUE code)
|
141
|
+
{
|
142
|
+
return (INT2NUM(AU3_Shutdown(FIX2INT(code))) == 0 ? Qfalse : Qtrue);
|
143
|
+
}
|