Forum: Ruby Print screen with win32api

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7cab3de4cd313089a2425250a404b0be?d=identicon&s=25 Emil Sandin (emilsverige)
on 2007-03-12 12:11
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
4371f8fa1c3574e74d8f88c77d23e7d7?d=identicon&s=25 Harry (Guest)
on 2007-03-12 12:36
(Received via mailing list)
On 3/12/07, Emil Sandin <esandin@gmail.com> wrote:
> 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
--

http://www.kakueki.com/ruby/list.html
Japanese Ruby List Subjects in English
1c29f9b1bf5f1b88ed8b0c9a9be39788?d=identicon&s=25 Daniele Alessandri (Guest)
on 2007-03-12 12:53
(Received via mailing list)
On 3/12/07, Emil Sandin <esandin@gmail.com> wrote:

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.


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.
7cab3de4cd313089a2425250a404b0be?d=identicon&s=25 Emil Sandin (emilsverige)
on 2007-03-12 13:51
Daniele Alessandri wrote:
> On 3/12/07, Emil Sandin <esandin@gmail.com> wrote:
>
> 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.
>
>
> 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
Cbba7b7c2eab0e47dd7a06e335327e9b?d=identicon&s=25 gemini kowui (geminikowui)
on 2012-05-03 13:31
help help..........

why i don't excute, require ffi_c is wrong,who can help me?
Abdb670e1c130f96f947a94d03c02efa?d=identicon&s=25 Eric Christopherson (echristopherson)
on 2012-05-03 21:37
(Received via mailing list)
On Thu, May 3, 2012 at 6:31 AM, gemini kowui <lists@ruby-forum.com>
wrote:
> help help..........
>
> why i don't excute, require ffi_c is wrong,who can help me?

Perhaps you could tell us
1) what you're trying to accomplish
2) what code you're trying
3) what error messages or incorrect behaviors the code is producing

As an aside: you're replying to a thread from 2007.
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2012-05-08 20:00
gemini kowui wrote in post #1059414:
> help help..........
>
> why i don't excute, require ffi_c is wrong,who can help me?

did you install the ffi gem?
This topic is locked and can not be replied to.