The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Win32::FindWindow - find windows on Win32 systems

SYNOPSIS

    use Win32::FindWindow;
    
    # find a window with the class name.
    my $window = find_window( classname => 'ExploreWClass' );
    
    # basename, filename, windowtext, and classname can be specified.
    my $window = find_window( basename   => 'Explorer.EXE'
                            , filename   => 'C:\\WINDOWS\\Explorer.EXE'
                            , windowtext => 'C:\\'
                            , classname  => 'ExploreWClass' );
    
    # hwnd and pid can be specified, too.
    # hwnd defaults to the retval of GetDesktopWindow().
    # pid is not effective until specifying it.
    
    # find with regexp:
    # it must set the value by qr// style.
    my $window = find_window( classname  => qr/^ExploreWClass$/
                            , filename   => qr/^C:\\WINDOWS\\.*/
                            , basename   => qr/^Explorer.EXE$/
                            , windowtext => qr/^C:\\$/ );
    
    # the retval is an object.
    # the read-only accessor are as follows:
    $window->hwnd;
    $window->windowtext;
    $window->classname;
    $window->pid;
    $window->filename;
    $winfow->basename;
    
    # call find_windows() to return multiple values.
    my @windows = find_windows( classname => 'MSPaintApp'
                              , filename  => 'C:\\WINDOWS\\system32\\mspaint.exe'
                              , basename  => 'mspaint.exe'
                              , windowtext => qr/^.+$/ );
    
    # set $Win32::FindWindow::ENCODING with wide characters search
    # ex. Japanese UTF-8
    use utf8;
    use encoding 'utf8', STDOUT => 'cp932';
    $Win32::FindWindow::ENCODING = 'cp932';
    
    my @windows = find_windows( classname => qr/スタート/ );

DESCRIPTION

This module provides routines for finding windows on Win32 systems.

METHODS

read-only accessors

hwnd()
windowtext()
classname()
pid()
filename()
basename()

AUTHOR

Michiya Honda <pia@cpan.org>

LICENCE

This library is free software, licensed under the same terms with Perl. See perlartistic.