Sha256: d57db8e8325bd57a8a9b4f529d7fea192a7b51803a830439a084d8f05c6f9709

Contents?: true

Size: 1021 Bytes

Versions: 1

Compression:

Stored size: 1021 Bytes

Contents

require 'win32/screenshot/bitmap_maker'

module Win32
  # Captures screenshots with Ruby on Windows
  class Screenshot
    class << self

      # captures foreground
      def foreground(&proc)
        hwnd = BitmapMaker.foreground_window
        BitmapMaker.capture(hwnd, &proc)
      end

      # captures desktop
      def desktop(&proc)
        hwnd = BitmapMaker.desktop_window
        BitmapMaker.capture(hwnd, &proc)
      end

      # captures window with a *title_query* and waits *pause* (by default is 0.5)
      # seconds after trying to set window to the foreground
      def window(title_query, pause=0.5, &proc)
        hwnd = BitmapMaker.hwnd(title_query)
        raise "window with title '#{title_query}' was not found!" unless hwnd
        hwnd(hwnd, pause, &proc)
      end

      # captures by window handle
      def hwnd(hwnd, pause=0.5, &proc)
        BitmapMaker.prepare_window(hwnd, pause)
        BitmapMaker.capture(hwnd, &proc)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
win32screenshot-0.0.4 lib/win32/screenshot.rb