au3 0.1.1 → 0.1.2
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/lib/AutoItX3/au3.rb +3 -5
- data/lib/AutoItX3/control.rb +511 -44
- data/lib/AutoItX3/filedir.rb +68 -21
- data/lib/AutoItX3/graphic.rb +29 -5
- data/lib/AutoItX3/keyboard.rb +18 -4
- data/lib/AutoItX3/misc.rb +85 -28
- data/lib/AutoItX3/mouse.rb +82 -16
- data/lib/AutoItX3/process.rb +116 -51
- data/lib/AutoItX3/window.rb +346 -61
- data/lib/AutoItX3/window/send_message.rb +271 -0
- data/lib/HISTORY.rdoc +10 -0
- data/lib/README.rdoc +26 -1
- data/lib/au3.rb +6 -0
- data/test/test_misc.rb +2 -1
- data/test/test_window_messages.rb +42 -0
- metadata +42 -16
data/lib/AutoItX3/filedir.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#Encoding: UTF-8
|
2
2
|
#This file is part of au3.
|
3
|
-
#Copyright © 2009 Marvin Gülker
|
3
|
+
#Copyright © 2009, 2010 Marvin Gülker, Steven Heidel
|
4
4
|
#
|
5
5
|
#au3 is published under the same terms as Ruby.
|
6
6
|
#See http://www.ruby-lang.org/en/LICENSE.txt
|
@@ -9,15 +9,18 @@ module AutoItX3
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
12
|
-
|
12
|
+
#Maps a network drive.
|
13
|
+
#===Parameters
|
13
14
|
#Every | is ment to be a backslash.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
#
|
15
|
+
#[+device+] The device letter to map the drive to, in the form <tt>"X:"</tt>. If this is an asterisk *, the next available letter will be used.
|
16
|
+
#[+remote_share+] The address of the network drive, in the form <tt>"||Server|Drive"</tt> or <tt>"||Server|Share"</tt>.
|
17
|
+
#[+flags+] (0) A combination (via +) of 1 (PersistantMapping) and 8 (Show authentification dialog if neccessary).
|
18
|
+
#[+username+] ("") The username, of the form <tt>"username"</tt> or <tt>"Domain|username"</tt>.
|
19
|
+
#[+password+] (""): The login password.
|
20
|
+
#===Return value
|
21
|
+
#The assigned drive letter.
|
22
|
+
#===Raises
|
23
|
+
#[Au3Error] Failed to connect the network drive.
|
21
24
|
def add_drive_map(device, remote_share, flags = 0, username = "", password = "")
|
22
25
|
@functions[__method__] ||= AU3_Function.new("DriveMapAdd", 'SSLSSPI')
|
23
26
|
buffer = " " * BUFFER_SIZE
|
@@ -35,21 +38,29 @@ module AutoItX3
|
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
38
|
-
#Disconnects a network drive.
|
39
|
-
|
40
|
-
#
|
41
|
+
#Disconnects a network drive.
|
42
|
+
#===Parameters
|
43
|
+
#[+device+] The device to disconnect. Can be either of form <tt>"X:"</tt> or <tt>"||Server|share</tt> (| is a backslash).
|
44
|
+
#===Return value
|
45
|
+
#nil.
|
46
|
+
#===Raises
|
47
|
+
#[Au3Error] Couldn't disconnect the network drive.
|
41
48
|
def delete_drive_map(device)
|
42
49
|
@functions[__method__] ||= AU3_Function.new("DriveMapDel", 'S', 'L')
|
43
50
|
result = @functions[__method__].call(device)
|
44
51
|
if result == 0
|
45
52
|
raise(Au3Error, "Failed to remove remote device '#{device}'!")
|
46
53
|
end
|
47
|
-
|
54
|
+
nil
|
48
55
|
end
|
49
56
|
|
50
|
-
#Gets the server of
|
51
|
-
|
52
|
-
|
57
|
+
#Gets the server of a network drive.
|
58
|
+
#===Parameters
|
59
|
+
#[+device+] The device to check.
|
60
|
+
#===Return value
|
61
|
+
#A string of form <tt>"||Server|drive"</tt>, where every | is meant to be a backslash.
|
62
|
+
#===Raises
|
63
|
+
#[Au3Error] Couldn't retrieve the requested information.
|
53
64
|
def get_drive_map(device)
|
54
65
|
@functions[__method__] ||= AU3_Function.new("DriveMapGet", 'SPI')
|
55
66
|
buffer = " " * BUFFER_SIZE
|
@@ -63,6 +74,14 @@ module AutoItX3
|
|
63
74
|
end
|
64
75
|
|
65
76
|
#Deletes a key-value pair in a standard <tt>.ini</tt> file.
|
77
|
+
#===Parameters
|
78
|
+
#[+filename+] The filename of the file.
|
79
|
+
#[+section+] The section the key resides in.
|
80
|
+
#[+key+] The key to delete.
|
81
|
+
#===Return value
|
82
|
+
#true on success, otherwise false.
|
83
|
+
#===Example
|
84
|
+
# AutoItX3.delete_ini_entry("myini.ini", "mysection", "mykey")
|
66
85
|
def delete_ini_entry(filename, section, key)
|
67
86
|
@functions[__method__] ||= AU3_Function.new("IniDelete", 'SSS', 'L')
|
68
87
|
if @functions[__method__].call(filename.wide, section.wide, key.wide) == 0
|
@@ -72,9 +91,23 @@ module AutoItX3
|
|
72
91
|
end
|
73
92
|
end
|
74
93
|
|
75
|
-
#Reads a value from a standard <tt>.ini</tt> file
|
76
|
-
|
77
|
-
|
94
|
+
#Reads a value from a standard <tt>.ini</tt> file.
|
95
|
+
#===Parameters
|
96
|
+
#[+filename+] The filename of the file.
|
97
|
+
#[+section+] The section the key resides in.
|
98
|
+
#[+key+] The key to read.
|
99
|
+
#[+default+] ("")A string to return on failure.
|
100
|
+
#===Return value
|
101
|
+
#The value of the +default+ parameter.
|
102
|
+
#===Example
|
103
|
+
# puts AutoItX3.read_ini_entry("myini.ini", "mysection", "mykey") #=> myvalue
|
104
|
+
# #Nonexistant key:
|
105
|
+
# puts AutoItX3.read_ini_entry("myini.ini", "mysection", "mynonexsistingkey") #=>
|
106
|
+
# #With default value
|
107
|
+
# puts AutoItX3.read_ini_entry("myini,ini", "mysection", "mynonexsistingkey", "NOTHING") #=> NOTHING
|
108
|
+
#===Remarks
|
109
|
+
#The returned string has a maximum length of <tt>AutoItX3::BUFFER_SIZE - 1 </tt> characters.
|
110
|
+
def read_ini_entry(filename, section, key, default = "")
|
78
111
|
@functions[__method__] ||= AU3_Function.new("IniRead", 'SSSSPI')
|
79
112
|
buffer = " " * BUFFER_SIZE
|
80
113
|
buffer.wide!
|
@@ -82,8 +115,22 @@ module AutoItX3
|
|
82
115
|
buffer.normal.strip
|
83
116
|
end
|
84
117
|
|
85
|
-
#Writes the specified key-value pair in a <tt>.ini</tt> file.
|
86
|
-
|
118
|
+
#Writes the specified key-value pair in a <tt>.ini</tt> file.
|
119
|
+
#===Parameters
|
120
|
+
#[+filename+] The file's filename.
|
121
|
+
#[+section+] The section you want to write in.
|
122
|
+
#[+key+] The key whose value you want to write.
|
123
|
+
#[+value+] The value to write.
|
124
|
+
#===Return value
|
125
|
+
#The +value+ argument.
|
126
|
+
#===Raises
|
127
|
+
#[Au3Error] +filename+ is read-only.
|
128
|
+
#===Example
|
129
|
+
# AutoItX3.write_ini_entry("minini.ini", "mysection", "mykey", "myvalue")
|
130
|
+
#===Remarks
|
131
|
+
#Both the +section+ and the +key+ will be created if they aren't there already. Likewise is the file if nonexistant.
|
132
|
+
#
|
133
|
+
#If the specified key-value pair already exists, it will be overwritten.
|
87
134
|
def write_ini_entry(filename, section, key_value, value)
|
88
135
|
@functions[__method__] ||= AU3_Function.new("IniWrite", 'SSSS', 'L')
|
89
136
|
|
data/lib/AutoItX3/graphic.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#Encoding: UTF-8
|
2
2
|
#This file is part of au3.
|
3
|
-
#Copyright © 2009 Marvin Gülker
|
3
|
+
#Copyright © 2009, 2010 Marvin Gülker, Steven Heidel
|
4
4
|
#
|
5
5
|
#au3 is published under the same terms as Ruby.
|
6
6
|
#See http://www.ruby-lang.org/en/LICENSE.txt
|
@@ -9,8 +9,22 @@ module AutoItX3
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
12
|
-
#Computes a checksum of the pixels in the specified region.
|
13
|
-
|
12
|
+
#Computes a checksum of the pixels in the specified region.
|
13
|
+
#===Parameters
|
14
|
+
#[+x1+] Upper-left X-Coordinate of the region.
|
15
|
+
#[+y1+] Upper-left Y-Coordinate of the region.
|
16
|
+
#[+x2+] Lower-right X-Coordinate of the region.
|
17
|
+
#[+y2+] Lower-right Y-Coordinate of the region.
|
18
|
+
#[+step+] (1) Indicatates how many pixels are used for the computation. Every <tt>step</tt>-th pixel will be checked.
|
19
|
+
#===Return value
|
20
|
+
#The computed checksum.
|
21
|
+
#===Example
|
22
|
+
# #Compute the checksum of [0, 0, 100, 100]
|
23
|
+
# p AutoItX3.pixel_checksum(0, 0, 100, 100) #=> 2252979179
|
24
|
+
# #Then move a window into this region.
|
25
|
+
# p AutoItX3.pixel_checksum(0, 0, 100, 100) #=> 4287194203
|
26
|
+
#===Remarks
|
27
|
+
#If the checksum changes, that only indidcates that *something* has changed, not *what*.
|
14
28
|
#Note that this method may be very time-consuming, so think about increasing the
|
15
29
|
#+step+ parameter (but bear in mind that that will generate more inaccurate checksums).
|
16
30
|
def pixel_checksum(x1, y1, x2, y2, step = 1)
|
@@ -18,8 +32,18 @@ module AutoItX3
|
|
18
32
|
@functions[__method__].call(x1, y1, x2, y2, step)
|
19
33
|
end
|
20
34
|
|
21
|
-
#Retrieves the
|
22
|
-
|
35
|
+
#Retrieves the color value of the pixel at the specified position.
|
36
|
+
#===Parameters
|
37
|
+
#[+x+] The pixel's X coordinate.
|
38
|
+
#[+y+] The pixel's Y coordinate.
|
39
|
+
#[+hex+] Changes the return value, see below.
|
40
|
+
#===Return value
|
41
|
+
#The decimal color value of the specified pixel. If you set +hex+ to true,
|
42
|
+
#you get a string in form <tt>#RRGGBB</tt> that describes the color in
|
43
|
+
#hexadecimal format.
|
44
|
+
#===Example
|
45
|
+
# p AutoItX3.get_pixel_color(15, 15) #=> 1057590
|
46
|
+
# p AutoItX3.get_pixel_color(15, 15, true) #=> "#102336"
|
23
47
|
def get_pixel_color(x, y, hex = false)
|
24
48
|
@functions[__method__] ||= AU3_Function.new("PixelGetColor", 'LL', 'L')
|
25
49
|
res = @functions[__method__].call(x, y)
|
data/lib/AutoItX3/keyboard.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#Encoding: UTF-8
|
2
2
|
#This file is part of au3.
|
3
|
-
#Copyright © 2009 Marvin Gülker
|
3
|
+
#Copyright © 2009, 2010 Marvin Gülker, Steven Heidel
|
4
4
|
#
|
5
5
|
#au3 is published under the same terms as Ruby.
|
6
6
|
#See http://www.ruby-lang.org/en/LICENSE.txt
|
@@ -9,9 +9,23 @@ module AutoItX3
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
12
|
-
#Simulates
|
13
|
-
|
14
|
-
#
|
12
|
+
#Simulates keyboard input.
|
13
|
+
#===Parameters
|
14
|
+
#[+keys+] The keystrokes to simulate. See _Remarks_.
|
15
|
+
#[+flag+] (+false+) If set to +true+, escape sequences in braces { and } are ignored.
|
16
|
+
#===Return value
|
17
|
+
#nil.
|
18
|
+
#===Example
|
19
|
+
# #Simulate [SHIFT] + [A], [B] and [C].
|
20
|
+
# AutoItX3.send_keys("Abc")
|
21
|
+
# #Simulate [A], [ESC] and b.
|
22
|
+
# AutoItX3.send_keys("a{ESC}b")
|
23
|
+
# #Ignore the escape sequence and send it as regular keystrokes.
|
24
|
+
# AutoItX3.send_keys("a{ESC}b", true)
|
25
|
+
# #Sends [ALT] + [F]
|
26
|
+
# AutoItX3.send_keys("!F")
|
27
|
+
#===Remarks
|
28
|
+
#You may use some of the follwing escape sequences in braces { and }
|
15
29
|
#(copied from the AutoItX3 help):
|
16
30
|
# Escape sequence | Resulting keypress
|
17
31
|
# ====================+============================================================
|
data/lib/AutoItX3/misc.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#Encoding: UTF-8
|
2
2
|
#This file is part of au3.
|
3
|
-
#Copyright © 2009 Marvin Gülker
|
3
|
+
#Copyright © 2009, 2010 Marvin Gülker, Steven Heidel
|
4
4
|
#
|
5
5
|
#au3 is published under the same terms as Ruby.
|
6
6
|
#See http://www.ruby-lang.org/en/LICENSE.txt
|
@@ -9,9 +9,20 @@ module AutoItX3
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
12
|
-
#Blocks user input
|
13
|
-
|
14
|
-
#
|
12
|
+
#Blocks user input.
|
13
|
+
#===Parameters
|
14
|
+
#[+val+] Wheather the user input should be blocked or not.
|
15
|
+
#===Return value
|
16
|
+
#The passed argument, double-negated to ensure a boolean value.
|
17
|
+
#===Example
|
18
|
+
# p AutoItX3.input_blocked? #=> false
|
19
|
+
# AutoItX3.block_input = true
|
20
|
+
# p AutoItX3.input_blocked? #=> true
|
21
|
+
# AutoItX3.block_input = false
|
22
|
+
# p AutoItX3.input_blocked? #=> false
|
23
|
+
#===Remarks
|
24
|
+
#The user can gain back control by pressing [CTRL] + [ALT] + [DEL].
|
25
|
+
#In older versions of Windows AutoIt itself may also be blocked.
|
15
26
|
def block_input=(val)
|
16
27
|
@functions[__method__] ||= AU3_Function.new("BlockInput", 'L')
|
17
28
|
@functions[__method__].call(!!val)
|
@@ -19,45 +30,72 @@ module AutoItX3
|
|
19
30
|
end
|
20
31
|
|
21
32
|
#Returns wheather or not input is blocked by AutoItX3.
|
33
|
+
#===Return value
|
34
|
+
#true or false.
|
35
|
+
#===Example
|
36
|
+
# #See #block_input.
|
37
|
+
#===Remarks
|
38
|
+
#This method fails to report that input has been enabled again if the
|
39
|
+
#user has pressed [CTRL] + [ALT] + [DEL] after a call to #block_input=.
|
22
40
|
def input_blocked?
|
23
41
|
@input_blocked ||= false
|
24
42
|
end
|
25
43
|
|
26
|
-
#Opens
|
27
|
-
|
44
|
+
#Opens a CD/DVD drive.
|
45
|
+
#===Parameters
|
46
|
+
#[+tray+] The drive to eject, a string of form <tt>"X:"</tt>.
|
47
|
+
#===Return value
|
48
|
+
#true on success, false otherwise.
|
49
|
+
#===Example
|
50
|
+
# AutoItX3.open_cd_tray("E:") #| true
|
51
|
+
# AutoItX3.open_cd_tray("Y:") #| false
|
52
|
+
#===Remarks
|
53
|
+
#The cd tray must be local at this computer, remote drives
|
28
54
|
#cannot be accessed.
|
29
55
|
def open_cd_tray(tray)
|
30
56
|
@functions[__method__] ||= AU3_Function.new("CDTray", 'SS', 'L')
|
31
57
|
raise(ArgumentError, "The drive name has to be of form 'X:'!") unless tray =~ /^\w:$/
|
32
|
-
|
33
|
-
return false
|
34
|
-
else
|
35
|
-
return true
|
36
|
-
end
|
58
|
+
@functions[__method__].call(tray.wide, "open".wide) == 1
|
37
59
|
end
|
38
60
|
|
39
|
-
#Closes a
|
40
|
-
|
41
|
-
#
|
61
|
+
#Closes a CD/DVD drive.
|
62
|
+
#===Parameters
|
63
|
+
#[+tray+] The drive to close.
|
64
|
+
#===Return value
|
65
|
+
#true on success, false otherwise.
|
66
|
+
#===Example
|
67
|
+
# AutoItX3.open_cd_tray("E:")
|
68
|
+
# AutoItX3.close_cd_tray("E:")
|
69
|
+
#===Remarks
|
70
|
+
#The cd tray must be local at this computer, remote drives
|
71
|
+
#cannot be accessed.
|
72
|
+
#This method may return true if +drive+ is a laptop drive which can only be
|
42
73
|
#closed manually.
|
43
74
|
def close_cd_tray(tray)
|
44
75
|
@functions[__method__] ||= AU3_Function.new("CDTray", 'SS', 'L')
|
45
76
|
raise(ArgumentError, "The drive name has to be of form 'X:'!") unless tray =~ /^\w:$/
|
46
|
-
|
47
|
-
return false
|
48
|
-
else
|
49
|
-
return true
|
50
|
-
end
|
77
|
+
@functions[__method__].call(tray.wide, "closed".wide) == 1
|
51
78
|
end
|
52
79
|
|
53
80
|
#Determines wheather the current user has administrator privileges.
|
81
|
+
#===Return value
|
82
|
+
#true or false,
|
83
|
+
#===Example
|
84
|
+
# p AutoItX3.is_admin? #=> false
|
54
85
|
def is_admin?
|
55
86
|
@functions[__method__] ||= AU3_Function.new("IsAdmin", 'V', 'L')
|
56
|
-
|
57
|
-
true
|
87
|
+
@functions[__method__].call == 1
|
58
88
|
end
|
59
89
|
|
60
90
|
#Writes +text+ to the Windows clipboard.
|
91
|
+
#===Parameters
|
92
|
+
#[+text+] The text to write.
|
93
|
+
#===Return value
|
94
|
+
#The argument passed.
|
95
|
+
#===Example
|
96
|
+
# AutoItX3.cliptext = "I love Ruby!"
|
97
|
+
# puts AutoItX3.cliptext #=> I love Ruby!
|
98
|
+
#===Remarks
|
61
99
|
#You can't write NUL characters to the clipboard, the text will
|
62
100
|
#be terminated.
|
63
101
|
def cliptext=(text)
|
@@ -66,8 +104,16 @@ module AutoItX3
|
|
66
104
|
text
|
67
105
|
end
|
68
106
|
|
69
|
-
#
|
70
|
-
|
107
|
+
#Reads the Windows clipboard.
|
108
|
+
#===Return value
|
109
|
+
#The text saved in the clipboard, encoded in UTF-8.
|
110
|
+
#===Example
|
111
|
+
# puts AutoItX3.cliptext #=> I love Ruby!
|
112
|
+
#===Remarks
|
113
|
+
#Returns the text saved in the clipboard. It will be truncated at the
|
114
|
+
#<tt>AutoItX3::BUFFER_SIZE - 1</tt>th character or at a NUL character.
|
115
|
+
#
|
116
|
+
#If the clipboard doesn't contain text, this method returns an empty string.
|
71
117
|
def cliptext
|
72
118
|
@functions[__method__] ||= AU3_Function.new("ClipGet", 'PL')
|
73
119
|
cliptext = " " * BUFFER_SIZE
|
@@ -80,9 +126,16 @@ module AutoItX3
|
|
80
126
|
# tool_tip( text [, x = INTDEFAULT [, y = INTDEFAULT ] ] ) ==> nil
|
81
127
|
# tooltip( text [, x = INTDEFAULT [, y = INTDEFAULT ] ] ) ==> nil
|
82
128
|
#
|
83
|
-
#Displays a tooltip at the given position.
|
84
|
-
|
85
|
-
#
|
129
|
+
#Displays a tooltip at the given position.
|
130
|
+
#===Parameters
|
131
|
+
#[+text+] The text to display.
|
132
|
+
#[+x+] (+INTDEFAULT+) The X coordinate where to display the tooltip. Defaults to the cursor's X coordinate if ommited.
|
133
|
+
#[+y+] (+INTDEFAULT+) The Y coordinate where to display the tooltip. Defaults to the cursor's Y coordinate if ommited.
|
134
|
+
#===Return value
|
135
|
+
#nil.
|
136
|
+
#===Remarks
|
137
|
+
#Coordinates out of range are automatically corrected.
|
138
|
+
#
|
86
139
|
#The tooltip will be deleted when the program ends, or after a system-dependent
|
87
140
|
#timeout.
|
88
141
|
def tool_tip(text, x = INTDEFAULT, y = INTDEFAULT)
|
@@ -91,8 +144,12 @@ module AutoItX3
|
|
91
144
|
end
|
92
145
|
alias tooltip tool_tip
|
93
146
|
|
94
|
-
#Wait for the specified amount of milliseconds.
|
95
|
-
|
147
|
+
#Wait for the specified amount of milliseconds.
|
148
|
+
#===Return value
|
149
|
+
#nil.
|
150
|
+
#===Remarks
|
151
|
+
#In AutoIt, this function is named "Sleep", but to avoid compatibility
|
152
|
+
#issues with Ruby's own sleep I decided to
|
96
153
|
#name the function "msleep" (the "m" indicates "milli"). If you wish to name it
|
97
154
|
#"sleep", simply define an alias.
|
98
155
|
def msleep(msecs)
|
data/lib/AutoItX3/mouse.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#Encoding: UTF-8
|
2
2
|
#This file is part of au3.
|
3
|
-
#Copyright © 2009 Marvin Gülker
|
3
|
+
#Copyright © 2009, 2010 Marvin Gülker, Steven Heidel
|
4
4
|
#
|
5
5
|
#au3 is published under the same terms as Ruby.
|
6
6
|
#See http://www.ruby-lang.org/en/LICENSE.txt
|
@@ -34,13 +34,24 @@ module AutoItX3
|
|
34
34
|
|
35
35
|
class << self
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
#Executes a mouse click.
|
38
|
+
#===Parameters
|
39
|
+
#* x (INTDEFAULT): The X position. The cursor's current X if not specified.
|
40
|
+
#* y (INTDEFAULT): The Y position. The cursor's current Y if not specified.
|
41
|
+
#* button(<tt>"Primary"</tt>): The mouse button to click width. On a mouse for left-handed people the right, for right-handed people the left mouse button.
|
42
|
+
#* clicks(1): The number of times to click.
|
43
|
+
#* speed(10): The speed the mouse cursor will move with. If set to 0, the cursor is set immediatly.
|
44
|
+
#===Return value
|
45
|
+
#nil.
|
46
|
+
#===Raises
|
47
|
+
#[Au3Error] Invalid mouse button specified.
|
48
|
+
#===Example
|
49
|
+
# #Normal mouse click at (100|100).
|
50
|
+
# AutoItX3.mouse_click(100, 100)
|
51
|
+
# #Click with the right (or left if buttons are swapped) button
|
52
|
+
# AutoItX3.mouse_click(AutoItX3::INTDEFAULT, AutoItX3::INTDEFAULT, "Secondary")
|
53
|
+
# #Don't move the cursor
|
54
|
+
# AutoItX3.mouse_click(100, 100, "Primary", 1, 0)
|
44
55
|
#Clicks the mouse.
|
45
56
|
def mouse_click(x = INTDEFAULT, y = INTDEFAULT, button = "Primary", clicks = 1, speed = 10)
|
46
57
|
@functions[__method__] ||= AU3_Function.new("MouseClick", 'SLLLL', 'L')
|
@@ -50,7 +61,22 @@ module AutoItX3
|
|
50
61
|
nil
|
51
62
|
end
|
52
63
|
|
53
|
-
#Performes a drag & drop operation
|
64
|
+
#Performes a drag & drop operation.
|
65
|
+
#===Parameters
|
66
|
+
#[+x1+] The start X coordinate.
|
67
|
+
#[+y1+] The start Y coordinate.
|
68
|
+
#[+x2+] The goal X coordinate.
|
69
|
+
#[+y2+] The goal Y coordinate.
|
70
|
+
#[+button+] The button to hold down while moving.
|
71
|
+
#[+speed+] The cursor's speed. If 0, the cursor is set directly to the goal position.
|
72
|
+
#===Return value
|
73
|
+
#nil.
|
74
|
+
#===Raises
|
75
|
+
#[Au3Error] Invalid mouse button specified.
|
76
|
+
#===Example
|
77
|
+
# AutoItX3.drag_mouse(10, 10, 73, 86)
|
78
|
+
# #With the secondary mouse button
|
79
|
+
# AutoItX3.drag_mouse(10, 10, 73, 86, "Secondary")
|
54
80
|
def drag_mouse(x1, y1, x2, y2, button = "Primary", speed = 10)
|
55
81
|
@functions[__method__] ||= AU3_Function.new("MouseClickDrag", 'SLLLLL', 'L')
|
56
82
|
@functions[__method__].call(button.wide, x1, y1, x2, y2, speed)
|
@@ -63,7 +89,15 @@ module AutoItX3
|
|
63
89
|
# hold_mouse_down( [ button = "Primary" ] ) ==> nil
|
64
90
|
# mouse_down( [ button = "Primary" ] ) ==> nil
|
65
91
|
#
|
66
|
-
#Holds a mouse button down
|
92
|
+
#Holds a mouse button down.
|
93
|
+
#===Parameters
|
94
|
+
#[+button+] (<tt>"Primary"</tt>) The button to hold down.
|
95
|
+
#===Return value
|
96
|
+
#nil.
|
97
|
+
#===Example
|
98
|
+
# AutoItX3.hold_mouse_down("Primary")
|
99
|
+
# AutoItX3.hold_mouse_down("Secondary")
|
100
|
+
#===Remarks
|
67
101
|
#You should release the mouse button somewhen.
|
68
102
|
def hold_mouse_down(button = "Primary")
|
69
103
|
@functions[__method__] ||= AU3_Function.new("MouseDown", 'S')
|
@@ -75,7 +109,11 @@ module AutoItX3
|
|
75
109
|
# cursor_id ==> aFixnum
|
76
110
|
# get_cursor_id ==> aFixnum
|
77
111
|
#
|
78
|
-
#
|
112
|
+
#Get the cursor that is shown at the moment.
|
113
|
+
#===Return value
|
114
|
+
#One of the *_CURSOR constants to indicate which cursor icon is actually shown.
|
115
|
+
#===Example
|
116
|
+
# p AutoItX3.cursor_id #=> 5 #IBEAM_CURSOR, that one with the >I< form for editing texts.
|
79
117
|
def cursor_id
|
80
118
|
@functions[__method__] ||= AU3_Function.new("MouseGetCursor", '', 'L')
|
81
119
|
@functions[__method__].call
|
@@ -85,7 +123,11 @@ module AutoItX3
|
|
85
123
|
# cursor_pos ==> anArray
|
86
124
|
# get_cursor_pos ==> anArray
|
87
125
|
#
|
88
|
-
#Returns the current cursor position
|
126
|
+
#Returns the current cursor position.
|
127
|
+
#===Return value
|
128
|
+
#The current cursor position in a two-element array of form <tt>[x, y]</tt>.
|
129
|
+
#===Example
|
130
|
+
# p AutoItX3.cursor_pos #=> [127, 345]
|
89
131
|
def cursor_pos
|
90
132
|
@functions[:cursor_pos_x] ||= AU3_Function.new("MouseGetPosX", 'V', 'L')
|
91
133
|
@functions[:cursor_pos_y] ||= AU3_Function.new("MouseGetPosY", 'V', 'L')
|
@@ -96,8 +138,13 @@ module AutoItX3
|
|
96
138
|
# move_mouse( x , y [, speed = 10 ] ) ==> nil
|
97
139
|
# mouse_move( x , y [, speed = 10 ] ) ==> nil
|
98
140
|
#
|
99
|
-
#Moves the mouse cursor to the given position.
|
100
|
-
|
141
|
+
#Moves the mouse cursor to the given position.
|
142
|
+
#===Parameters
|
143
|
+
#[+x+] The goal X coordinate.
|
144
|
+
#[+y+] The goal Y coordinate.
|
145
|
+
#[+speed+] (+10+) The speed to move the cursor with. 0 means no movement and the cursor is set directly to the goal position.
|
146
|
+
#===Return value
|
147
|
+
#nil.
|
101
148
|
def move_mouse(x, y, speed = 10)
|
102
149
|
@functions[__method__] ||= AU3_Function.new("MouseMove", 'LLL', 'L')
|
103
150
|
@functions[__method__].call(x, y, speed)
|
@@ -109,14 +156,33 @@ module AutoItX3
|
|
109
156
|
# mouse_up( [ button = "Primary" ] ) ==> nil
|
110
157
|
#
|
111
158
|
#Releases a mouse button hold down by #hold_mouse_down.
|
159
|
+
#===Parameters
|
160
|
+
#[+button+] (<tt>"Primary"</tt>) The mouse button to release.
|
161
|
+
#===Return value
|
162
|
+
#nil.
|
163
|
+
#===Example
|
164
|
+
# AutoItX3.hold_mouse_down
|
165
|
+
# AutoItX3.release_mouse
|
166
|
+
# #With the secondary button
|
167
|
+
# AutoItX3.hold_mouse_down("Secondary")
|
168
|
+
# AutoItX3.release_mouse("Secondary")
|
112
169
|
def release_mouse(button = "Primary")
|
113
170
|
@functions[__method__] ||= AU3_Function.new("MouseUp", 'S')
|
114
171
|
@functions[__method__].call(button.wide)
|
115
172
|
nil
|
116
173
|
end
|
117
174
|
|
118
|
-
#Scrolls up or down the mouse wheel
|
119
|
-
|
175
|
+
#Scrolls up or down the mouse wheel.
|
176
|
+
#===Parameters
|
177
|
+
#[+direction+] The scrolling direction, either <tt>"up</tt> or <tt>"down</tt>.
|
178
|
+
#[+times+] The scrolling steps. These <b>are not</b> full wheel turns.
|
179
|
+
#===Return value
|
180
|
+
#nil.
|
181
|
+
#===Example
|
182
|
+
# #5 steps up.
|
183
|
+
# AutoItX3.mouse_wheel("up")
|
184
|
+
# #3 steps down.
|
185
|
+
# AutoItX3.mouse_wheel("down", 3)
|
120
186
|
def mouse_wheel(direction, times = 5)
|
121
187
|
@functions[__method__] ||= AU3_Function.new("MouseWheel", 'SL')
|
122
188
|
@functions[__method__].call(direction.wide, times)
|