Window#pid for adapter :autoit returns an empty string. For adapter :win_ffi, it returns an integet pid.
The code at adapter/autoit/window.rb is this:
def pid
@@autoit.WinGetProcess(hwnd)
end
It would be better as:
def pid
@@autoit.WinGetProcess(title).to_i
end
Here's a test that can be run in the spec directory:
require 'spec_helper'
describe RAutomation::Windows do
[ :win_ffi, :autoit ].each do |adapter|
title = SpecHelper::DATA[:window1_title]
it "#pid with adapter=#{adapter} should return a positive integer" do
window = RAutomation::Window.new(
:adapter => adapter,
:title => title
)
pid = window.pid
puts "adapter=#{adapter} class=#{pid.class} value='#{pid}'"
pid.should > 0
end
end
end
Failing result on my machine:
adapter=win_ffi class=Fixnum value='2028'
.adapter=autoit class=String value=''
F
Failures:
1) RAutomation::Windows #pid with adapter=autoit should return a positive inte
ger
Failure/Error: pid.should > 0
ArgumentError:
comparison of String with 0 failed
# ./pid_bug.rb:14
Finished in 3 seconds
2 examples, 1 failure
Window#pid for adapter :autoit returns an empty string. For adapter :win_ffi, it returns an integet pid.
The code at adapter/autoit/window.rb is this:
It would be better as:
Here's a test that can be run in the spec directory:
Failing result on my machine: