How to capture a part of a screen using Ruby on Windows?
I haven't tried it (I'm not on windows). But you could use Win32::Screenshot.
While looking around, I've found the following, which does the screenshot using that library
width, height, bitmap = Win32::Screenshot.desktop
img_lst = ImageList.new
img_lst.from_blob(bitmap)
img_lst.write('public/screen.png')
And should write your screenshot as a png file.
How do I capture the screen using Ruby?
I figured out how to do this so I though I would post the solution for others who may need help.
The GetDIBits Win32API function can be used to access the RGB array stored in the bitmap captured using the above code.
http://msdn.microsoft.com/en-us/library/dd144879%28v=vs.85%29.aspx
How to capture a window screen shot in Ruby
Actually we have a library for screenshot in win32 we can make use of that library in order to solve this problem.
Here is the piece of code that might help you
require 'win32/screenshot'
Win32::Screenshot::Take.of(:foreground).write("Screenshot.png")
How to use Win32's BitBlt using Ruby?
Second Carl's other post: use win32 screenshot http://github.com/jarmo/win32screenshot
Capture screenshots for a Ruby on Rails application
I use IMGKit gem for that: https://github.com/csquared/IMGKit
Related topic: How to respond_to PNG or JPG in Rails and generate image from HTML?
How to use Ruby to detect whether on Windows Platform, the SHIFT or ALT key is being pressed?
On Win32, how to detect whether a Left Shift or Right ALT is pressed using Perl, Python, or Ruby (or C)? has some clues...
ruby ffi might help, too
Related Topics
Ruby on Rails - Activerecord::Relation Count Method Is Wrong
How to Pass Content to Jekyll Default Converter After Custom Conversion
Advice on How to Validate Names and Surnames Using Regex
In Rspec, Using Let Variable Inside Before :All Block
Behaviour of Array Bang Methods
Web Page Scraping Gems/Tools Available in Ruby
What's the Nature of "Property" in a Ruby Class
Read and Write File Atomically
Arbitrary Precision Arithmetic with Ruby
Accessing a Has_One Associations' Attributes
Rotate Bits Right Operation in Ruby
More Concise Version of Max/Min Without the Block
Cancan Abilities in Separate File
How to Test Whether a String Would Match a Glob in Ruby
Is There an Elegant Way to Exclude the First Value of a Range
How to Define a Method in Ruby Using Splat and an Optional Hash at the Same Time