Sha256: a9d87adf40776b3f3b6e28a607796143b7cafba47ddc7d05ea30091debd18411

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

= Win32::Screenshot (old name win32screenshot)

* http://github.com/jarmo/win32screenshot

== DESCRIPTION

Capture Screenshots on Windows with Ruby. This library captures
screenshots in bmp format, but you may use RMagick to convert these to some
other formats like png.

== SYNOPSIS

  require 'win32/screenshot'
 
  # take a screenshot of the foreground window
  Win32::Screenshot.foreground do |width, height, bmp|
    File.open("picture1.bmp", "wb") {|file| file.puts bmp}
  end
  
  # take a screenshot of the screen
  Win32::Screenshot.desktop do |width, height, bmp|
    File.open("picture2.bmp", "wb") {|file| file.puts bmp}
  end
  
  # take a screenshot of the window, which has a text part of it's title
  Win32::Screenshot.window("Internet Explorer") do |width, height, bmp|
    File.open("picture3.bmp", "wb") {|file| file.puts bmp}
  end
  
  # take a screenshot of the window, which matches regexp against it's title
  Win32::Screenshot.window(/Internet Explorer/) do |width, height, bmp|
    File.open("picture4.bmp", "wb") {|file| file.puts bmp}
  end
  
  # take a screenshot of the window with specified window handle
  Win32::Screenshot.hwnd(window_handle) do |width, height, bmp|
    File.open("picture5.bmp", "wb") {|file| file.puts bmp}
  end

  # convert a screenshot to the png format with RMagick
  require 'rmagick'
  
  Win32::Screenshot.hwnd(window_handle) do |width, height, bmp|
    img = Magick::Image.from_blob(bmp)
    png = img[0].to_blob {self.format = 'PNG'}
    File.open("picture6.png", "wb") {|file| file.puts png}
  end

== Copyright

Copyright (c) 2010 Jarmo Pertman, Aslak Hellesøy. See LICENSE for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
win32screenshot-0.0.4 README.rdoc