Class: RubyXMacro::Display
- Inherits:
-
Object
- Object
- RubyXMacro::Display
- Defined in:
- lib/rubyxmacro.rb,
ext/rubyxmacro/rubyxmacro.c
Instance Method Summary collapse
-
#click ⇒ Object
Left-click the mouse.
-
#initialize ⇒ Object
constructor
Get a RubyXMacro object with the default display.
-
#keycodeDown(keycode) ⇒ Object
Hold down the key with the value keycode until keycodeUp.
-
#keycodePress(keycode) ⇒ Object
Press and release the key with the value keycode.
-
#keycodeShiftPress(keycode) ⇒ Object
Hold down shift, then press and release the key with the value keycode.
-
#keycodeUp(keycode) ⇒ Object
Release the key with the value keycode.
-
#keyDown(keycode) ⇒ Object
Hold down the key until keyUp.
-
#keyPress(key) ⇒ Object
Press and release the key.
-
#keyUp(keycode) ⇒ Object
Release the key.
-
#mouseDown ⇒ Object
Hold the left mouse button down until mouseUp.
-
#mouseUp ⇒ Object
Release the left mouse button.
-
#moveMouse(x, y) ⇒ Object
Move the mouse pointer to position (x,y).
-
#rightClick ⇒ Object
Right-click the mouse.
-
#rightMouseDown ⇒ Object
Hold the right mouse button down until rightMouseUp.
-
#rightMouseUp ⇒ Object
Release the right mouse button.
-
#sendKeys(keyString) ⇒ Object
Press and release a string of keys.
Constructor Details
#initialize ⇒ Object
Get a RubyXMacro object with the default display. The default display is stored in the $DISPLAY environment variable.
display = RubyXMacro.new
38 39 40 41 42 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 38
static VALUE init(VALUE self)
{
openDefaultDisplay();
return Qnil;
}
|
Instance Method Details
#click ⇒ Object
Left-click the mouse.
display.click
70 71 72 73 74 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 70
static VALUE method_click(VALUE self)
{
click();
return Qnil;
}
|
#keycodeDown(keycode) ⇒ Object
Hold down the key with the value keycode until keycodeUp.
display.keycodeDown(int_keycode)
154 155 156 157 158 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 154
static VALUE method_keycodeDown(VALUE self, VALUE keycode)
{
keycodeDown(NUM2INT(keycode));
return Qnil;
}
|
#keycodePress(keycode) ⇒ Object
Press and release the key with the value keycode.
display.keycodePress(int_keycode)
180 181 182 183 184 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 180
static VALUE method_keycodePress(VALUE self, VALUE keycode)
{
keycodePress(NUM2INT(keycode));
return Qnil;
}
|
#keycodeShiftPress(keycode) ⇒ Object
Hold down shift, then press and release the key with the value keycode.
display.keycodeShiftPress(int_keycode)
193 194 195 196 197 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 193
static VALUE method_keycodeShiftPress(VALUE self, VALUE keycode)
{
keycodeShiftPress(NUM2INT(keycode));
return Qnil;
}
|
#keycodeUp(keycode) ⇒ Object
Release the key with the value keycode. Usually used after keycodeDown.
display.keycodeUp(int_keycode)
167 168 169 170 171 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 167
static VALUE method_keycodeUp(VALUE self, VALUE keycode)
{
keycodeUp(NUM2INT(keycode));
return Qnil;
}
|
#keyDown(keycode) ⇒ Object
Hold down the key until keyUp.
display.keyDown(str_key)
206 207 208 209 210 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 206
static VALUE method_keyDown(VALUE self, VALUE keycode)
{
keyDown(StringValuePtr(keycode));
return Qnil;
}
|
#keyPress(key) ⇒ Object
Press and release the key.
display.keyPress(str_key)
232 233 234 235 236 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 232
static VALUE method_keyPress(VALUE self, VALUE key)
{
keyPress(StringValuePtr(key));
return Qnil;
}
|
#keyUp(keycode) ⇒ Object
Release the key. Usually used after keyDown.
display.keyUp(str_key)
219 220 221 222 223 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 219
static VALUE method_keyUp(VALUE self, VALUE keycode)
{
keyUp(StringValuePtr(keycode));
return Qnil;
}
|
#mouseDown ⇒ Object
Hold the left mouse button down until mouseUp.
display.mouseDown
83 84 85 86 87 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 83
static VALUE method_mouseDown(VALUE self)
{
mouseDown();
return Qnil;
}
|
#mouseUp ⇒ Object
Release the left mouse button. Usually used after mouseDown.
display.mouseUp
96 97 98 99 100 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 96
static VALUE method_mouseUp(VALUE self)
{
mouseUp();
return Qnil;
}
|
#moveMouse(x, y) ⇒ Object
Move the mouse pointer to position (x,y).
display.move(int_x, int_y)
57 58 59 60 61 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 57
static VALUE method_moveMouse(VALUE self, VALUE x, VALUE y)
{
moveMouse(NUM2INT(x), NUM2INT(y));
return Qnil;
}
|
#rightClick ⇒ Object
Right-click the mouse.
display.rightClick
109 110 111 112 113 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 109
static VALUE method_rightClick(VALUE self)
{
rightClick();
return Qnil;
}
|
#rightMouseDown ⇒ Object
Hold the right mouse button down until rightMouseUp.
display.rightMouseDown
122 123 124 125 126 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 122
static VALUE method_rightMouseDown(VALUE self)
{
rightMouseDown();
return Qnil;
}
|
#rightMouseUp ⇒ Object
Release the right mouse button. Usually used after rightMouseDown.
display.rightMouseUp
135 136 137 138 139 |
# File 'ext/rubyxmacro/rubyxmacro.c', line 135
static VALUE method_rightMouseUp(VALUE self)
{
rightMouseUp();
return Qnil;
}
|
#sendKeys(keyString) ⇒ Object
Press and release a string of keys.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubyxmacro.rb', line 7 def sendKeys(keyString) while keyString.length > 0 do keyStringArray = keyString.partition(/\{(.*?)\}/) keyString = keyStringArray[0] keyString.each_char do |key| if RubyXMacro::KEYCODES[key] == nil then self.keyPress(key) else keycode = RubyXMacro::KEYCODES[key] keyCase = keycode[-1] keycode = keycode.chop.to_i if keyCase == 'l' then keycodePress(keycode) else keycodeShiftPress(keycode) end end end specialKey = keyStringArray[1].slice(1..(keyStringArray[1].length - 2)) if specialKey != nil && specialKey.length > 0 then specialKey.upcase! keycodePress(RubyXMacro::SPECIAL_KEYCODES[specialKey]) end keyString = keyStringArray[2] end end |