-
Notifications
You must be signed in to change notification settings - Fork 12
/
auto_it_driver.rb
45 lines (38 loc) · 860 Bytes
/
auto_it_driver.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module Selenium
class AutoIt
@@autoit = nil
def self.load
begin
@@autoit = load_instance
rescue WIN32OLERuntimeError
registerAutoItDll
@@autoit = load_instance
end
@@autoit
end
def self.load_instance
@@autoit = WIN32OLE.new('AutoItX3.Control') unless @@autoit
@@autoit
end
def self.reset
if @@autoit
@@autoit.ole_free
@@autoit =nil
system("regsvr32.exe /s /u #{dll}")
end
end
def self.registerAutoItDll
system("regsvr32.exe /s #{dll}")
end
def self.dll
File.join(File.dirname(__FILE__), 'autoit', 'AutoItX3.dll')
end
def initialize
@autoit = AutoIt.load
end
def on_window_active(title, text = nil)
@autoit.WinWaitActive(title, text, 30)
yield @@autoit
end
end
end