Module: MouseControl
- Extended by:
- FFI::Library
- Defined in:
- lib/simple_gui_creator/mouse_control.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 (seeing if mouse down currently or not)
0x01
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.total_movements ⇒ Object
Returns the value of attribute total_movements.
132
133
134
|
# File 'lib/simple_gui_creator/mouse_control.rb', line 132
def total_movements
@total_movements
end
|
Class Method Details
.get_mouse_location ⇒ Object
127
128
129
130
|
# File 'lib/simple_gui_creator/mouse_control.rb', line 127
def get_mouse_location
loc = MouseInfo.getPointerInfo.getLocation [loc.x, loc.y]
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
|
# File 'lib/simple_gui_creator/mouse_control.rb', line 62
def jitter_forever_in_own_thread
old_x, old_y = get_mouse_location
Thread.new {
loop {
move_y = 8 cur_x, cur_y = get_mouse_location
if(cur_x == old_x && cur_y == old_y)
@total_movements += 1
move_mouse_relative(0, move_y)
move_mouse_relative(0, move_y * -1)
sleep 0.05
old_x, old_y = get_mouse_location
sleep 0.75
else
old_x, old_y = get_mouse_location
sleep 3
end
}
}
end
|
117
118
119
120
121
122
123
124
|
# File 'lib/simple_gui_creator/mouse_control.rb', line 117
def left_mouse_button_state
GetAsyncKeyState(VK_LBUTTON) if GetAsyncKeyState(VK_LBUTTON) == 0 :up
else
:down
end
end
|
.left_mouse_down! ⇒ Object
107
108
109
|
# File 'lib/simple_gui_creator/mouse_control.rb', line 107
def left_mouse_down!
send_left_mouse_button MOUSEEVENTF_LEFTDOWN
end
|
.left_mouse_up! ⇒ Object
111
112
113
|
# File 'lib/simple_gui_creator/mouse_control.rb', line 111
def left_mouse_up!
send_left_mouse_button MOUSEEVENTF_LEFTUP
end
|
.move_mouse_relative(dx, dy) ⇒ Object
101
102
103
104
105
|
# File 'lib/simple_gui_creator/mouse_control.rb', line 101
def single_click_left_mouse_button
left_mouse_down!
left_mouse_up!
p "CLICKED LEFT MOUSE BUTTON"
end
|