Class: ThinClient::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/thinclient/input.rb

Class Method Summary collapse

Class Method Details

.keyevent(keycode) ⇒ Object

input keyevent



37
38
39
# File 'lib/thinclient/input.rb', line 37

def self.keyevent(keycode)
  system("adb shell input keyevent #{keycode}")
end

.swipe(x1 = 0, y1 = 0, x2 = 0, y2 = 0) ⇒ Object

input swipe



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/thinclient/input.rb', line 42

def self.swipe(x1 = 0, y1 = 0, x2 = 0, y2 = 0)
  begin
    if (x1 == nil || y1 == nil || x2 == nil || y2 == nil)
     Log.error("Usage: dragDropImage(img, x, y)")
     print("Usage: dragDropImage(img, x, y)")
     return
    end
    x1 = x1.to_i
    y1 = y1.to_i
    x2 = x2.to_i
    y2 = y2.to_i
  rescue => ex
    Log.error("#{ex}")
    print("#{ex}")
  end  
  system("adb shell input swipe #{x1} #{y1} #{x2} #{y2}")
end

.tap(x = 0, y = 0) ⇒ Object

input tap



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/thinclient/input.rb', line 20

def self.tap(x = 0, y = 0)
  begin
    if (x == nil || y == nil)
     Log.error("Usage: dragDropImage(img, x, y)")
     print("Usage: dragDropImage(img, x, y)")
     return
    end
    x = x.to_i
    y = y.to_i
  rescue => ex
    Log.error("#{ex}")
    print("#{ex}")
  end  
  system("adb shell input tap #{x}, #{y}")
end

.text(str) ⇒ Object

input text



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/thinclient/input.rb', line 4

def self.text(str)
  begin
    str =str.to_s
    strings = str.split(/ /)
    strings.each{ |string|
     system("adb shell input text #{string}")
     Keyboard.sendKeys("space")
    }
  rescue => ex
    Log.error("#{ex}")
    print("#{ex}")
  end  
  
end