Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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
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, 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 (;;) {
        my $text = uc $clip->GetText();
        last if $text =~ /^\s*$/;
        print "$text\n";


=head1 NAME 




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 7 Apr 2002

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

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2023-12-11 21:44 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (41 votes). Check out past polls.