Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

chromatic
  (email not shown publicly)
http://wgz.org/chromatic/

Blog Information [technorati.com] Profile for chr0matic [technorati.com]

Journal of chromatic (983)

Saturday August 07, 2004
12:14 PM

Saving Unicode Characters as Screenshots

[ #20293 ]

I have a small project that requires extracting several Unicode characters from a Word document as uncompressed high-resolution screenshots. The only problem is that I don't have Word -- nor do I run any operating system that can run Word.

Has anyone solved a similar problem? Are there any Win32::Com gurus who know the magic invocations to dump a few dozen Kana characters to images? I suspect a decent hacker could do this in 15 minutes or so, much better than the 10 hours it would take -- if I had the tools -- to convert these manually.

Drop me a line at chromatic at oreilly dot com if that's you.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Here is some code to do the screen capture part:

    #!/usr/bin/perl -w

    use strict;
    use Win32::Clipboard;
    use Win32::GuiTest qw(FindWindowLike SetForegroundWindow SendKeys);

    # Find an open Word document
    my @windows = FindWindowLike(0, qr/Microsoft Word/);

    # Bring Word to the foreground (with focus)
    for (@windows) {
        SetForegroundWindow($_);
        SendKeys('%{PRTSCR}'); # Alt Print Screen
    }

    # Get the image from the clipboard.
    my $screen = Win32::Clipboard::GetBitmap()
           

  • If you needed screenshots of them, could you not get the characters you needed from the PDF Unicode Charts [unicode.org] at unicode.org [unicode.org]? Just a thought.

    • Yes, that would work. However, with a couple of hundred characters, the amount of time and energy necessary for that would have been as much as the first option (entering them manually as screenshots).

      Fortunately, Andrew wrote a macro and Jessamyn figured out a way to copy and paste through a different application. Problem solved.