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

前端 未结 1 1870
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 06:24

Instead of using some third party app, I\'d like to write an app in Ruby that when invoked, will capture the full screen and save it in c:\\screenshot\\snap000001.png

相关标签:
1条回答
  • 2021-01-06 07:14

    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.

    0 讨论(0)
提交回复
热议问题