class RAutomation::Adapter::MsUia::Keys
Constants
- KEYS
- SPECIAL_KEYS
Public Class Methods
[](key)
click to toggle source
# File lib/rautomation/adapter/ms_uia/keys.rb, line 93 def self.[](key) KEYS[key] or raise "unsupported key #{key.inspect}" end
encode(keys)
click to toggle source
# File lib/rautomation/adapter/ms_uia/keys.rb, line 97 def self.encode(keys) keys.reduce([]) do |converted, key| if key.is_a?(Symbol) converted << Keys[key] elsif key.is_a?(Array) converted << (key.map {|k| encode([k])} << Keys[:null]).flatten else # key is a string converted += encode_str(key) end converted end end
encode_str(keys)
click to toggle source
# File lib/rautomation/adapter/ms_uia/keys.rb, line 110 def self.encode_str(keys) keys.to_s.split("").map do |key| key =~ /[a-z]/ ? key.upcase.unpack("c")[0] : key =~ /[A-Z]/ || SPECIAL_KEYS[key] ? [Keys[:shift], SPECIAL_KEYS[key] || key.unpack("c")[0], Keys[:null]] : key.unpack("c")[0] end end