Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi Ritter,

Here's a working start using Win32::API and Win32::API::Callback to handle EnumWindows. Error handling is up to you ;)

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 );
Results:
C:\S>perl enumwin.pl Mozilla Command Prompt - perl enumwin.pl Mozilla preview page - Mozilla Firefox

In reply to Re: How can I fetch text from Windows Title Bars? by bmann
in thread How can I fetch text from Windows Title Bars? by Ritter

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-03-28 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found