http://qs321.pair.com?node_id=157285
Category: Win32 Stuff
Author/Contact Info Rudif@lecroy.com
Description: I wanted to convert a large number (several hundred) of strings from mixed case to upper case. Strings were accessible one at a time, through a dialog belonging to a particular application.
So, I sat down to do the work:
repeat open the dialog on next item retype string in uppercase
Ugh. Retyping was the longest and most error-prone part of the operation. And easiest to mechanize, if I could hook Perl into my loop. I remembered Win32::Clipboard and quickly whipped up this script, ucclip.pl. Now the slog became bearable (almost pleasant, in a cyborg sort of way):
start the script repeat open the dialog on next item copy string to clipboard (select, ^C) - script uppercases it paste back into the dialog (^V)
#!perl -w

    use strict;
    use Win32::Clipboard;
    my $clip = Win32::Clipboard("uppercases the clipboard content");
    for (;;) {
        $clip->WaitForChange();
        my $text = uc $clip->GetText();
        last if $text =~ /^\s*$/;
        print "$text\n";
        $clip->Set($text);
    }


__END__


=head1 NAME

ucclip.pl 

=head1 SYNOPSIS

    ucclip

=head1 DESCRIPTION

Loops waiting for change in contents of your Windows Clipboard.
Converts any string that you copy into the Clipboard to uppercase,
ready for pasting.

Also prints the converted string to the console window.

Exits when you copy a blank string into the Clipboard.

=head1 SEE ALSO

perl(1), Win32::Clipboard

=head1 AUTHOR

Rudi Farkas rudif@lecroy.com 7 Apr 2002

=cut
Replies are listed 'Best First'.
Re: Me in a loop with Win32::Clipboard
by clemburg (Curate) on Apr 08, 2002 at 13:00 UTC

    Hey, you know, you could even try to couple this to the SendKeys functionality for further automation of GUI interaction - see Application for 'Quality Assurance' for some discussion of this, and Re: Application for 'Quality Assurance' for a specific example. As you will note from the discussion, there are several modules that are implementing SendKeys in Perl.

    Christian Lemburg