Sha256: 2f09627eeb3fd7654fe6b8a88454d83cd041e51b60e479c4c61a1bdd58e61495

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
  require 'fiddle/import'
else
  require 'dl/import'
  require 'dl/struct'
end
require 'Win32API'

module Watir
  # @private
  module Win32
    # this will find the IEDialog.dll file in its build location
    @@iedialog_file = (File.expand_path(File.dirname(__FILE__) + '/..') + "/watir-classic/IEDialog/Release/IEDialog.dll").gsub('/', '\\')

    GetUnknown = Win32API.new(@@iedialog_file, 'GetUnknown', ['l', 'p'], 'V')


    if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.0')
      User32 = Fiddle.dlopen('user32')
    else
      User32 = DL.dlopen('user32')
    end
    if RUBY_VERSION =~ /^1\.8/
      FindWindowEx = User32['FindWindowEx', 'LLLpp']
      # method for this found in wet-winobj/wet/winobjects/WinUtils.rb
      GetWindow = User32['GetWindow', 'ILL']
      IsWindow = User32['IsWindow', 'II']
    else
      FindWindowEx = GetWindow = IsWindow = lambda do |*args|
        raise NotImplementedError, "1.9's DL API not compatible with 1.8, see http://www.ruby-forum.com/topic/138277"
      end
    end

    ## GetWindows Constants
    GW_HWNDFIRST = 0
    GW_HWNDLAST = 1
    GW_HWNDNEXT = 2
    GW_HWNDPREV = 3
    GW_OWNER = 4
    GW_CHILD = 5
    GW_ENABLEDPOPUP = 6
    GW_MAX = 6


    # Does the window with the specified window handle (hwnd) exist?
    def self.window_exists? hwnd
      rtn, junk = IsWindow[hwnd]
      rtn == 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-classic-4.3.0 lib/watir-classic/win32.rb