def main_window
      return @main_window if @main_window

      # pre sanity checks
      raise_error "calling main_window without a pid, application not initialized properly" unless @pid
      raise_error "calling main_window without a window title, application not initialized properly" unless @title

      timeout(main_window_timeout) do
        begin
          # There may be multiple instances, use title and pid to id our main window
          @main_window = Autogui::EnumerateDesktopWindows.new.find do |w|
            w.title.match(title) && w.pid == pid
          end
          sleep 0.1
        end until @main_window
      end

      # post sanity checks
      raise_error "cannot find main_window, check application title" unless @main_window

      @main_window
    end
def main_window
      return @main_window if @main_window

      # pre sanity checks
      raise_error "calling main_window without a pid, application not initialized properly" unless @pid
      raise_error "calling main_window without a window title, application not initialized properly" unless @title

      timeout(main_window_timeout) do
        begin
          # There may be multiple instances, use title and pid to id our main window
          @main_window = Autogui::EnumerateDesktopWindows.new.find do |w|
            w.title.match(title) && w.pid == pid
          end
          sleep 0.1
        end until @main_window
      end

      # post sanity checks
      raise_error "cannot find main_window, check application title" unless @main_window

      @main_window
    end
The application main window found by enumerating windows
 by title and application pid.  This method will keep looking
 unit main_window_timeout (default: 10s) is exceeded.

 @raise [Exception] if the main window cannot be found

 @return [Autogui::Window]
 @see initialize for options