Class: XDo::Keyboard

Inherits:
Object
  • Object
show all
Defined in:
lib/x_do/keyboard.rb

Overview

The keyboard state for a libxdo context.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#xdoObject

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

#type_string(string, delay = 0.012) ⇒ Object

Types a string into the current window.



22
23
24
# File 'lib/x_do/keyboard.rb', line 22

def type_string(string, delay = 0.012)
  XDo::FFILib.xdo_type @_xdo_pointer, 0, string, (delay * 1_000_000).to_i
end