auto_click 0.1.6 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+
2
+ 0.1.9
3
+ Add support for keybaord region specific keys using US-keyboard standard
4
+
5
+ 0.1.8
6
+ Implement key_stroke, key_down and key_up
7
+
8
+ 0.1.7
9
+ Primitive implementation of key_stroke. Need good api before putting it into method list
10
+
11
+ 0.1.6
12
+ Edit changelog and readme.rdoc problem
13
+
1
14
  0.1.4
2
15
  Implement left_drag and right_drag
3
16
 
@@ -12,7 +25,7 @@ Primitive implementation of mouse_move_percentage_absolute_real, mouse_move_perc
12
25
  Specify required ruby environments
13
26
 
14
27
  0.1.0
15
- rewrite the program using dl instead of Win32API
28
+ rewrite the program using DL instead of Win32API
16
29
 
17
30
  0.0.5
18
31
  remove gem dependency requirement.
@@ -1,13 +1,6 @@
1
1
  = AutoClick
2
2
 
3
- Ruby gem for simulating mouse clicks and mouse cursor movement.
4
-
5
- == Description
6
-
7
- Provide several Ruby methods for simulating mouse click and cursor movement in Windows.
8
- This gem use DL library and SendInput method so there is no dependency on FFI, AutoIt or Win32-api.
9
- Currently contains 7 methods (mouse_move(x,y), left_click, right_click, cursor_position, mouse_scroll, left_drag and right drag).
10
- More control over mouse movement such as speed or locus will be implemented in future releases.
3
+ Smulating mouse click, cursor movement and keystrokes
11
4
 
12
5
  == Install
13
6
 
@@ -31,18 +24,61 @@ To show the current cursor position:
31
24
 
32
25
  puts cursor_position
33
26
 
34
- To scroll up (forward) 10 wheel steps
27
+ To scroll up (forward) 10 wheel steps:
35
28
 
36
29
  mouse_scroll(10)
37
30
 
38
- To scroll down (backward) 5 wheel steps
31
+ To scroll down (backward) 5 wheel steps:
39
32
 
40
33
  mouse_scroll(-5)
41
34
 
42
- To drag the icon on (50,50) to (200,300)
35
+ To drag the icon on (50,50) to (200,300):
36
+
43
37
  left_drag(50,50,200,300)
44
38
 
45
-
39
+ To send keystroke 'a':
40
+
41
+ key_stroke('a')
42
+
43
+ To send keystroke tab:
44
+
45
+ key_stroke('tab')
46
+
47
+ Suppose the notepad window on the top left corner of the screen, to type "Auto Click" in notepad (assume that the capslock is off):
48
+
49
+ mouse_move(100,100)
50
+ leftclick
51
+ key_down('shift')
52
+ key_stroke('a')
53
+ key_up('shift')
54
+ key_stroke('u')
55
+ key_stroke('t')
56
+ key_stroke('o')
57
+ key_stroke('space')
58
+ key_stroke('c')
59
+ key_stroke('l')
60
+ key_stroke('i')
61
+ key_stroke('c')
62
+ key_stroke('k')
63
+
64
+ Methods like get_windows("notepad") will be implemented in future release.
65
+ Notice that 'a' means the key 'a' instead of the letter 'a'. Therefore key_stroke('a') and key_stroke('A') is basically the same. If the capslock is off but you want to type the capitalized A, you need to:
66
+
67
+ key_down('shift')
68
+ key_stroke('a')
69
+ key_up('shift')
70
+
71
+ A list of key stroke names will be included in the readme later. 'a' to 'z', 'num0' to 'num9', 'f1' to 'f12', 'shift' 'ctrl' 'alt' 'win' 'tab' 'del' 'ins' 'return' 'esc' 'pageup' 'pagedown' 'left' 'right' 'up' 'down' 'equal' 'hyphen'......etc are all acceptable key names.
72
+
73
+ If you know the virtual key code you can directly enter the key code, for example:
74
+
75
+ key_stroke(0x41)
76
+
77
+ is the same as
78
+
79
+ key_stroke('a')
80
+
81
+
46
82
  == Method List
47
83
 
48
84
  - left_click
@@ -53,11 +89,29 @@ To drag the icon on (50,50) to (200,300)
53
89
 
54
90
  - mouse_move(x,y)
55
91
 
56
- - mouse_scroll(d)
92
+ - mouse_scroll(step)
57
93
 
58
94
  - left_drag(sx,sy,ex,ey)
59
95
 
60
96
  - right_drag(sx,sy,ex,ey)
