special_input_device 0.0.0 → 0.0.1
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.
- checksums.yaml +4 -4
- data/ext/special_input_device/color.c +25 -6
- data/ext/special_input_device/color.h +5 -1
- data/ext/special_input_device/extconf.rb +2 -2
- data/ext/special_input_device/image.c +728 -0
- data/ext/special_input_device/image.h +8 -0
- data/ext/special_input_device/{interception_connector.c → interception.c} +7 -3
- data/ext/special_input_device/{interception_connector.h → interception.h} +0 -0
- data/ext/special_input_device/keyboard.c +4 -4
- data/ext/special_input_device/mouse.c +26 -28
- data/ext/special_input_device/ruby_macro.h +11 -3
- data/ext/special_input_device/screen.c +54 -164
- data/ext/special_input_device/special_input_device.c +2 -2
- data/ext/special_input_device/special_input_device.h +2 -1
- data/ext/special_input_device/win32error.c +0 -2
- data/ext/special_input_device/window.c +82 -105
- data/lib/special_input_device/color.rb +2 -3
- data/lib/special_input_device/image.rb +2 -61
- data/lib/special_input_device/point.rb +0 -1
- data/lib/special_input_device/special_input_device.rb +0 -1
- metadata +7 -15
- data/lib/special_input_device/image/bmp.rb +0 -89
- data/lib/special_input_device/image/error/damaged_image_error.rb +0 -4
- data/lib/special_input_device/image/error/image_error.rb +0 -3
- data/lib/special_input_device/image/error/unsupported_image_format_error.rb +0 -4
- data/lib/special_input_device/table_2d.rb +0 -157
- data/stab/keyboard.rb +0 -35
- data/stab/mouse.rb +0 -189
- data/stab/screen.rb +0 -56
- data/stab/win32_error.rb +0 -20
- data/stab/window.rb +0 -398
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# <code>SpecialInputDevice::Image</code> object represent an image.
|
|
4
|
-
class SpecialInputDevice::Image < SpecialInputDevice::Table2D
|
|
1
|
+
# An <code>Image</code> object represent a bitmap. It internally store colors of each pixel in 32 bit argb format.
|
|
2
|
+
class SpecialInputDevice::Image < Data
|
|
5
3
|
|
|
6
4
|
# A container of all return methods used by <code>#find</code> method.
|
|
7
5
|
# @see #find
|
|
@@ -12,45 +10,6 @@ class SpecialInputDevice::Image < SpecialInputDevice::Table2D
|
|
|
12
10
|
CLOSEST = :closest
|
|
13
11
|
end
|
|
14
12
|
|
|
15
|
-
# Load an image from a file.
|
|
16
|
-
# @param [File, String] argument the file need to load
|
|
17
|
-
# @return [SpecialInputDevice::Image] a new image
|
|
18
|
-
def self.load(argument)
|
|
19
|
-
case argument
|
|
20
|
-
when String
|
|
21
|
-
file = File.open(argument, 'rb')
|
|
22
|
-
when File
|
|
23
|
-
file = argument
|
|
24
|
-
file.binmode
|
|
25
|
-
else
|
|
26
|
-
raise(TypeError, "Expecting String or File, #{argument.class} gavin")
|
|
27
|
-
end
|
|
28
|
-
extension = file.path[/(?<=\.)(?<!\/\.)(?<!\\\.)\w+\Z/].upcase
|
|
29
|
-
# noinspection RubyResolve
|
|
30
|
-
image = const_get(extension).load(file)
|
|
31
|
-
file.close unless argument == file
|
|
32
|
-
image
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Save this image to a file.
|
|
36
|
-
# @param [File, String] argument the target file
|
|
37
|
-
# @return [SpecialInputDevice::Image] self
|
|
38
|
-
def save(argument)
|
|
39
|
-
case argument
|
|
40
|
-
when String
|
|
41
|
-
file = File.open(argument, 'wb')
|
|
42
|
-
when File
|
|
43
|
-
file = argument
|
|
44
|
-
file.binmode
|
|
45
|
-
else
|
|
46
|
-
raise(TypeError, "Expecting String or File, #{argument.class} gavin")
|
|
47
|
-
end
|
|
48
|
-
extension = file.path[/(?<=\.)(?<!\/\.)(?<!\\\.)\w+\Z/].upcase
|
|
49
|
-
SpecialInputDevice::Image.const_get(extension).save(self, file)
|
|
50
|
-
file.close unless argument == file
|
|
51
|
-
self
|
|
52
|
-
end
|
|
53
|
-
|
|
54
13
|
# Calculate similarity between a section of this image and another smaller image which provided by parameter
|
|
55
14
|
# <code>image</code>. The parameters <code>x</code> and <code>y</code> indicate the position of the upper-left corner
|
|
56
15
|
# of the section. The size of section is same as the size of smaller image. This method compares each pixel in two
|
|
@@ -107,18 +66,6 @@ class SpecialInputDevice::Image < SpecialInputDevice::Table2D
|
|
|
107
66
|
SpecialInputDevice::Rectangle.new(closest_similarity_x, closest_similarity_y, image.width, image.height)
|
|
108
67
|
end
|
|
109
68
|
|
|
110
|
-
# Override this method if validation is needed. In this method, raise an <code>Exception</code> if it is not valid.
|
|
111
|
-
# @param [Integer] x the x coordinate
|
|
112
|
-
# @param [Integer] y the y coordinate
|
|
113
|
-
# @param [Object] value the object at the specific coordinate
|
|
114
|
-
# @return [Object] the value to be stored
|
|
115
|
-
def validate(x, y, value)
|
|
116
|
-
raise(TypeError, "Expecting SpecialInputDevice::Color, #{value.class} gavin") if value && !value.is_a?(SpecialInputDevice::Color)
|
|
117
|
-
value
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
protected(:validate)
|
|
121
|
-
|
|
122
69
|
def find_path(image)
|
|
123
70
|
return nil unless image.width <= width && image.height <= height
|
|
124
71
|
width_difference = width - image.width
|
|
@@ -162,9 +109,3 @@ class SpecialInputDevice::Image < SpecialInputDevice::Table2D
|
|
|
162
109
|
private(:find_path)
|
|
163
110
|
|
|
164
111
|
end
|
|
165
|
-
|
|
166
|
-
require_relative('image/error/image_error')
|
|
167
|
-
require_relative('image/error/damaged_image_error')
|
|
168
|
-
require_relative('image/error/unsupported_image_format_error')
|
|
169
|
-
|
|
170
|
-
require_relative('image/bmp')
|
|
@@ -24,7 +24,6 @@ class SpecialInputDevice::Point
|
|
|
24
24
|
# Returns a new instance of <code>Point</code>.
|
|
25
25
|
# @param [Integer] x the x-coordinate of the point
|
|
26
26
|
# @param [Integer] y the y-coordinate of the point
|
|
27
|
-
# @return [SpecialInputDevice::Point] a new instance of <code>Point</code>
|
|
28
27
|
def initialize(x, y)
|
|
29
28
|
self.x = x
|
|
30
29
|
self.y = y
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: special_input_device
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 6y
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-01-
|
|
11
|
+
date: 2017-01-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: tlserver6y@gmail.com
|
|
@@ -26,8 +26,10 @@ files:
|
|
|
26
26
|
- ext/special_input_device/color.c
|
|
27
27
|
- ext/special_input_device/color.h
|
|
28
28
|
- ext/special_input_device/extconf.rb
|
|
29
|
-
- ext/special_input_device/
|
|
30
|
-
- ext/special_input_device/
|
|
29
|
+
- ext/special_input_device/image.c
|
|
30
|
+
- ext/special_input_device/image.h
|
|
31
|
+
- ext/special_input_device/interception.c
|
|
32
|
+
- ext/special_input_device/interception.h
|
|
31
33
|
- ext/special_input_device/keyboard.c
|
|
32
34
|
- ext/special_input_device/mouse.c
|
|
33
35
|
- ext/special_input_device/point.c
|
|
@@ -44,21 +46,11 @@ files:
|
|
|
44
46
|
- lib/special_input_device/attributes_equal_checker.rb
|
|
45
47
|
- lib/special_input_device/color.rb
|
|
46
48
|
- lib/special_input_device/image.rb
|
|
47
|
-
- lib/special_input_device/image/bmp.rb
|
|
48
|
-
- lib/special_input_device/image/error/damaged_image_error.rb
|
|
49
|
-
- lib/special_input_device/image/error/image_error.rb
|
|
50
|
-
- lib/special_input_device/image/error/unsupported_image_format_error.rb
|
|
51
49
|
- lib/special_input_device/key_code.rb
|
|
52
50
|
- lib/special_input_device/point.rb
|
|
53
51
|
- lib/special_input_device/rectangle.rb
|
|
54
52
|
- lib/special_input_device/special_input_device.rb
|
|
55
|
-
|
|
56
|
-
- stab/keyboard.rb
|
|
57
|
-
- stab/mouse.rb
|
|
58
|
-
- stab/screen.rb
|
|
59
|
-
- stab/win32_error.rb
|
|
60
|
-
- stab/window.rb
|
|
61
|
-
homepage:
|
|
53
|
+
homepage: http://tlserver6y.ddns.net/SpecialInputDevice
|
|
62
54
|
licenses:
|
|
63
55
|
- LGPL-3.0
|
|
64
56
|
metadata: {}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# <code>SpecialInputDevice::Image::BMP</code> is an image decoder for bmp files.
|
|
2
|
-
module SpecialInputDevice::Image::BMP
|
|
3
|
-
|
|
4
|
-
# The header identifiers of bitmap.
|
|
5
|
-
# This should be the first two bytes in the bitmap file.
|
|
6
|
-
BITMAP_HEADER_IDENTIFIERS = ['BM', 'BA', 'CI', 'CP', 'IC', 'PT']
|
|
7
|
-
|
|
8
|
-
# Load a image from a bmp file.
|
|
9
|
-
# @param [File] file the file need to load
|
|
10
|
-
# @return [SpecialInputDevice::Image] the image
|
|
11
|
-
def self.load(file)
|
|
12
|
-
filename = file.is_a?(File) ? "The path '#{file.path}'" : 'This bitmap file'
|
|
13
|
-
bitmap_header_identifier = file.read(2)
|
|
14
|
-
raise(ArgumentError, "#{filename} does not point to a bitmap file.") unless BITMAP_HEADER_IDENTIFIERS.include?(bitmap_header_identifier)
|
|
15
|
-
system_file_size = file.size if file.is_a?(File)
|
|
16
|
-
bitmap_file_size = file.read(4).unpack('L<')[0]
|
|
17
|
-
raise(SpecialInputDevice::DamagedImageError, "The size of the file at '#{path}' should be #{bitmap_file_size} bytes, but the image only has #{system_file_size} bytes.") if file.is_a?(File) && bitmap_file_size != system_file_size
|
|
18
|
-
file.read(4) # Reserved field
|
|
19
|
-
image_data_address = file.read(4).unpack('L<')[0]
|
|
20
|
-
dib_header_size = file.read(4).unpack('L<')[0]
|
|
21
|
-
raise(SpecialInputDevice::UnsupportedImageFormatError, "#{filename} is using an unsupported DIB header.") unless dib_header_size == 40
|
|
22
|
-
width = file.read(4).unpack('l<')[0]
|
|
23
|
-
height = file.read(4).unpack('l<')[0]
|
|
24
|
-
number_of_color_planes = file.read(2).unpack('S<')[0]
|
|
25
|
-
raise(SpecialInputDevice::DamagedImageError, "#{filename} has been damaged.") unless number_of_color_planes == 1
|
|
26
|
-
color_depth = file.read(2).unpack('S<')[0]
|
|
27
|
-
compression_method = file.read(4).unpack('L<')[0]
|
|
28
|
-
raise(SpecialInputDevice::UnsupportedImageFormatError, "#{filename} is using an unsupported compression method.") unless compression_method == 0
|
|
29
|
-
image_size = file.read(4).unpack('L<')[0]
|
|
30
|
-
file.read(4) # Horizontal resolution
|
|
31
|
-
file.read(4) # Vertical resolution
|
|
32
|
-
file.read(4) # Number of colors in the color palette
|
|
33
|
-
file.read(4) # Number of important colors used
|
|
34
|
-
file.read(image_data_address - 14 - dib_header_size) # Palette
|
|
35
|
-
raise(SpecialInputDevice::DamagedImageError, "#{filename} has been damaged.") unless image_size == (color_depth * width.abs + 31) / 32 * 4 * height.abs
|
|
36
|
-
padding_size = -color_depth * width % 32 / 8
|
|
37
|
-
image = SpecialInputDevice::Image.new(width.abs, height.abs)
|
|
38
|
-
if color_depth == 24 || color_depth == 32
|
|
39
|
-
byte_size = color_depth / 8
|
|
40
|
-
(height > 0 ? (height - 1).downto(0) : height.upto(-1)).each do |x0|
|
|
41
|
-
(width > 0 ? 0.upto(width - 1) : -1.downto(width)).each do |x1|
|
|
42
|
-
color = file.read(byte_size).unpack("C#{byte_size}")
|
|
43
|
-
color[0], color[2] = color[2], color[0]
|
|
44
|
-
image[x1, x0] = SpecialInputDevice::Color.new(*color)
|
|
45
|
-
end
|
|
46
|
-
file.read(padding_size)
|
|
47
|
-
end
|
|
48
|
-
else
|
|
49
|
-
raise(SpecialInputDevice::UnsupportedImageFormatError, "#{filename} is using an unsupported number of bits per pixel.")
|
|
50
|
-
end
|
|
51
|
-
image
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Save the image to a bmp file.
|
|
55
|
-
# @param [SpecialInputDevice::Image] image the file need to load
|
|
56
|
-
# @param [File] file the file need to load
|
|
57
|
-
# @return [SpecialInputDevice::Image] the image
|
|
58
|
-
def self.save(image, file)
|
|
59
|
-
bmp_header_size = 14
|
|
60
|
-
dib_header_size = 40
|
|
61
|
-
headers_size = bmp_header_size + dib_header_size
|
|
62
|
-
color_depth = 32
|
|
63
|
-
width = image.width
|
|
64
|
-
height = image.height
|
|
65
|
-
row_size = color_depth / 8 * width
|
|
66
|
-
image_size = row_size * height
|
|
67
|
-
bitmap_file_size = headers_size + image_size
|
|
68
|
-
pack_format = "C#{row_size}"
|
|
69
|
-
|
|
70
|
-
file.write(BITMAP_HEADER_IDENTIFIERS[0])
|
|
71
|
-
file.write([bitmap_file_size].pack('L<')) # Bitmap file size
|
|
72
|
-
file.write([0].pack('L<')) # Reserved field
|
|
73
|
-
file.write([headers_size].pack('L<')) # Image data address
|
|
74
|
-
file.write([dib_header_size].pack('L<')) # DIB header size
|
|
75
|
-
file.write([width].pack('L<')) # Width
|
|
76
|
-
file.write([height].pack('L<')) # Height
|
|
77
|
-
file.write([1].pack('S<')) # Number of color planes
|
|
78
|
-
file.write([color_depth].pack('S<')) # Color depth
|
|
79
|
-
file.write([0].pack('L<')) # Compression method
|
|
80
|
-
file.write([image_size].pack('L<')) # Image size
|
|
81
|
-
file.write([0].pack('L<')) # Horizontal resolution
|
|
82
|
-
file.write([0].pack('L<')) # Vertical resolution
|
|
83
|
-
file.write([0].pack('L<')) # Number of colors in the color palette
|
|
84
|
-
file.write([0].pack('L<')) # Number of important colors used
|
|
85
|
-
image.each_row.reverse_each { |row| file.write((row.map { |x| [x.blue, x.green, x.red, x.alpha] }.flatten).pack(pack_format)) }
|
|
86
|
-
file
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
# <code>SpecialInputDevice::DamagedImageError</code> occur when loading a image which contain contradiction. For
|
|
2
|
-
# example, the image size from header of BMP file and file system do not match.
|
|
3
|
-
class SpecialInputDevice::DamagedImageError < SpecialInputDevice::ImageError
|
|
4
|
-
end
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
# <code>Table2D</code> object is a container which act like a two dimensional array.
|
|
2
|
-
class SpecialInputDevice::Table2D
|
|
3
|
-
|
|
4
|
-
include(Enumerable)
|
|
5
|
-
|
|
6
|
-
# @return [Fixnum] the width of table
|
|
7
|
-
attr_reader(:width)
|
|
8
|
-
|
|
9
|
-
# @return [Fixnum] the height of table
|
|
10
|
-
attr_reader(:height)
|
|
11
|
-
|
|
12
|
-
# @!scope class
|
|
13
|
-
# @overload new(width, height, default = nil, &block)
|
|
14
|
-
# @param [Integer] width the width of table
|
|
15
|
-
# @param [Integer] height the height of table
|
|
16
|
-
# @param [Object] default the default value
|
|
17
|
-
# @param [Proc] block initializer of the table
|
|
18
|
-
# @yield [x, y] initializer of the table
|
|
19
|
-
# @yieldparam [Integer] x the x coordinate
|
|
20
|
-
# @yieldparam [Integer] y the y coordinate
|
|
21
|
-
# @yieldreturn [Object] the value to be stored
|
|
22
|
-
def initialize(width, height, default = nil, &block)
|
|
23
|
-
@width = width
|
|
24
|
-
@height = height
|
|
25
|
-
@data = Array.new(width) do |x0|
|
|
26
|
-
Array.new(height) do |x1|
|
|
27
|
-
value = if block
|
|
28
|
-
yield x0, x1
|
|
29
|
-
else
|
|
30
|
-
default
|
|
31
|
-
end
|
|
32
|
-
validate(x0, x1, value)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# @param [Integer] x the x coordinate
|
|
38
|
-
# @param [Integer] y the y coordinate
|
|
39
|
-
# @return [Object] the object at the specific coordinate
|
|
40
|
-
def [](x, y)
|
|
41
|
-
raise(RangeError, "The table only has #{@height} row. The row at #{y} cannot be accessed.") unless (-@height...@height).include?(y)
|
|
42
|
-
raise(RangeError, "The table only has #{@width} column. The column at #{x} cannot be accessed") unless (-@width...@width).include?(x)
|
|
43
|
-
@data[x][y]
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# @param [Integer] x the x coordinate
|
|
47
|
-
# @param [Integer] y the y coordinate
|
|
48
|
-
# @param [Object] value the new value
|
|
49
|
-
# @return [Object] the new value
|
|
50
|
-
def []=(x, y, value)
|
|
51
|
-
raise(RangeError, "The table only has #{@height} row. The row at #{y} cannot be accessed.") unless (-@height...@height).include?(y)
|
|
52
|
-
raise(RangeError, "The table only has #{@width} column. The column at #{x} cannot be accessed") unless (-@width...@width).include?(x)
|
|
53
|
-
validate(x, y, value)
|
|
54
|
-
@data[x][y] = value
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
# @param [Integer] x the x coordinate
|
|
58
|
-
# @param [Integer] y the y coordinate
|
|
59
|
-
# @return [Object] the object at the specific coordinate
|
|
60
|
-
def try_get(x, y)
|
|
61
|
-
self[x, y] if (-@width...@width).include?(x) && (-@height...@height).include?(y)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# @param [Integer] x the x coordinate
|
|
65
|
-
# @param [Integer] y the y coordinate
|
|
66
|
-
# @param [Object] value the new value
|
|
67
|
-
# @return [Object] the new value
|
|
68
|
-
def try_set(x, y, value)
|
|
69
|
-
self[x, y] = value if (-@width...@width).include?(x) && (-@height...@height).include?(y)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# @param [Proc] block the action
|
|
73
|
-
# @yield [value, position] the action
|
|
74
|
-
# @yieldparam [Object] value the value
|
|
75
|
-
# @yieldparam [SpecialInputDevice::Point] position the position of the value
|
|
76
|
-
# @yieldreturn [Object] value will be ignored
|
|
77
|
-
# @return [Enumerator, SpecialInputDevice::Table2D] a Enumerator if no block gavin, self otherwise.
|
|
78
|
-
def each(&block)
|
|
79
|
-
if block
|
|
80
|
-
@data.each.with_index do |v0, i0|
|
|
81
|
-
v0.each.with_index do |v1, i1|
|
|
82
|
-
yield v1, SpecialInputDevice::Point.new(i0, i1)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
self
|
|
86
|
-
else
|
|
87
|
-
Enumerator.new(self)
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# @param [Proc] block the action
|
|
92
|
-
# @yield [row] the action
|
|
93
|
-
# @yieldparam [Array<Object>] row the row
|
|
94
|
-
# @yieldreturn [Object] value will be ignored
|
|
95
|
-
# @return [Enumerator, SpecialInputDevice::Table2D] a Enumerator if no block gavin, self otherwise.
|
|
96
|
-
def each_row(&block)
|
|
97
|
-
enumerator = :zip.to_proc.call(*@data).each(&block)
|
|
98
|
-
block ? self : enumerator
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# @param [Proc] block the action
|
|
102
|
-
# @yield [column] the action
|
|
103
|
-
# @yieldparam [Array<Object>] column the column
|
|
104
|
-
# @yieldreturn [Object] value will be ignored
|
|
105
|
-
# @return [Enumerator, SpecialInputDevice::Table2D] a Enumerator if no block gavin, self otherwise.
|
|
106
|
-
def each_column(&block)
|
|
107
|
-
enumerator = @data.each(&block)
|
|
108
|
-
block ? self : enumerator
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
# @param [Integer] y the y coordinate
|
|
112
|
-
# @param [Proc] block the action
|
|
113
|
-
# @yield [value] the action
|
|
114
|
-
# @yieldparam [Object] value the value
|
|
115
|
-
# @yieldreturn [Object] value will be ignored
|
|
116
|
-
# @return [Enumerator, SpecialInputDevice::Table2D] a Enumerator if no block gavin, self otherwise.
|
|
117
|
-
def each_in_row(y, &block)
|
|
118
|
-
raise(RangeError, "The table only has #{@height} row. The row at #{y} cannot be accessed.") unless (-@height...@height).include?(y)
|
|
119
|
-
enumerator = @data.map { |x| x[y] }.each(&block)
|
|
120
|
-
block ? self : enumerator
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# @param [Integer] x the x coordinate
|
|
124
|
-
# @param [Proc] block the action
|
|
125
|
-
# @yield [value] the action
|
|
126
|
-
# @yieldparam [Object] value the value
|
|
127
|
-
# @yieldreturn [Object] value will be ignored
|
|
128
|
-
# @return [Enumerator, SpecialInputDevice::Table2D] a Enumerator if no block gavin, self otherwise.
|
|
129
|
-
def each_in_column(x, &block)
|
|
130
|
-
raise(RangeError, "The table only has #{@width} column. The column at #{x} cannot be accessed") unless (-@width...@width).include?(x)
|
|
131
|
-
enumerator = @data[x].each(&block)
|
|
132
|
-
block ? self : enumerator
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# @param [Proc] block the mapper
|
|
136
|
-
# @yield [value, position] the mapper
|
|
137
|
-
# @yieldparam [Object] value the value
|
|
138
|
-
# @yieldparam [SpecialInputDevice::Point] position an array included x and y
|
|
139
|
-
# @yieldreturn [Object] the value to be stored
|
|
140
|
-
# @return [Enumerator, SpecialInputDevice::Table2D] a Enumerator if no block gavin, self otherwise.
|
|
141
|
-
def map(&block)
|
|
142
|
-
(0...width).each { |x0| (0...height).each { |x1| self[x0, x1] = yield self[x0, x1], SpecialInputDevice::Point.new(x0, x1) } }
|
|
143
|
-
block ? self : Enumerator.new(self, :map)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# Override this method if validation is needed. In this method, raise an <code>Exception</code> if it is not valid.
|
|
147
|
-
# @param [Integer] x the x coordinate
|
|
148
|
-
# @param [Integer] y the y coordinate
|
|
149
|
-
# @param [Object] value the object at the specific coordinate
|
|
150
|
-
# @return [Object] the value to be stored
|
|
151
|
-
def validate(x, y, value)
|
|
152
|
-
value
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
protected(:validate)
|
|
156
|
-
|
|
157
|
-
end
|
data/stab/keyboard.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# noinspection ALL
|
|
2
|
-
module SpecialInputDevice::Keyboard
|
|
3
|
-
|
|
4
|
-
class << self
|
|
5
|
-
|
|
6
|
-
# Simulate holding the specified key down.
|
|
7
|
-
# @param [Integer] key_code virtual key code. Use a value of constant in {SpecialInputDevice::KeyCode}.
|
|
8
|
-
# @return [Module] self
|
|
9
|
-
# @see SpecialInputDevice::Window#key_hold
|
|
10
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
11
|
-
def hold(key_code)
|
|
12
|
-
# This is a stub, used for indexing
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# Simulate pressing the specified key.
|
|
16
|
-
# @param [Integer] key_code virtual key code. Use a value of constant in {SpecialInputDevice::KeyCode}.
|
|
17
|
-
# @return [Module] self
|
|
18
|
-
# @see SpecialInputDevice::Window#key_press
|
|
19
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
20
|
-
def press(key_code)
|
|
21
|
-
# This is a stub, used for indexing
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Simulate releasing the specified key.
|
|
25
|
-
# @param [Integer] key_code virtual key code. Use a value of constant in {SpecialInputDevice::KeyCode}.
|
|
26
|
-
# @return [Module] self
|
|
27
|
-
# @see SpecialInputDevice::Window#key_release
|
|
28
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
29
|
-
def release(key_code)
|
|
30
|
-
# This is a stub, used for indexing
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
data/stab/mouse.rb
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
# noinspection ALL
|
|
2
|
-
module SpecialInputDevice::Mouse
|
|
3
|
-
|
|
4
|
-
class << self
|
|
5
|
-
|
|
6
|
-
# Lock the mouse.
|
|
7
|
-
# @return [Module] self
|
|
8
|
-
def lock
|
|
9
|
-
# This is a stub, used for indexing
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# Unlock the mouse.
|
|
13
|
-
# @return [Module] self
|
|
14
|
-
def unlock
|
|
15
|
-
# This is a stub, used for indexing
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# @return [SpecialInputDevice::Point] the point of cursor position
|
|
19
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
20
|
-
def cursor_position
|
|
21
|
-
# This is a stub, used for indexing
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Move the cursor position relative to current position.
|
|
25
|
-
# @param [Integer] x the amount of horizontal motion specified as the number of pixels.
|
|
26
|
-
# @param [Integer] y the amount of vertical motion specified as the number of pixels.
|
|
27
|
-
# @return [Module] self
|
|
28
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
29
|
-
def move_relatively(x, y)
|
|
30
|
-
# This is a stub, used for indexing
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Move the cursor position relative to the upper-left corner of primary screen.
|
|
34
|
-
# @param [Integer] x the x-coordinate of position specified as the number of pixels.
|
|
35
|
-
# @param [Integer] y the y-coordinate of position specified as the number of pixels.
|
|
36
|
-
# @return [Module] self
|
|
37
|
-
# @see SpecialInputDevice::Screen.primary_screen
|
|
38
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
39
|
-
def move_to_primary(x, y)
|
|
40
|
-
# This is a stub, used for indexing
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Move the cursor position relative to the upper-left corner of virtual screen. If the position of virtual screen is
|
|
44
|
-
# inaccessible, the cursor will move to the closest point to the specified position.
|
|
45
|
-
# @param [Integer] x the x-coordinate of position specified as the number of pixels.
|
|
46
|
-
# @param [Integer] y the y-coordinate of position specified as the number of pixels.
|
|
47
|
-
# @return [Module] self
|
|
48
|
-
# @see SpecialInputDevice::Screen.virtual_screen
|
|
49
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
50
|
-
def move_to_virtual(x, y)
|
|
51
|
-
# This is a stub, used for indexing
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Simulate clicking the left button on the mouse.
|
|
55
|
-
# @return [Module] self
|
|
56
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
57
|
-
def left_click
|
|
58
|
-
# This is a stub, used for indexing
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Simulate holding the left button on the mouse down.
|
|
62
|
-
# @return [Module] self
|
|
63
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
64
|
-
def left_down
|
|
65
|
-
# This is a stub, used for indexing
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Simulate releasing the left button on the mouse.
|
|
69
|
-
# @return [Module] self
|
|
70
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
71
|
-
def left_up
|
|
72
|
-
# This is a stub, used for indexing
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Simulate clicking the right button on the mouse.
|
|
76
|
-
# @return [Module] self
|
|
77
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
78
|
-
def right_click
|
|
79
|
-
# This is a stub, used for indexing
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Simulate holding the right button on the mouse down.
|
|
83
|
-
# @return [Module] self
|
|
84
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
85
|
-
def right_down
|
|
86
|
-
# This is a stub, used for indexing
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# Simulate releasing the right button on the mouse.
|
|
90
|
-
# @return [Module] self
|
|
91
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
92
|
-
def right_up
|
|
93
|
-
# This is a stub, used for indexing
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
# Simulate clicking the middle button on the mouse.
|
|
97
|
-
# @return [Module] self
|
|
98
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
99
|
-
def middle_click
|
|
100
|
-
# This is a stub, used for indexing
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
# Simulate holding the middle button on the mouse down.
|
|
104
|
-
# @return [Module] self
|
|
105
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
106
|
-
def middle_down
|
|
107
|
-
# This is a stub, used for indexing
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# Simulate releasing the middle button on the mouse.
|
|
111
|
-
# @return [Module] self
|
|
112
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
113
|
-
def middle_up
|
|
114
|
-
# This is a stub, used for indexing
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Simulate clicking the x1 button on the mouse.
|
|
118
|
-
# @return [Module] self
|
|
119
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
120
|
-
def x1_click
|
|
121
|
-
# This is a stub, used for indexing
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Simulate holding the x1 button on the mouse down.
|
|
125
|
-
# @return [Module] self
|
|
126
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
127
|
-
def x1_down
|
|
128
|
-
# This is a stub, used for indexing
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# Simulate releasing the x1 button on the mouse.
|
|
132
|
-
# @return [Module] self
|
|
133
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
134
|
-
def x1_up
|
|
135
|
-
# This is a stub, used for indexing
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
# Simulate clicking the x2 button on the mouse.
|
|
139
|
-
# @return [Module] self
|
|
140
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
141
|
-
def x2_click
|
|
142
|
-
# This is a stub, used for indexing
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
# Simulate holding the x2 button on the mouse down.
|
|
146
|
-
# @return [Module] self
|
|
147
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
148
|
-
def x2_down
|
|
149
|
-
# This is a stub, used for indexing
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# Simulate releasing the x2 button on the mouse.
|
|
153
|
-
# @return [Module] self
|
|
154
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
155
|
-
def x2_up
|
|
156
|
-
# This is a stub, used for indexing
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
# Simulate wheeling the scroll backward.
|
|
160
|
-
# @return [Module] self
|
|
161
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
162
|
-
def scroll_wheel_backward
|
|
163
|
-
# This is a stub, used for indexing
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
# Simulate wheeling the scroll forward.
|
|
167
|
-
# @return [Module] self
|
|
168
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
169
|
-
def scroll_wheel_forward
|
|
170
|
-
# This is a stub, used for indexing
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# Simulate wheeling the scroll to left hand side.
|
|
174
|
-
# @return [Module] self
|
|
175
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
176
|
-
def scroll_wheel_to_left
|
|
177
|
-
# This is a stub, used for indexing
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
# Simulate wheeling the scroll to right hand side.
|
|
181
|
-
# @return [Module] self
|
|
182
|
-
# @see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310.aspx Windows Dev Center - SendInput function
|
|
183
|
-
def scroll_wheel_to_right
|
|
184
|
-
# This is a stub, used for indexing
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
end
|