Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Me in a loop with Win32::Clipboard

by Rudif (Hermit)
on Apr 07, 2002 at 16:42 UTC ( #157285=sourcecode: print w/ replies, xml ) Need Help??

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

Comment on Me in a loop with Win32::Clipboard
Download Code
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

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://157285]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-12-20 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls