Class: Vapir::IE::Process
- Inherits:
-
Object
- Object
- Vapir::IE::Process
- Defined in:
- lib/vapir-ie/ie-process.rb
Instance Attribute Summary collapse
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
Class Method Summary collapse
-
.process_id_from_hwnd(hwnd) ⇒ Object
Returns the process id for the specifed hWnd.
-
.start ⇒ Object
Vapir::IE::Process.start is called by Vapir::IE.new_process and does not start a new process correctly in IE8.
Instance Method Summary collapse
-
#initialize(process_id) ⇒ Process
constructor
A new instance of Process.
- #window ⇒ Object
Constructor Details
#initialize(process_id) ⇒ Process
Returns a new instance of Process.
34 35 36 |
# File 'lib/vapir-ie/ie-process.rb', line 34 def initialize process_id @process_id = process_id end |
Instance Attribute Details
#process_id ⇒ Object (readonly)
Returns the value of attribute process_id.
37 38 39 |
# File 'lib/vapir-ie/ie-process.rb', line 37 def process_id @process_id end |
Class Method Details
.process_id_from_hwnd(hwnd) ⇒ Object
Returns the process id for the specifed hWnd.
51 52 53 54 55 56 |
# File 'lib/vapir-ie/ie-process.rb', line 51 def self.process_id_from_hwnd hwnd pid_info = ' ' * 32 Win32API.new('user32', 'GetWindowThreadProcessId', 'ip', 'i'). call(hwnd, pid_info) process_id = pid_info.unpack("L")[0] end |
.start ⇒ Object
Vapir::IE::Process.start is called by Vapir::IE.new_process and does not start a new process correctly in IE8. Calling IE8 with the -nomerge option correctly starts a new process, so call Process.create with this option if IE’s version is 8
24 25 26 27 28 29 30 31 32 |
# File 'lib/vapir-ie/ie-process.rb', line 24 def self.start program_files = ENV['ProgramFiles'] || "c:\\Program Files" startup_command = "#{program_files}\\Internet Explorer\\iexplore.exe" startup_command << " -nomerge" if ::Vapir::IE.version_parts.first==8 # maybe raise an error here if it's > 8, as not-yet-supported? who knows what incompatibilities the future will hold process_info = ::Process.create('app_name' => "#{startup_command} about:blank") process_id = process_info.process_id new process_id end |
Instance Method Details
#window ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vapir-ie/ie-process.rb', line 39 def window Waiter.wait_until do IE.each do | ie | window = ie.ie hwnd = ie.hwnd process_id = Process.process_id_from_hwnd hwnd return window if process_id == @process_id end end end |