lib/driver/driver.rb in screen_driver-0.0.0 vs lib/driver/driver.rb in screen_driver-0.0.1
- old
+ new
@@ -2,9 +2,30 @@
class Driver
def initialize
@screen = Screen.new
@mouse = Mouse.new
+ @keys = Keys.new
+ end
+
+ def press_keys(string)
+ robot = Robot.new
+ keys = string.upcase.split("")
+ keys.each do |key|
+ kc = @keys.get(key)
+ robot.keyPress(kc)
+ robot.keyRelease(kc)
+ end
+ end
+
+ def press_modified_key(modifier, key)
+ m = @keys.get(modifier.upcase)
+ k = @keys.get(key.upcase)
+ robot = Robot.new
+ robot.keyPress(m)
+ robot.keyPress(k)
+ robot.keyRelease(k)
+ robot.keyRelease(m)
end
def screen_to_file(filename)
ss = @screen.screenshot
@screen.put_image(ss, filename)