Print screen with win32api

E

Emil Sandin

Hi,
I have seen this question on several locations, but no solution to it. I
want to capture the screen on windows xp. I know that you can do it with
rmagick, but that seems to be for unix-systems only, and rubycocoa for
mac. Since there is a "print screen"-button on the keyboard, I guess
that it should be possible to use win32api to fake a klick on the
keyboard button, and then somehow save the image to disk.

Any ideas?
Regards
Emil
 
H

Harry

Hi,
I have seen this question on several locations, but no solution to it. I
want to capture the screen on windows xp. I know that you can do it with
rmagick, but that seems to be for unix-systems only, and rubycocoa for
mac. Since there is a "print screen"-button on the keyboard, I guess
that it should be possible to use win32api to fake a klick on the
keyboard button, and then somehow save the image to disk.

Any ideas?
Regards
Emil


I haven't tested this particular command but you should be able to do
it with AutoIt.
You can script AutoIt via Ruby.

Here are some commands.
Printscreen is listed.

http://tiger.la.asu.edu/Quick_Ref/AutoIt_quickref.pdf

Harry
 
E

Emil Sandin

Daniele said:
mac. Since there is a "print screen"-button on the keyboard, I guess


Try installing Win32::Screenshot (
http://rubyforge.org/projects/win32screenshot/) and launching the
following
script:


require 'win32screenshot'

width, height, bitmap = Win32::Screenshot.desktop
File.open('test.bmp', 'wb') { |file| file.write(bitmap) }


You can find more examples in the test folder after installing the gem
file.

Wow, that sounds exactly right, Thank you!

/Emil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top