auto_click 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ test_build.rb
5
+ test_build.rb
6
+ test_run.rb
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>auto_click</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ </buildSpec>
9
+ <natures>
10
+ <nature>com.aptana.ruby.core.rubynature</nature>
11
+ </natures>
12
+ </projectDescription>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in auto_click.gemspec
4
+ gemspec
@@ -0,0 +1,9 @@
1
+ = auto_click
2
+
3
+ Ruby gem for simulating mouse clicks and mouse cursor movement.
4
+
5
+ == Install
6
+
7
+ == Usage
8
+
9
+ == License
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "auto_click/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "auto_click"
7
+ s.version = AutoClick::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["erinata"]
10
+ s.email = ["erinata@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Smulating mouse click and cursor movement in Ruby}
13
+ s.description = %q{Provide several ruby methods for simulating mouse click and cursor movement in Windows. Currently only contains 3 methods (move_mouse(x,y), left_click and right_click).}
14
+
15
+ # s.rubyforge_project = "auto_click"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,74 @@
1
+ require 'win32/api'
2
+ include Win32
3
+ require "auto_click/input_structure"
4
+
5
+ module AutoClick
6
+
7
+ @@gcp = API.new("GetCursorPos",'P','V',"user32")
8
+ @@scp = API.new('SetCursorPos', 'II', 'V',"user32")
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
+
25
+ INPUT_KEYBOARD = 1
26
+ KEYEVENTF_EXTENDEDKEY = 0x0001 # If specified, the scan code was preceded by a prefix byte that has the value 0xE0 (224).
27
+ KEYEVENTF_KEYUP = 0x0002 # If specified, the key is being released. If not specified, the key is being pressed.
28
+ KEYEVENTF_SCANCODE = 0x0008 # If specified, wScan identifies the key and wVk is ignored.
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)
35
+
36
+
37
+ def send_input(inputs)
38
+ n = inputs.size
39
+ ptr = inputs.collect {|i| i.to_s}.join
40
+ @@si.call(n, ptr, inputs[0].size)
41
+ end
42
+
43
+ def move_mouse(x,y)
44
+ @@scp.call(x,y)
45
+ end
46
+
47
+ def right_click
48
+ send_input( [@@rightdown, @@rightup] )
49
+ end
50
+
51
+ def left_click
52
+ send_input( [@@leftdown, @@leftup] )
53
+ end
54
+
55
+ def get_cursor_pos
56
+ point = " " * 8
57
+ @@gcp.call(point)
58
+ point.unpack('LL')
59
+ end
60
+
61
+ end
62
+
63
+
64
+ include AutoClick # This line allo auto include when the user require the gem
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
@@ -0,0 +1,12 @@
1
+ module InputStructure
2
+
3
+ def self.mouse_input(dx,dy,mouse_data,dw_flags)
4
+ mi = Array.new(7, 0)
5
+ mi[0] = 0
6
+ mi[1] = dx
7
+ mi[2] = dy
8
+ mi[3] = mouse_data
9
+ mi[4] = dw_flags
10
+ mi.pack('LLLLLLL')
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Tools
2
+ def self.call_name
3
+ 'Someone'
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module AutoClick
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auto_click
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - erinata
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-26 00:00:00 -06:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Provide several ruby methods for simulating mouse click and cursor movement in Windows. Currently only contains 3 methods (move_mouse(x,y), left_click and right_click).
22
+ email:
23
+ - erinata@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - .project
33
+ - Gemfile
34
+ - README.rdoc
35
+ - Rakefile
36
+ - auto_click.gemspec
37
+ - lib/auto_click.rb
38
+ - lib/auto_click/input_structure.rb
39
+ - lib/auto_click/tools.rb
40
+ - lib/auto_click/version.rb
41
+ has_rdoc: true
42
+ homepage: ""
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.7
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Smulating mouse click and cursor movement in Ruby
73
+ test_files: []
74
+