How to capture part of the screen using Ruby on Windows?

Instead of using any third-party application, I would like to write an application in Ruby that, when called, will capture the entire screen and save it in c: \ screenshot \ snap000001.png

The graphics package is easily accessible, but how can you capture an area from full screen to save it?

This program should be called with some hotkey, for example, when it is launched by pressing CTRL-PrtScn or CTRL-CTRL (both controls are left and right) or ALT-ALT.

+4
source share
1 answer

I have not tried (I am not on the windows). But you can use Win32 :: Screenshot .

While watching, I found the following that takes a screenshot using this library

width, height, bitmap = Win32::Screenshot.desktop img_lst = ImageList.new img_lst.from_blob(bitmap) img_lst.write('public/screen.png') 

And I should write your screenshot as a png file.

+8
source

All Articles