Class: XDo::Keyboard
- Inherits:
-
Object
- Object
- XDo::Keyboard
- Defined in:
- lib/x_do/keyboard.rb
Overview
The keyboard state for a libxdo context.
Instance Attribute Summary collapse
-
#xdo ⇒ Object
The XDo context that produced the window.
Instance Method Summary collapse
-
#initialize(xdo) ⇒ Keyboard
constructor
Creates a keyboard state wrapper for an XDo context.
-
#press_keysequence(keysequence, delay = 0.012) ⇒ Object
Presses a keysequence in the active window.
-
#release_keysequence(keysequence, delay = 0.012) ⇒ Object
Releases a keysequence in the active window.
-
#type_keysequence(keysequence, delay = 0.012) ⇒ Object
Sends a keysequence to the active window.
-
#type_string(string, delay = 0.012) ⇒ Object
Types a string into the current window.
Constructor Details
#initialize(xdo) ⇒ Keyboard
Creates a keyboard state wrapper for an XDo context.
This constructor is called internally by XDo#keyboard and client code should not need to call it directly.
Args:
xdo:: the XDo wrapping a libxdo context
13 14 15 16 |
# File 'lib/x_do/keyboard.rb', line 13 def initialize(xdo) @xdo = xdo @_xdo_pointer = xdo._pointer end |
Instance Attribute Details
#xdo ⇒ Object
The XDo context that produced the window.
19 20 21 |
# File 'lib/x_do/keyboard.rb', line 19 def xdo @xdo end |
Instance Method Details
#press_keysequence(keysequence, delay = 0.012) ⇒ Object
Presses a keysequence in the active window.
Examples: “alt+Return”, “Alt_L+Tab”, “l”, “semicolon”
37 38 39 40 |
# File 'lib/x_do/keyboard.rb', line 37 def press_keysequence(keysequence, delay = 0.012) XDo::FFILib.xdo_keysequence_down @_xdo_pointer, 0, keysequence, (delay * 1_000_000).to_i end |
#release_keysequence(keysequence, delay = 0.012) ⇒ Object
Releases a keysequence in the active window.
Examples: “alt+Return”, “Alt_L+Tab”, “l”, “semicolon”
45 46 47 48 |
# File 'lib/x_do/keyboard.rb', line 45 def release_keysequence(keysequence, delay = 0.012) XDo::FFILib.xdo_keysequence_up @_xdo_pointer, 0, keysequence, (delay * 1_000_000).to_i end |
#type_keysequence(keysequence, delay = 0.012) ⇒ Object
Sends a keysequence to the active window.
Examples: “alt+Return”, “Alt_L+Tab”, “l”, “semicolon”
29 30 31 32 |
# File 'lib/x_do/keyboard.rb', line 29 def type_keysequence(keysequence, delay = 0.012) XDo::FFILib.xdo_keysequence @_xdo_pointer, 0, keysequence, (delay * 1_000_000).to_i end |