Created
November 17, 2010 04:28
-
-
Save elitecoder/702973 to your computer and use it in GitHub Desktop.
Ruby script to take screenshots. Requires - Win32Screenshot Or RMagick You can uncomment corresponding code if using RMagick. This script is ready to take screenshots on a Win32 System. Users can opt to use RMagick on //other Platforms. (Considering RMagi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################### | |
# Screenshots.rb # | |
# Author: Mukul Sharma # | |
# Date: 11/09/2009 # | |
############################################### | |
require 'win32screenshot' | |
#require 'RMagick' | |
t = Time.now | |
str = t.strftime("%Y%m%d_%H%M%S") | |
# Take Foreground Screenshot | |
# width, height, bmp = Win32::Screenshot.foreground | |
# Take Desktop Screenshot | |
width, height, bmp = Win32::Screenshot.desktop | |
# Take Application Window Screenshot | |
# width, height, bmp = Win32::Screenshot.window(/Firefox/) | |
img_path = ARGV[0] || "file_#{str}.bmp" | |
File.open(img_path, "wb") { |io| | |
io.write(bmp) | |
} | |
# img = Magick::Image.from_blob(bmp)[0] | |
# dir and spec number are defined outside | |
# img_path = img_path + ".png" | |
# img.write(img_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment