<commit_before>module RAutomation
  module Adapter
    module Autoit
      class Window
        include WaitHelper
        include Locators

        class << self
          # @private
          def autoit
            @@autoit
          end

          # @private
          def load_autoit
            @@autoit = WIN32OLE.new('AutoItX3.Control')
          rescue WIN32OLERuntimeError
            dll = File.dirname(__FILE__) + "/../../../../ext/AutoItX/AutoItX3.dll"
            system("regsvr32.exe /s #{dll.gsub('/', '\\')}")
            @@autoit = WIN32OLE.new('AutoItX3.Control')
          end
        end

        load_autoit
        @@autoit.AutoItSetOption("WinWaitDelay", 350)

        # Locators of the window.
        attr_reader :locators

        # @private
        # Special-cased locators
        LOCATORS = {
            [:title, Regexp] => :regexptitle,
            :index => :instance,
            :hwnd => :handle
        }

        # Creates the window object.
        # @note this method is not meant to be accessed directly, but only through {RAutomation::Window#initialize}!
        # @param [Hash] locators for searching the window.
        # @option locators [String, Regexp] :title Title of the window
        # @option locators [String, Regexp] :text Visible text of the window
        # @option locators [String, Regexp] :class Internal class name of the window<commit_msg>Show error message when registration of AutoIt dll fails.<commit_after>module RAutomation
  module Adapter
    module Autoit
      class Window
        include WaitHelper
        include Locators

        class << self
          # @private
          def autoit
            @@autoit
          end

          # @private
          def load_autoit
            @@autoit = WIN32OLE.new('AutoItX3.Control')
          rescue WIN32OLERuntimeError
            dll = File.dirname(__FILE__) + "/../../../../ext/AutoItX/AutoItX3.dll"
            unless system("regsvr32.exe /s #{dll.gsub('/', '\\')}")
              raise "Start Ruby with administrative rights when using AutoIt adapter for the first time."
            end
            @@autoit = WIN32OLE.new('AutoItX3.Control')
          end
        end

        load_autoit
        @@autoit.AutoItSetOption("WinWaitDelay", 350)

        # Locators of the window.
        attr_reader :locators

        # @private
        # Special-cased locators
        LOCATORS = {
            [:title, Regexp] => :regexptitle,
            :index => :instance,
            :hwnd => :handle
        }

        # Creates the window object.
        # @note this method is not meant to be accessed directly, but only through {RAutomation::Window#initialize}!
        # @param [Hash] locators for searching the window.
        # @option locators [String, Regexp] :title Title of the window
        # @option locators [String, Regexp] :text Visible text of the window
        # @option locators [String, Regexp] :class Internal class name of the window
{'fraction_non_alphanumeric': 0.09632873021219265, 'fraction_numerical': 0.009430784776018861, 'mean_word_length': 1.8585178055822906, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5550719', 'n_tokens_mistral': 854, 'n_tokens_neox': 813, 'n_words': 245}