special_input_device 0.0.1 → 0.1.0
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/image.c +13 -13
- data/ext/special_input_device/interception.c +151 -7
- data/ext/special_input_device/interception.h +2 -0
- data/ext/special_input_device/keyboard.c +44 -0
- data/ext/special_input_device/keyboard.h +6 -0
- data/ext/special_input_device/mouse.c +22 -20
- data/ext/special_input_device/mouse.h +6 -0
- data/ext/special_input_device/ruby_macro.h +10 -6
- data/ext/special_input_device/screen.c +3 -4
- data/ext/special_input_device/special_input_device.c +36 -1
- data/ext/special_input_device/special_input_device.h +7 -0
- data/ext/special_input_device/window.c +207 -60
- data/lib/special_input_device/color.rb +4 -4
- data/lib/special_input_device/image.rb +2 -1
- data/lib/special_input_device/point.rb +2 -2
- data/lib/special_input_device/rectangle.rb +40 -37
- data/lib/special_input_device/special_input_device.rb +6 -4
- metadata +5 -3
|
@@ -5,54 +5,57 @@ class SpecialInputDevice::Rectangle
|
|
|
5
5
|
|
|
6
6
|
include(SpecialInputDevice::AttributesEqualChecker)
|
|
7
7
|
|
|
8
|
+
# @return [SpecialInputDevice::Point] the position of top-left corner of the rectangle
|
|
9
|
+
attr_reader(:position)
|
|
10
|
+
|
|
8
11
|
# @return [Integer] the height of the rectangle
|
|
9
|
-
attr_reader
|
|
12
|
+
attr_reader(:height)
|
|
10
13
|
# @param [Integer] value the height of the rectangle
|
|
11
14
|
def height=(value)
|
|
12
15
|
@height = value.to_i
|
|
13
16
|
if @height < 0
|
|
14
|
-
@
|
|
15
|
-
@height
|
|
17
|
+
@position = SpecialInputDevice::Point.new(@position.x, @position.y + @height)
|
|
18
|
+
@height = -@height
|
|
16
19
|
end
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
# @return [Integer] the width of the rectangle
|
|
20
|
-
attr_reader
|
|
23
|
+
attr_reader(:width)
|
|
21
24
|
# @param [Integer] value the width of the rectangle
|
|
22
25
|
def width=(value)
|
|
23
26
|
@width = value.to_i
|
|
24
27
|
if @width < 0
|
|
25
|
-
@
|
|
26
|
-
@width
|
|
28
|
+
@position = SpecialInputDevice::Point.new(@position.x + @width, @position.y)
|
|
29
|
+
@width = -@width
|
|
27
30
|
end
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
# @!attribute bottom
|
|
31
34
|
# @return [Integer] the y-coordinate of the bottom edge
|
|
32
35
|
def bottom
|
|
33
|
-
@
|
|
36
|
+
@position.y + @height
|
|
34
37
|
end
|
|
35
38
|
|
|
36
39
|
# @param [Integer] value the y-coordinate of the bottom edge
|
|
37
40
|
def bottom=(value)
|
|
38
|
-
value
|
|
39
|
-
top
|
|
40
|
-
@
|
|
41
|
-
@height
|
|
41
|
+
value = value.to_i
|
|
42
|
+
top = self.top
|
|
43
|
+
@position = SpecialInputDevice::Point.new(@position.y, [top, value].min)
|
|
44
|
+
@height = (value - top).abs
|
|
42
45
|
end
|
|
43
46
|
|
|
44
47
|
# @!attribute left
|
|
45
48
|
# @return [Integer] the x-coordinate of the left edge
|
|
46
49
|
def left
|
|
47
|
-
@
|
|
50
|
+
@position.x
|
|
48
51
|
end
|
|
49
52
|
|
|
50
53
|
# @param [Integer] value the x-coordinate of the left edge
|
|
51
54
|
def left=(value)
|
|
52
|
-
value
|
|
53
|
-
right
|
|
54
|
-
@
|
|
55
|
-
@width
|
|
55
|
+
value = value.to_i
|
|
56
|
+
right = self.right
|
|
57
|
+
@position = SpecialInputDevice::Point.new([value, right].min, @position.y)
|
|
58
|
+
@width = (right - value).abs
|
|
56
59
|
end
|
|
57
60
|
|
|
58
61
|
alias_method(:x, :left)
|
|
@@ -61,29 +64,29 @@ class SpecialInputDevice::Rectangle
|
|
|
61
64
|
# @!attribute right
|
|
62
65
|
# @return [Integer] the x-coordinate of the right edge
|
|
63
66
|
def right
|
|
64
|
-
@
|
|
67
|
+
@position.x + @width
|
|
65
68
|
end
|
|
66
69
|
|
|
67
70
|
# @param [Integer] value the x-coordinate of the right edge
|
|
68
71
|
def right=(value)
|
|
69
|
-
value
|
|
70
|
-
left
|
|
71
|
-
@
|
|
72
|
-
@width
|
|
72
|
+
value = value.to_i
|
|
73
|
+
left = self.left
|
|
74
|
+
@position = SpecialInputDevice::Point.new([left, value].min, @position.y)
|
|
75
|
+
@width = (value - left).abs
|
|
73
76
|
end
|
|
74
77
|
|
|
75
78
|
# @!attribute top
|
|
76
79
|
# @return [Integer] the y-coordinate of the top edge
|
|
77
80
|
def top
|
|
78
|
-
@
|
|
81
|
+
@position.y
|
|
79
82
|
end
|
|
80
83
|
|
|
81
84
|
# @param [Integer] value the y-coordinate of the top edge
|
|
82
85
|
def top=(value)
|
|
83
|
-
value
|
|
84
|
-
bottom
|
|
85
|
-
@
|
|
86
|
-
@height
|
|
86
|
+
value = value.to_i
|
|
87
|
+
bottom = self.bottom
|
|
88
|
+
@position = SpecialInputDevice::Point.new(@position.x, [value, bottom].min)
|
|
89
|
+
@height = (bottom - value).abs
|
|
87
90
|
end
|
|
88
91
|
|
|
89
92
|
alias_method(:y, :top)
|
|
@@ -108,19 +111,19 @@ class SpecialInputDevice::Rectangle
|
|
|
108
111
|
def initialize(*arguments)
|
|
109
112
|
case count = arguments.size
|
|
110
113
|
when 2
|
|
111
|
-
@
|
|
112
|
-
raise(TypeError, "Expecting SpecialInputDevice::Point, #{@
|
|
114
|
+
@position = arguments[0]
|
|
115
|
+
raise(TypeError, "Expecting SpecialInputDevice::Point, #{@position.class} gavin") unless @position.is_a? SpecialInputDevice::Point
|
|
113
116
|
end_point = arguments[1]
|
|
114
117
|
raise(TypeError, "Expecting SpecialInputDevice::Point, #{end_point.class} gavin") unless end_point.is_a? SpecialInputDevice::Point
|
|
115
|
-
self.width = end_point.x - @
|
|
116
|
-
self.height = end_point.y - @
|
|
118
|
+
self.width = end_point.x - @position.x
|
|
119
|
+
self.height = end_point.y - @position.y
|
|
117
120
|
when 3
|
|
118
|
-
@
|
|
119
|
-
raise(TypeError, "Expecting SpecialInputDevice::Point, #{@
|
|
121
|
+
@position = arguments[0]
|
|
122
|
+
raise(TypeError, "Expecting SpecialInputDevice::Point, #{@position.class} gavin") unless @position.is_a? SpecialInputDevice::Point
|
|
120
123
|
self.width = arguments[1]
|
|
121
124
|
self.height = arguments[2]
|
|
122
125
|
when 4
|
|
123
|
-
@
|
|
126
|
+
@position = SpecialInputDevice::Point.new(arguments[0], arguments[1])
|
|
124
127
|
self.width = arguments[2]
|
|
125
128
|
self.height = arguments[3]
|
|
126
129
|
else
|
|
@@ -143,7 +146,7 @@ class SpecialInputDevice::Rectangle
|
|
|
143
146
|
# @param [Integer] y the relative change of y
|
|
144
147
|
# @return [SpecialInputDevice::Point] the point of top left corner
|
|
145
148
|
def move!(x, y)
|
|
146
|
-
@
|
|
149
|
+
@position = SpecialInputDevice::Point.new(@position.x + x, @position.y + y)
|
|
147
150
|
end
|
|
148
151
|
|
|
149
152
|
# Moves the rectangle absolutely without changing the size.
|
|
@@ -161,7 +164,7 @@ class SpecialInputDevice::Rectangle
|
|
|
161
164
|
# @param [Integer] y new y-coordinate
|
|
162
165
|
# @return [SpecialInputDevice::Point] the point of top left corner
|
|
163
166
|
def move_to!(x, y)
|
|
164
|
-
@
|
|
167
|
+
@position = SpecialInputDevice::Point.new(x, y)
|
|
165
168
|
end
|
|
166
169
|
|
|
167
170
|
# @return [Array(Integer, Integer)] width and height in an array
|
|
@@ -171,12 +174,12 @@ class SpecialInputDevice::Rectangle
|
|
|
171
174
|
|
|
172
175
|
# @!visibility private
|
|
173
176
|
def inspect
|
|
174
|
-
"<upper-left: #{@
|
|
177
|
+
"<upper-left: #{@position.inspect}, bottom-right: #{SpecialInputDevice::Point.new(right, bottom).inspect}, width: #{width}, height: #{height}>"
|
|
175
178
|
end
|
|
176
179
|
|
|
177
180
|
# @!visibility private
|
|
178
181
|
def to_a
|
|
179
|
-
@
|
|
182
|
+
@position.to_a << width << height
|
|
180
183
|
end
|
|
181
184
|
|
|
182
185
|
# @!visibility private
|
|
@@ -31,11 +31,13 @@ module SpecialInputDevice
|
|
|
31
31
|
class << self
|
|
32
32
|
|
|
33
33
|
# @see SpecialInputDevice::MODE
|
|
34
|
-
# @return [Symbol]
|
|
35
|
-
|
|
34
|
+
# @return [Symbol] the simulation mode
|
|
35
|
+
attr_accessor(:mode)
|
|
36
36
|
# @see SpecialInputDevice::COLOR_COMPARE_METHOD
|
|
37
|
-
# @return [Symbol]
|
|
38
|
-
|
|
37
|
+
# @return [Symbol] the color compare method
|
|
38
|
+
attr_accessor(:color_compare_method)
|
|
39
|
+
# @return [Array[Fixnum]] scan codes of keys for exiting the script.
|
|
40
|
+
attr_accessor(:exit_keys)
|
|
39
41
|
# Set the simulation mode
|
|
40
42
|
# @param [Symbol] value
|
|
41
43
|
# @return [Symbol]
|
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.1.0
|
|
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-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: tlserver6y@gmail.com
|
|
@@ -31,7 +31,9 @@ files:
|
|
|
31
31
|
- ext/special_input_device/interception.c
|
|
32
32
|
- ext/special_input_device/interception.h
|
|
33
33
|
- ext/special_input_device/keyboard.c
|
|
34
|
+
- ext/special_input_device/keyboard.h
|
|
34
35
|
- ext/special_input_device/mouse.c
|
|
36
|
+
- ext/special_input_device/mouse.h
|
|
35
37
|
- ext/special_input_device/point.c
|
|
36
38
|
- ext/special_input_device/point.h
|
|
37
39
|
- ext/special_input_device/rectangle.c
|
|
@@ -73,5 +75,5 @@ rubyforge_project:
|
|
|
73
75
|
rubygems_version: 2.5.2
|
|
74
76
|
signing_key:
|
|
75
77
|
specification_version: 4
|
|
76
|
-
summary: Simulate mouse or keyboard inputs by program
|
|
78
|
+
summary: Simulate mouse or keyboard inputs by program. This gem only work for Windows.
|
|
77
79
|
test_files: []
|