module Sikulix
Classes and methods for using SikuliX
Private Class Methods
dynamic_def(name, &block)
click to toggle source
Dynamic method definition for several cases of invocation
# File lib/sikulix/sikulix.rb, line 70 def self.dynamic_def(name, &block) # using as: # include Sikulix # some_method(...) define_method(name, &block) # using as: # Sikulix::some_method(...) define_singleton_method(name, &block) # private method to avoid of attachment to all subclasses private name end
method_missing(name)
click to toggle source
# File lib/sikulix/sikulix.rb, line 124 def self.method_missing(name) if (val = const_get(name)) return val end fails "method missing #{name}" end
native_exception_protect(obj, methods_array)
click to toggle source
This method generates a wrapper for Java Native exception processing in native java methods. It allows to detect a line number in script that opened in IDE where the exception was appearing.
obj - class for the wrapping methods_array - array of method names as Symbols
# File lib/sikulix/sikulix.rb, line 52 def self.native_exception_protect(obj, methods_array) methods_array.each do |name| m = obj.instance_method name obj.class_exec do alias_method(('java_' + name.to_s).to_sym, name) define_method(name) do |*args| begin # java specific call for unbound methods m.bind(self).call(*args) rescue NativeException => e raise StandardError, e.message end end end end end
Private Instance Methods
addHotkey(key, modifiers, &block)
click to toggle source
Register hotkeys
Example:
addHotkey( Key::F1, KeyModifier::ALT + KeyModifier::CTRL ) do popup 'hallo', 'Title' end
# File lib/sikulix/sikulix.rb, line 169 def addHotkey(key, modifiers, &block) Env.addHotkey key, modifiers, Env::RHotkeyListener.new(block) end
removeHotkey(key, modifiers)
click to toggle source
Unregister hotkeys
Example:
removeHotkey( Key::F1, KeyModifier::ALT + KeyModifier::CTRL )
# File lib/sikulix/sikulix.rb, line 178 def removeHotkey(key, modifiers) Env.removeHotkey key, modifiers end
setDefaultScreen(screen)
click to toggle source
Replaces default screen for which all undotted methods are called with another screen example: setDefaultScreen($SIKULI_SCREEN) click(Location(10,10)) <- click will be performed on local screen
# File lib/sikulix/sikulix.rb, line 101 def setDefaultScreen(screen) if screen.respond_to?(:click) $DEFAULT_SCREEN = screen Debug.log("Screen switched") end end