use strict; use warnings; use Win32::API; use Win32::API::Callback; my $getwindowtext = Win32::API->new( 'user32', 'GetWindowText', 'NPN', 'N' ); my $enumwindows = Win32::API->new( 'user32', 'EnumWindows', 'KN', 'N' ); my $title = shift || "Mozilla"; $title = qr/\Q$title\E/i; my $cb = Win32::API::Callback-> new( sub { my $hwnd = shift; my $text = " " x 255; my $length = $getwindowtext->Call( $hwnd, $text, 255 ); $text = substr( $text, 0, $length ); if ( $text =~ $title ) { print "$text\n"; } 1; }, "NN", "N", ); my $ret = $enumwindows->Call( $cb, 0 );