97
+
98
+ - key_stroke(key_name)
99
+
100
+ - key_down(key_name)
101
+
102
+ - key_up(key_name)
103
+
104
+
105
+ == Change log (for full change log please refer to the CHANGELOG file in the repository
106
+
107
+ - 0.1.9 Add support for keybaord region specific keys using US-keyboard standard
108
+
109
+ - 0.1.8 Implement key_stroke, key_down and key_up
110
+
111
+ - 0.1.7 Primitive implementation of key_stroke. Need good api before putting it into method list
112
+
113
+ - 0.1.4 Implement left_drag and right_drag
114
+
61
115
 
62
116
  == Tested with
63
117
 
@@ -9,8 +9,12 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["erinata"]
10
10
  s.email = ["erinata@gmail.com"]
11
11
  s.homepage = ""
12
- s.summary = %q{Smulating mouse click and cursor movement}
13
- s.description = %q{Provide several Ruby methods for simulating mouse click and cursor movement in Windows. This gem use DL library and SendInput method so there is no dependency on FFI, AutoIt or Win32-api. Currently contains 7 methods (mouse_move(x,y), left_click, right_click, cursor_position, mouse_scroll, left_drag and right drag). More control over mouse movement such as speed or locus will be implemented in future releases.}
12
+ s.summary = %q{Smulating mouse click, cursor movement and keystrokes}
13
+ s.description = %q{Provide several Ruby methods for simulating mouse click, cursor movement and keystrokes in Windows.
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, cursor_position, mouse_scroll, key_up, key_down...etc.
16
+ See https://github.com/erinata/auto_click for more details.
17
+ (More control over mouse movement such as speed or locus will be implemented in future releases)}
14
18
 
15
19
  s.required_ruby_version = '>= 1.9.0'
16
20
 
@@ -1,5 +1,6 @@
1
1
  require 'dl/import'
2
2
  require 'auto_click/input_structure'
3
+ require 'auto_click/virtual_key'
3
4
  require 'auto_click/user32'
4
5
 
5
6
  module AutoClick
@@ -83,6 +84,27 @@ module AutoClick
83
84
  send_input( [@@rightup] )
84
85
  sleep 0.1
85
86
  end
87
+
88
+ def key_stroke(key)
89
+ code=VirtualKey.code_from_string(key)
90
+ send_input([InputStructure.keyboard_input(code,0x0000),
91
+ InputStructure.keyboard_input(code,0x0002)])
92
+ end
93
+
94
+ def key_down(key)
95
+ code=VirtualKey.code_from_string(key)
96
+ send_input([InputStructure.keyboard_input(code,0x0000)])
97
+ end
98
+
99
+ def key_up(key)
100
+ code=VirtualKey.code_from_string(key)
101
+ send_input([InputStructure.keyboard_input(code,0x0002)])
102
+ end
103
+
104
+ def type(string)
105
+ puts string
106
+ end
107
+
86
108
  end
87
109
 
88
110
 
@@ -11,4 +11,14 @@ module InputStructure
11
11
  end
12
12
 
13
13
 
14
+ def self.keyboard_input(wVk,dw_flags)
15
+ ki = Array.new(7, 0)
16
+ ki[0] = 1
17
+ ki[1] = wVk
18
+ ki[2] = dw_flags
19
+ ki.pack('LLLLLLL')
20
+ end
21
+
22
+
23
+
14
24
  end
@@ -1,3 +1,3 @@
1
1
  module AutoClick
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -0,0 +1,529 @@
1
+ module VirtualKey
2
+ def self.code_from_string(string)
3
+
4
+ if string.kind_of? Fixnum
5
+ return string
6
+ elsif string.kind_of? String
7
+ string=string.delete('_').delete('-').delete(' ')
8
+ end
9
+ string = string.to_sym.downcase
10
+ case string
11
+ #when
12
+ # 0x00S
13
+ #when
14
+ # 0x01
15
+ #when
16
+ # 0x02
17
+ #when
18
+ # 0x03
19
+ #when
20
+ # 0x04
21
+ #when
22
+ # 0x05
23
+ #when
24
+ # 0x06
25
+ #when
26
+ # 0x07
27
+ when :back,:backspace
28
+ 0x08
29
+ when :tab
30
+ 0x09
31
+ #when
32
+ # 0x0A
33
+ #when
34
+ # 0x0B
35
+ when :clear
36
+ 0x0C
37
+ when :return,:enter
38
+ 0x0D
39
+ #when
40
+ # 0x0E
41
+ #when
42
+ # 0x0F
43
+ when :shift
44
+ 0x10
45
+ when :ctrl,:control
46
+ 0x11
47
+ when :alt,:alternate
48
+ 0x12
49
+ when :pause
50
+ 0x13
51
+ when :cap,:capslock,:caplock
52
+ 0x14
53
+ #when
54
+ # 0x15
55
+ #when
56
+ # 0x16
57
+ #when
58
+ # 0x17
59
+ #when
60
+ # 0x18
61
+ #when
62
+ # 0x19
63
+ #when
64
+ # 0x1A
65
+ when :esc,:escape
66
+ 0x1B
67
+ #when
68
+ # 0x1C
69
+ #when
70
+ # 0x1D
71
+ #when
72
+ # 0x1E
73
+ #when
74
+ # 0x1F
75
+ when :space,:spacebar
76
+ 0x20
77
+ when :pageup
78
+ 0x21
79
+ when :pagedown
80
+ 0x22
81
+ when :end
82
+ 0x23
83
+ when :home
84
+ 0x24
85
+ when :left,:leftarrow,:leftkey
86
+ 0x25
87
+ when :up,:uparrow,:upkey
88
+ 0x26
89
+ when :right,:rightarrow,:rightkey
90
+ 0x27
91
+ when :down,:downarrow,:downkey
92
+ 0x28
93
+ when :select
94
+ 0x29
95
+ when :print
96
+ 0x2A
97
+ when :exe,:execute
98
+ 0x2B
99
+ when :printscr,:printscreen
100
+ 0x2C
101
+ when :ins,:insert
102
+ 0x2D
103
+ when :del,:delete
104
+ 0x2E
105
+ when :help
106
+ 0x2F
107
+ when :num0,:number0
108
+ 0x30
109
+ when :num1,:number1
110
+ 0x31
111
+ when :num2,:number2
112
+ 0x32
113
+ when :num3,:number3
114
+ 0x33
115
+ when :num4,:number4
116
+ 0x34
117
+ when :num5,:number5
118
+ 0x35
119
+ when :num6,:number6
120
+ 0x36
121
+ when :num7,:number7
122
+ 0x37
123
+ when :num8,:number8
124
+ 0x38
125
+ when :num9,:number9
126
+ 0x39
127
+ #when
128
+ # 0x3A
129
+ #when
130
+ # 0x3B
131
+ #when
132
+ # 0x3C
133
+ #when
134
+ # 0x3D
135
+ #when
136
+ # 0x3E
137
+ #when
138
+ # 0x3F
139
+ #when
140
+ # 0x40
141
+ when :a
142
+ 0x41
143
+ when :b
144
+ 0x42
145
+ when :c
146
+ 0x43
147
+ when :d
148
+ 0x44
149
+ when :e
150
+ 0x45
151
+ when :f
152
+ 0x46
153
+ when :g
154
+ 0x47
155
+ when :h
156
+ 0x48
157
+ when :i
158
+ 0x49
159
+ when :j
160
+ 0x4A
161
+ when :k
162
+ 0x4B
163
+ when :l
164
+ 0x4C
165
+ when :m
166
+ 0x4D
167
+ when :n
168
+ 0x4E
169
+ when :o
170
+ 0x4F
171
+ when :p
172
+ 0x50
173
+ when :q
174
+ 0x51
175
+ when :r
176
+ 0x52
177
+ when :s
178
+ 0x53
179
+ when :t
180
+ 0x54
181
+ when :u
182
+ 0x55
183
+ when :v
184
+ 0x56
185
+ when :w
186
+ 0x57
187
+ when :x
188
+ 0x58
189
+ when :y
190
+ 0x59
191
+ when :z
192
+ 0x5A
193
+ when :win, :windows,:leftwin
194
+ 0x5B
195
+ when :rightwin
196
+ 0x5C
197
+ when :app,:application
198
+ 0x5D
199
+ #when
200
+ # 0x5E
201
+ when :sleep
202
+ 0x5F
203
+ when :numpad0,:numberpad0
204
+ 0x60
205
+ when :numpad1,:numberpad1
206
+ 0x61
207
+ when :numpad2,:numberpad2
208
+ 0x62
209
+ when :numpad3,:numberpad3
210
+ 0x63
211
+ when :numpad4,:numberpad4
212
+ 0x64
213
+ when :numpad5,:numberpad5
214
+ 0x65
215
+ when :numpad6,:numberpad6
216
+ 0x66
217
+ when :numpad7,:numberpad7
218
+ 0x67
219
+ when :numpad8,:numberpad8
220
+ 0x68
221
+ when :numpad9,:numberpad9
222
+ 0x69
223
+ when :multiply,:multiplication
224
+ 0x6A
225
+ when :add,:addition
226
+ 0x6B
227
+ when :separator
228
+ 0x6C
229
+ when :substract,:subtraction
230
+ 0x6D
231
+ when :decimal
232
+ 0x6E
233
+ when :divide,:division
234
+ 0x6F
235
+ when :f1
236
+ 0x70
237
+ when :f2
238
+ 0x71
239
+ when :f3
240
+ 0x72
241
+ when :f4
242
+ 0x73
243
+ when :f5
244
+ 0x74
245
+ when :f6
246
+ 0x75
247
+ when :f7
248
+ 0x76
249
+ when :f8
250
+ 0x77
251
+ when :f9
252
+ 0x78
253
+ when :f10
254
+ 0x79
255
+ when :f11
256
+ 0x7A
257
+ when :f12
258
+ 0x7B
259
+ when :f13
260
+ 0x7C
261
+ when :f14
262
+ 0x7D
263
+ when :f15
264
+ 0x7E
265
+ when :f16
266
+ 0x7F
267
+ when :f17
268
+ 0x80
269
+ when :f18
270
+ 0x81
271
+ when :f19
272
+ 0x82
273
+ when :f20
274
+ 0x83
275
+ when :f21
276
+ 0x84
277
+ when :f22
278
+ 0x85
279
+ when :f23
280
+ 0x86
281
+ when :f24
282
+ 0x87
283
+ #when
284
+ # 0x88
285
+ #when
286
+ # 0x89
287
+ #when
288
+ # 0x8A
289
+ #when
290
+ # 0x8B
291
+ #when
292
+ # 0x8C
293
+ #when
294
+ # 0x8D
295
+ #when
296
+ # 0x8E
297
+ #when
298
+ # 0x8F
299
+ when :numlock,:numberlock
300
+ 0x90
301
+ when :scroll,:scrolllock
302
+ 0x91
303
+ #when
304
+ # 0x92
305
+ #when
306
+ # 0x93
307
+ #when
308
+ # 0x94
309
+ #when
310
+ # 0x95
311
+ #when
312
+ # 0x96
313
+ #when
314
+ # 0x97
315
+ #when
316
+ # 0x98
317
+ #when
318
+ # 0x99
319
+ #when
320
+ # 0x9A
321
+ #when
322
+ # 0x9B
323
+ #when
324
+ # 0x9C
325
+ #when
326
+ # 0x9D
327
+ #when
328
+ # 0x9E
329
+ #when
330
+ # 0x9F
331
+ when :leftshift
332
+ 0xA0
333
+ when :rightshift
334
+ 0xA1
335
+ when :leftcontrol,:leftctrl
336
+ 0xA2
337
+ when :rightcontrol,:rightctrl
338
+ 0xA3
339
+ when :menu,:leftmenu
340
+ 0xA4
341
+ when :rightmenu
342
+ 0xA5
343
+ when :browserback
344
+ 0xA6
345
+ when :browserforward
346
+ 0xA7
347
+ when :browserrefresh
348
+ 0xA8
349
+ when :browserstop
350
+ 0xA9
351
+ when :browsersearch
352
+ 0xAA
353
+ when :browserfav,:browserfavourites
354
+ 0xAB
355
+ when :browserstart,:browserhome
356
+ 0xAC
357
+ when :mute,:volmute,:volumemute
358
+ 0xAD
359
+ when :voldown,:volumedown
360
+ 0xAE
361
+ when :volup,:volumeup
362
+ 0xAF
363
+ when :nexttrack
364
+ 0xB0
365
+ when :previoustrack
366
+ 0xB1
367
+ when :mediastop
368
+ 0xB2
369
+ when :mediaplay,:mediapause
370
+ 0xB3
371
+ when :mail
372
+ 0xB4
373
+ when :mediaselect
374
+ 0xB5
375
+ when :app1,:application1
376
+ 0xB6
377
+ when :app2,:application2
378
+ 0xB7
379
+ #when
380
+ # 0xB8
381
+ #when
382
+ # 0xB9
383
+ when :semicolon,:colon
384
+ 0xBA
385
+ when :equal, :plus
386
+ 0xBB
387
+ when :comma, :smallerthan
388
+ 0xBC
389
+ when :hyphen,:underscore,:understrike
390
+ 0xBD
391
+ when :period, :dot, :greaterthan
392
+ 0xBE
393
+ when :slash,:question,:questionmark,:forwardslash
394
+ 0xBF
395
+ when :grave, :graveaccent, :tilde,:leftquote
396
+ 0xC0
397
+ #when
398
+ # 0xC1
399
+ #when
400
+ # 0xC2
401
+ #when
402
+ # 0xC3
403
+ #when
404
+ # 0xC4
405
+ #when
406
+ # 0xC5
407
+ #when
408
+ # 0xC6
409
+ #when
410
+ # 0xC7
411
+ #when
412
+ # 0xC8
413
+ #when
414
+ # 0xC9
415
+ #when
416
+ # 0xCA
417
+ #when
418
+ # 0xCB
419
+ #when
420
+ # 0xCC
421
+ #when
422
+ # 0xCD
423
+ #when
424
+ # 0xCE
425
+ #when
426
+ # 0xCF
427
+ #when
428
+ # 0xD0
429
+ #when
430
+ # 0xD1
431
+ #when
432
+ # 0xD2
433
+ #when
434
+ # 0xD3
435
+ #when
436
+ # 0xD4
437
+ #when
438
+ # 0xD5
439
+ #when
440
+ # 0xD6
441
+ #when
442
+ # 0xD7
443
+ #when
444
+ # 0xD8
445
+ #when
446
+ # 0xD9
447
+ #when
448
+ # 0xDA
449
+ when :openbranket, :leftbranket, :opensquarebranket, :leftsquarebranket, :squarebranket
450
+ 0xDB
451
+ when :pipe, :pipes, :bar, :brokenbar, :backslash
452
+ 0xDC
453
+ when :closebranket, :closesquarebranket, :rightbranket, :rightsquarebranket
454
+ 0xDD
455
+ when :quote,:singlequote,:doublequote, :rightquote
456
+ 0xDE
457
+ #when
458
+ # 0xDF
459
+ #when
460
+ # 0xE0
461
+ #when
462
+ # 0xE1
463
+ #when
464
+ # 0xE2
465
+ #when
466
+ # 0xE3
467
+ #when
468
+ # 0xE4
469
+ #when
470
+ # 0xE5
471
+ #when
472
+ # 0xE6
473
+ #when
474
+ # 0xE7
475
+ #when
476
+ # 0xE8
477
+ #when
478
+ # 0xE9
479
+ #when
480
+ # 0xEA
481
+ #when
482
+ # 0xEB
483
+ #when
484
+ # 0xEC
485
+ #when
486
+ # 0xED
487
+ #when
488
+ # 0xEE
489
+ #when
490
+ # 0xEF
491
+ #when
492
+ # 0xF0
493
+ #when
494
+ # 0xF1
495
+ #when
496
+ # 0xF2
497
+ #when
498
+ # 0xF3
499
+ #when
500
+ # 0xF4
501
+ #when
502
+ # 0xF5
503
+ #when
504
+ # 0xF6
505
+ #when
506
+ # 0xF7
507
+ #when
508
+ # 0xF8
509
+ #when
510
+ # 0xF9
511
+ when :play
512
+ 0xFA
513
+ when :zoom
514
+ 0xFB
515
+ #when
516
+ # 0xFC
517
+ #when
518
+ # 0xFD
519
+ #when
520
+ # 0xFE
521
+ #when
522
+ # 0xFF
523
+ else 0
524
+ end
525
+
526
+
527
+ end
528
+
529
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - erinata
@@ -18,7 +18,12 @@ date: 2011-01-03 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
- description: Provide several Ruby methods for simulating mouse click and cursor movement in Windows. This gem use DL library and SendInput method so there is no dependency on FFI, AutoIt or Win32-api. Currently contains 7 methods (mouse_move(x,y), left_click, right_click, cursor_position, mouse_scroll, left_drag and right drag). More control over mouse movement such as speed or locus will be implemented in future releases.
21
+ description: |-
22
+ Provide several Ruby methods for simulating mouse click, cursor movement and keystrokes in Windows.
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, cursor_position, mouse_scroll, key_up, key_down...etc.
25
+ See https://github.com/erinata/auto_click for more details.
26
+ (More control over mouse movement such as speed or locus will be implemented in future releases)
22
27
  email:
23
28
  - erinata@gmail.com
24
29
  executables: []
@@ -39,6 +44,7 @@ files:
39
44
  - lib/auto_click/input_structure.rb
40
45
  - lib/auto_click/user32.rb
41
46
  - lib/auto_click/version.rb
47
+ - lib/auto_click/virtual_key.rb
42
48
  has_rdoc: true
43
49
  homepage: ""
44
50
  licenses: []
@@ -72,6 +78,6 @@ rubyforge_project:
72
78
  rubygems_version: 1.3.7
73
79
  signing_key:
74
80
  specification_version: 3
75
- summary: Smulating mouse click and cursor movement
81
+ summary: Smulating mouse click, cursor movement and keystrokes
76
82
  test_files: []
77
83