Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How To Read Win32 Window Title Text

by roho (Bishop)
on Nov 12, 2007 at 20:32 UTC ( [id://650373]=perlquestion: print w/replies, xml ) Need Help??

roho has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I need to read the window title text (i.e, in the blue area at the very top of the window) of an open window in MSWin32. I have used Super Search, Google, and have scoured Dave Roth's "Win32 Perl Programming" book, but I cannot find any examples of how to locate an open window (specifically, I'm looking for my open Internet Explorer window), and retrieve the text of the window title. If anyone has done this before I would be eternally grateful for an example of the Win32 module and calling sequence used to get the window title text.

"Its not how hard you work, its how much you get done."

Replies are listed 'Best First'.
Re: How To Read Win32 Window Title Text
by technojosh (Priest) on Nov 12, 2007 at 22:05 UTC
    Win32::GuiTest should take care of that no problem.

    Here's a working example...

    use Win32; use Win32::GuiTest qw(:ALL); my $searchString = 'Internet Explorer'; for (FindWindowLike()) { my $title = GetWindowText($_); next unless ( $title ); if( $title =~ /$searchString/ ) { print "$title\n"; } }

    Update: Added code example that applies to Internet Explorer

      Thank you very much. That was exactly what I was looking for.

      "Its not how hard you work, its how much you get done."

Re: How To Read Win32 Window Title Text
by zer (Deacon) on Nov 12, 2007 at 21:02 UTC
    have you looked at the OLE browser which comes with the activestate perl distribution? Otherwise i would use msdn to find the objects. I'm in php class right now so ill take a deeper look.

    Update: I've looked at the msdn for a bit. The class you would likely need is WebBrowserBase Class. Somewhere within that you should be able to find what you need. Looking a little closer i found WebBrowser.DocumentTitle method. Give it a shot, all of the code there is in MSLanguages but post if you need help.

Re: How To Read Win32 Window Title Text
by bmann (Priest) on Nov 12, 2007 at 22:12 UTC
Re: How To Read Win32 Window Title Text
by SoaponaRope (Novice) on Nov 12, 2007 at 20:44 UTC
    Just a suggestion (I'm not sure if you've thought of this or not, and I'm not sure how to do it). Have you considered opening the source HTML of the window you're looking at and reading the <title> tag?
      Thanks for the suggestion, but I am not looking for the HTML title from within the page. I want to locate the open window (for Internet Explorer) from my Perl program and retrieve its title text.

      "Its not how hard you work, its how much you get done."

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://650373]
Approved by zer
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-19 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found