auto_click 0.1.12 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,10 @@
1
- 0.1.11
1
+ 0.1.15
2
+ Add more general mouse control methods: mouse_down(keyname), mouse_up(keyname)
3
+
4
+ 0.1.14
5
+ Add middle_click and double_click
6
+
7
+ 0.1.12
2
8
  super ugly implementation of that method type (need refactoring or even rewite later)
3
9
 
4
10
  0.1.10
@@ -1,6 +1,5 @@
1
1
  = AutoClick
2
2
 
3
-
4
3
  Smulating mouse click, cursor movement and keystrokes
5
4
 
6
5
  == Install
@@ -9,45 +8,21 @@ To install auto_click:
9
8
 
10
9
  gem install auto_click
11
10
 
12
- == Method List
13
-
14
- - left_click
15
-
16
- - right_click
17
-
18
- - cursor_position
19
-
20
- - mouse_move(x,y)
21
-
22
- - mouse_scroll(step)
23
-
24
- - left_drag(sx,sy,ex,ey)
25
-
26
- - right_drag(sx,sy,ex,ey)
27
-
28
- - type(string)
29
-
30
- - key_stroke(key_name)
31
-
32
- - key_down(key_name)
33
-
34
- - key_up(key_name)
35
-
36
- == Usage
11
+ == Basic Usage
37
12
 
38
- To use the methods provided by auto_click. You need to require it.
13
+ Using auto_click is easy. To use the methods provided by auto_click. You need to require it.
39
14
 
40
15
  require 'auto_click'
41
16
 
42
17
  To move the mouse cursor to 50,50 ( the top left corner is 0,0) and perform a double left click:
43
18
 
44
19
  mouse_move(50,50)
45
- left_click
46
- left_click
47
-
48
- To show the current cursor position:
20
+ double_click
49
21
 
50
- puts cursor_position
22
+ To move the mouse cursor to 300,300 and perform a right click:
23
+
24
+ mouse_move(50,50)
25
+ right_click
51
26
 
52
27
  To scroll up (forward) 10 wheel steps:
53
28
 
@@ -67,7 +42,7 @@ Suppose the notepad window on the top left corner of the screen, to type "Auto C
67
42
  leftclick
68
43
  type('Auto Click')
69
44
 
70
- The type method will Send keystroke for every characters of the strings. It will ensure that the capslock is off and hold shift when it is typing a capital character.
45
+ The type method will Send keystroke for every characters of the string. It will ensure that the capslock is off and hold shift when it is typing a capital character.
71
46
  Notice that you need to escape the character \ and ' in single quote string, and you need to escape \ " and # in double quote string.
72
47
  For example, to type #''\ , you can either do:
73
48
 
@@ -75,8 +50,24 @@ For example, to type #''\ , you can either do:
75
50
 
76
51
  or
77
52
 
