auto_click 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/README.rdoc +25 -0
- data/lib/auto_click.rb +13 -27
- data/lib/auto_click/version.rb +1 -1
- metadata +3 -2
data/CHANGELOG
ADDED
data/README.rdoc
CHANGED
@@ -4,6 +4,31 @@ Ruby gem for simulating mouse clicks and mouse cursor movement.
|
|
4
4
|
|
5
5
|
== Install
|
6
6
|
|
7
|
+
gem install auto_click
|
8
|
+
|
7
9
|
== Usage
|
8
10
|
|
11
|
+
To use the methods provided by auto_click. You need to require it.
|
12
|
+
|
13
|
+
require 'auto_click'
|
14
|
+
|
15
|
+
To move the mouse cursor to 50,50 ( the top left corner is 0,0) and perform a double left click:
|
16
|
+
|
17
|
+
mouse_move(50,50)
|
18
|
+
left_click
|
19
|
+
left_click
|
20
|
+
|
21
|
+
To get the current cursor position:
|
22
|
+
|
23
|
+
cursor_position
|
24
|
+
|
25
|
+
To scroll up 10 wheel steps
|
26
|
+
|
27
|
+
mouse_scroll(10)
|
28
|
+
|
29
|
+
To scroll down 5 wheel steps
|
30
|
+
|
31
|
+
mouse_scroll(-5)
|
32
|
+
|
33
|
+
|
9
34
|
== License
|
data/lib/auto_click.rb
CHANGED
@@ -7,31 +7,11 @@ module AutoClick
|
|
7
7
|
@@gcp = API.new("GetCursorPos",'P','V',"user32")
|
8
8
|
@@scp = API.new('SetCursorPos', 'II', 'V',"user32")
|
9
9
|
@@si = API.new('SendInput','IPI', 'I',"user32")
|
10
|
-
|
11
|
-
|
12
|
-
INPUT_MOUSE = 0
|
13
|
-
MOUSEEVENTF_MOVE = 0x0001
|
14
|
-
MOUSEEVENTF_LEFTDOWN = 0x0002
|
15
|
-
MOUSEEVENTF_LEFTUP = 0x0004
|
16
|
-
MOUSEEVENTF_MIDDLEDOWN = 0x0020
|
17
|
-
MOUSEEVENTF_MIDDLEUP = 0x0040
|
18
|
-
MOUSEEVENTF_RIGHTDOWN = 0x0008
|
19
|
-
MOUSEEVENTF_RIGHTUP = 0x0010
|
20
|
-
MOUSEEVENTF_ABSOLUTE = 0x8000
|
21
|
-
MOUSEEVENTF_WHEEL = 0x0800 # The amount of movement is specified in dwData
|
22
|
-
MOUSEEVENTF_VIRTUALDESK = 0x4000
|
23
|
-
WHEEL_DELTA = 120
|
24
10
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
KEYEVENTF_UNICODE = 0x0004 # If specified, the system synthesizes a VK_PACKET keystroke. The wVk parameter must be zero. This flag can only be combined with the KEYEVENTF_KEYUP flag. For more information, see the Remarks section.
|
30
|
-
|
31
|
-
@@rightdown = InputStructure.mouse_input(0,0,0,MOUSEEVENTF_RIGHTDOWN)
|
32
|
-
@@rightup = InputStructure.mouse_input(0,0,0,MOUSEEVENTF_RIGHTUP)
|
33
|
-
@@leftdown = InputStructure.mouse_input(0,0,0,MOUSEEVENTF_LEFTDOWN)
|
34
|
-
@@leftup = InputStructure.mouse_input(0,0,0,MOUSEEVENTF_LEFTUP)
|
11
|
+
@@rightdown = InputStructure.mouse_input(0,0,0,0x0008)
|
12
|
+
@@rightup = InputStructure.mouse_input(0,0,0,0x0010)
|
13
|
+
@@leftdown = InputStructure.mouse_input(0,0,0,0x0002)
|
14
|
+
@@leftup = InputStructure.mouse_input(0,0,0,0x0004)
|
35
15
|
|
36
16
|
|
37
17
|
def send_input(inputs)
|
@@ -40,7 +20,7 @@ module AutoClick
|
|
40
20
|
@@si.call(n, ptr, inputs[0].size)
|
41
21
|
end
|
42
22
|
|
43
|
-
def
|
23
|
+
def mouse_move(x,y)
|
44
24
|
@@scp.call(x,y)
|
45
25
|
end
|
46
26
|
|
@@ -52,16 +32,22 @@ module AutoClick
|
|
52
32
|
send_input( [@@leftdown, @@leftup] )
|
53
33
|
end
|
54
34
|
|
55
|
-
def
|
35
|
+
def cursor_position
|
56
36
|
point = " " * 8
|
57
37
|
@@gcp.call(point)
|
58
38
|
point.unpack('LL')
|
59
39
|
end
|
40
|
+
|
41
|
+
def mouse_scroll(d)
|
42
|
+
scroll = InputStructure.mouse_input(0,0,d*120,0x0800)
|
43
|
+
send_input( [scroll])
|
44
|
+
end
|
45
|
+
|
60
46
|
|
61
47
|
end
|
62
48
|
|
63
49
|
|
64
|
-
include AutoClick # This line
|
50
|
+
include AutoClick # This line allow auto include when the user require the gem
|
65
51
|
|
66
52
|
|
67
53
|
|
data/lib/auto_click/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- erinata
|
@@ -30,6 +30,7 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- .gitignore
|
32
32
|
- .project
|
33
|
+
- CHANGELOG
|
33
34
|
- Gemfile
|
34
35
|
- README.rdoc
|
35
36
|
- Rakefile
|