Loading ...
Sorry, an error occurred while loading the content.
 

Answer in Ruby Re: Using GuiTest, show can I get a Window's Process ID?

Expand Messages
  • chrs_mcmhn
    ... In the code below, IE.new is equivalent to Win32::Process::Create. I think it should be possible to figure out the Perl Win32 stuff from the following
    Message 1 of 2 , Nov 7, 2005
      --- In perlguitest@yahoogroups.com, "Mark Andre Hary" <mark_hary@y...>
      wrote:
      >
      > I start a process using $process = Win32::Process::Create(...).
      >
      > I then find a list of Windows via
      > Win32::GuiTest::FindWindowLike("blah","").
      >
      > That returns a list of window handles whose titles match "blah". How
      > can I get the ProcessID of each of those Windows to match against
      > $process?

      In the code below, "IE.new" is equivalent to Win32::Process::Create.
      I think it should be possible to figure out the Perl Win32 stuff from
      the following Ruby code. We know the pid is correct because
      "Process.kill() works correctly.

      require 'win32ole'
      require 'watir' # the controller
      include Watir
      require 'Win32API'

      @ie = IE.new
      hWnd = @...
      pid=" " * 32
      thread= Win32API.new("user32", "GetWindowThreadProcessId", 'IP',
      'I').Call(hWnd,pid)
      fixnum_pid = pid.unpack("L")[0]
      puts fixnum_pid
      Process.kill( 9 , fixnum_pid)
    Your message has been successfully submitted and would be delivered to recipients shortly.