78
- type("\#''\\)
53
+ type("\#''\\")
54
+
55
+ == Advanced Usage
56
+
57
+ The methods shown in Basic Usage is convenient, but sometimes you may need more control on your mouse action and key strokes.
58
+
59
+ To show the current cursor position:
60
+
61
+ puts cursor_position
62
+
63
+ If you wish to left click and hold:
64
+
65
+ mouse_down(:left)
79
66
 
67
+ And remember to release the button later:
68
+
69
+ mouse_up(:left)
70
+
80
71
  To get more refine control of key stroke simulation, you can use the method key_stroke, key_up and key_down methods
81
72
 
82
73
  To send keystroke 'a':
@@ -87,7 +78,7 @@ To send keystroke tab:
87
78
 
88
79
  key_stroke('tab')
89
80
 
90
- Therefore, to type "Auto Click" , you can either use the type method stated before, or you can do:
81
+ Therefore, to type "Auto Click" , you can either use the simple type method stated basic usage section, or you can do:
91
82
 
92
83
  key_down('shift')
93
84
  key_stroke('a')
@@ -96,12 +87,15 @@ Therefore, to type "Auto Click" , you can either use the type method stated befo
96
87
  key_stroke('t')
97
88
  key_stroke('o')
98
89
  key_stroke('space')
90
+ key_down('shift')
99
91
  key_stroke('c')
92
+ key_up('shift')
100
93
  key_stroke('l')
101
94
  key_stroke('i')
102
95
  key_stroke('c')
103
96
  key_stroke('k')
104
97
 
98
+ And you can have detail adjustments to the keyboard behaviour that you need.
105
99
 
106
100
  Notice that 'a' means the key 'a' instead of the letter 'a'. Therefore key_stroke('a') and key_stroke('A') are basically the same. If the capslock is off but you want to type the capitalized A, you need to:
107
101
 
@@ -119,13 +113,60 @@ is the same as
119
113
 
120
114
  key_stroke('a')
121
115
 
116
+ To perform a double_click, instead of using
117
+
118
+ double_click
119
+
120
+ You can use two click calls
121
+
122
+ left_click
123
+ left_click
122
124
 
123
-
124
-
125
+ And of course if for some reasons you need double middle mouse click, you can:
126
+
127
+ middle_click
128
+ middle_click
129
+
130
+ There are some methods which is not discussed here. Please see the following Method List for all the available methods.
131
+
132
+ == Method List
133
+
134
+ - left_click
135
+
136
+ - right_click
137
+
138
+ - middle_click
139
+
140
+ - double_click
141
+
142
+ - mouse_down(button_name)
143
+
144
+ - cursor_position
145
+
146
+ - mouse_move(x,y)
147
+
148
+ - mouse_scroll(step)
149
+
150
+ - left_drag(x_start,y_start,x_end,y_end)
151
+
152
+ - right_drag(x_start,y_start,x_end,y_end)
153
+
154
+ - type(string)
155
+
156
+ - key_stroke(key_name)
157
+
158
+ - key_down(key_name)
159
+
160
+ - key_up(key_name)
161
+
125
162
  == Change log
126
163
  (for full change log please refer to the CHANGELOG file in the repository)
127
164
 
128
- - 0.1.11 Super ugly implementation of that method type (need refactoring or even rewite later)
165
+ - 0.1.15 Add more general mouse control methods: mouse_down(keyname), mouse_up(keyname)
166
+
167
+ - 0.1.14 Add middle_click and double_click
168
+
169
+ - 0.1.12 Super ugly implementation of that method type (need refactoring or even rewite later)
129
170
 
130
171
  - 0.1.10 Implement get_key_state method. Refine the key_stroke, key_down and key_up method
131
172
 
@@ -136,7 +177,6 @@ is the same as
136
177
  - 0.1.7 Primitive implementation of key_stroke. Need good api before putting it into method list
137
178
 
138
179
  - 0.1.4 Implement left_drag and right_drag
139
-
140
180
 
141
181
  == Tested with
142
182
 
@@ -12,14 +12,12 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{Smulating mouse click, cursor movement and keystrokes}
13
13
  s.description = %q{Provide several Ruby methods for simulating mouse click, cursor movement and keystrokes in Windows.
14
14
  This gem use DL library and SendInput method so there is no dependency on FFI, AutoIt or Win32-api.
15
- Methods include mouse_move(x,y), left_click, right_click, mouse_scroll, type, key_up, key_down...etc.
15
+ Methods include mouse_move(x,y), left_click, right_click, type(string), mouse_scroll(steps), key_up, key_down...etc.
16
16
  See https://github.com/erinata/auto_click for more details about instalation and usage.
17
17
  (More control over mouse movement such as speed or locus will be implemented in future releases)}
18
18
 
19
19
  s.required_ruby_version = '>= 1.9.0'
20
20
 
21
- s.executables << 'testing'
22
-
23
21
  s.files = `git ls-files`.split("\n")
24
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
23
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -9,6 +9,8 @@ module AutoClick
9
9
  @@rightup = InputStructure.mouse_input(0,0,0,0x0010)
10
10
  @@leftdown = InputStructure.mouse_input(0,0,0,0x0002)
11
11
  @@leftup = InputStructure.mouse_input(0,0,0,0x0004)
12
+ @@middledown = InputStructure.mouse_input(0,0,0,0x0020)
13
+ @@middleup = InputStructure.mouse_input(0,0,0,0x0040)
12
14
 
13
15
  def send_input(inputs)
14
16
  n = inputs.size
@@ -52,6 +54,37 @@ module AutoClick
52
54
  send_input( [@@leftdown, @@leftup] )
53
55
  end
54
56
 
57
+ def middle_click
58
+ send_input( [@@middledown, @@middleup] )
59
+ end
60
+
61
+ def mouse_down(button_name)
62
+ case button_name
63
+ when :right
64
+ send_input( [@@rightdown] )
65
+ when :middle
66
+ send_input( [@@middledown] )
67
+ else
68
+ send_input( [@@leftdown] )
69
+ end
70
+ end
71
+
72
+ def mouse_up(button_name)
73
+ case button_name
74
+ when :right
75
+ send_input( [@@rightup] )
76
+ when :middle
77
+ send_input( [@@middleup] )
78
+ else
79
+ send_input( [@@leftup] )
80
+ end
81
+ end
82
+
83
+ def double_click
84
+ left_click
85
+ left_click
86
+ end
87
+
55
88
  def cursor_position
56
89
  point = " " * 8
57
90
  User32.GetCursorPos(point)
@@ -10,7 +10,6 @@ module InputStructure
10
10
  mi.pack('LLLLLLL')
11
11
  end
12
12
 
13
-
14
13
  def self.keyboard_input(wVk,dw_flags)
15
14
  ki = Array.new(7, 0)
16
15
  ki[0] = 1
@@ -18,7 +17,6 @@ module InputStructure
18
17
  ki[2] = dw_flags
19
18
  ki.pack('LLLLLLL')
20
19
  end
21
-
22
20
 
23
21
 
24
22
  end
@@ -1,3 +1,3 @@
1
1
  module AutoClick
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.15"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 12
9
- version: 0.1.12
8
+ - 15
9
+ version: 0.1.15
10
10
  platform: ruby
11
11
  authors:
12
12
  - erinata
@@ -14,14 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-04 00:00:00 -06:00
17
+ date: 2011-01-13 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
21
  description: |-
22
22
  Provide several Ruby methods for simulating mouse click, cursor movement and keystrokes in Windows.
23
23
  This gem use DL library and SendInput method so there is no dependency on FFI, AutoIt or Win32-api.
24
- Methods include mouse_move(x,y), left_click, right_click, mouse_scroll, type, key_up, key_down...etc.
24
+ Methods include mouse_move(x,y), left_click, right_click, type(string), mouse_scroll(steps), key_up, key_down...etc.
25
25
  See https://github.com/erinata/auto_click for more details about instalation and usage.
26
26
  (More control over mouse movement such as speed or locus will be implemented in future releases)
27
27
  email: