#!/usr/bin/perl use warnings; use strict; use Win32::GuiTest qw[FindWindowLike SendKeys SetForegroundWindow]; use Win32::Clipboard; my $clip = Win32::Clipboard(); for my $w (FindWindowLike(undef, qr{ - Notepad$}, undef, undef, undef)){ SetForegroundWindow($w); SendKeys(q{^A^C}); print $clip->Get(); }