class Robobot::Keyboard
Public Class Methods
new(window = nil)
click to toggle source
Initialize keyboard
# File lib/robobot/keyboard.rb, line 10 def initialize window = nil @window = window end
Public Instance Methods
key(key)
click to toggle source
Press key
You may use any Syntax like:
space, Control+a, A, up, alt+r, BackSpace, Control, Control_R, shift, super, ...
# File lib/robobot/keyboard.rb, line 20 def key key cmd "key #{key}" end
keydown(key)
click to toggle source
Key down only
# File lib/robobot/keyboard.rb, line 25 def keydown key cmd "keydown #{key}" end
keyup(key)
click to toggle source
Key up
# File lib/robobot/keyboard.rb, line 30 def keyup key cmd "keyup #{key}" end
type(text)
click to toggle source
type text
# File lib/robobot/keyboard.rb, line 35 def type text cmd "type \"#{text}\"" end
Private Instance Methods
cmd(command)
click to toggle source
Command generator (add window if set)
# File lib/robobot/keyboard.rb, line 42 def cmd command command = command.split(" ",2) cmd = "xdotool #{command[0]}" cmd += " --window #{@window.id}" if @window cmd += " #{command[1]}" puts "#{cmd}" `#{cmd}` end