Skip to content
Capture Screenshots on Windows with Ruby
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ext/ImageMagick-6.9.3-0-portable-Q16-x86 Update bundled ImageMagic to 6.9.3-0-portable-Q16-x86. Use notepad in… Jan 9, 2016
lib/win32 Prepare for a release. Jan 9, 2016
spec Update bundled ImageMagic to 6.9.3-0-portable-Q16-x86. Use notepad in… Jan 9, 2016
.gitignore use Bundler Oct 16, 2011
.rspec
.yardopts added .yardopts Dec 16, 2010
Gemfile Loosen up some dependencies. Mar 9, 2013
Gemfile.lock Update yard due to CVE. Dec 29, 2017
History.rdoc Fix history. Jan 9, 2016
LICENSE Prepare for a release. Jan 9, 2016
README.rdoc Correcting typo when I added write! Dec 3, 2015
Rakefile Update README and LICENSE. Jun 28, 2015
win32screenshot.gemspec Update mini_magick dependency. Jan 9, 2016

README.rdoc

Win32::Screenshot

DESCRIPTION

Capture Screenshots on Windows with Ruby to bmp, gif, jpg or png formats!

INSTALL

gem install win32screenshot

SYNOPSIS

require 'win32/screenshot'

# Take a screenshot of the window with the specified title
Win32::Screenshot::Take.of(:window, title: "Windows Internet Explorer").write("image.bmp")

# Take a screenshot of the foreground
Win32::Screenshot::Take.of(:foreground).write("image.png")

# Take a screenshot of the foreground, and writing over previous image if it exists
Win32::Screenshot::Take.of(:foreground).write!("image.png")

# Take a screenshot of the specified window's top-left corner's area
Win32::Screenshot::Take.of(:window, title: /internet/i, area: [10, 10, 20, 20]).write("image.jpg")

# Take a screenshot of the window with the specified handle
Win32::Screenshot::Take.of(:window, hwnd: 123456).write("image.gif")

# Take a screenshot of the window's client area (e.g. without title bar) with the specified handle
Win32::Screenshot::Take.of(:window, hwnd: 123456, context: :client)

# Take a screenshot of the child window with the specified internal class name
Win32::Screenshot::Take.of(:rautomation, RAutomation::Window.new(hwnd: 123456).
                          child(class: "Internet Explorer_Server")).write("image.png")

# Use the bitmap blob for something else
image = Win32::Screenshot::Take.of(:window, hwnd: 123456)
image.height # => height of the image
image.width  # => width of the image
image.bitmap # => bitmap blob

Copyright

Copyright © Jarmo Pertman, Aslak Hellesøy. See LICENSE for details.

You can’t perform that action at this time.