Module: Mouse
- Extended by:
- FFI::Library
- Defined in:
- lib/mouse.rb
Defined Under Namespace
Classes: Input, InputEvent, MouseInput
Constant Summary
collapse
- MouseInfo =
java.awt.MouseInfo
- MOUSEEVENTF_MOVE =
1
- INPUT_MOUSE =
0
- MOUSEEVENTF_ABSOLUTE =
0x8000
- MOUSEEVENTF_LEFTDOWN =
0x0002
- MOUSEEVENTF_LEFTUP =
0x0004
- VK_LBUTTON =
mouse left button for GetAsyncKeyState
0x01
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.total_movements ⇒ Object
Returns the value of attribute total_movements.
131
132
133
|
# File 'lib/mouse.rb', line 131
def total_movements
@total_movements
end
|
Class Method Details
.get_mouse_location ⇒ Object
127
128
129
|
# File 'lib/mouse.rb', line 127
def get_mouse_location
MouseInfo.getPointerInfo.getLocation
end
|
.jitter_forever_in_own_thread ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/mouse.rb', line 62
def jitter_forever_in_own_thread
myinput = Mouse::Input.new
myinput[:type] = Mouse::INPUT_MOUSE
in_evt = myinput[:evt][:mi]
in_evt[:mouse_data] = 0 in_evt[:flags] = Mouse::MOUSEEVENTF_MOVE
in_evt[:time] = 0
in_evt[:extra] = 0
in_evt[:dx] = 0
in_evt[:dy] = 8
old_x = get_mouse_location.x
old_y = get_mouse_location.y
Thread.new {
loop {
cur_x = get_mouse_location.x
cur_y = get_mouse_location.y
if(cur_x == old_x && cur_y == old_y)
@total_movements += 1
in_evt[:dy] *= -1
SendInput(1, myinput, Mouse::Input.size)
in_evt[:dy] *= -1
sleep 0.05
SendInput(1, myinput, Mouse::Input.size)
old_x = get_mouse_location.x
old_y = get_mouse_location.y
sleep 0.75
else
old_x = get_mouse_location.x
old_y = get_mouse_location.y
sleep 3
end
}
}
end
|
118
119
120
121
122
123
124
125
|
# File 'lib/mouse.rb', line 118
def left_mouse_button_state
GetAsyncKeyState(VK_LBUTTON) if GetAsyncKeyState(VK_LBUTTON) == 0 :up
else
:down
end
end
|
.left_mouse_down! ⇒ Object
108
109
110
|
# File 'lib/mouse.rb', line 108
def left_mouse_down!
change_left_mouse_button MOUSEEVENTF_LEFTDOWN
end
|
.left_mouse_up! ⇒ Object
112
113
114
|
# File 'lib/mouse.rb', line 112
def left_mouse_up!
change_left_mouse_button MOUSEEVENTF_LEFTUP
end
|
102
103
104
105
106
|
# File 'lib/mouse.rb', line 102
def single_click_left_mouse_button
left_mouse_down!
left_mouse_up!
p "CLICKED LEFT MOUSE BUTTON"
end
|