Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
Think about Loose Coupling
 
PerlMonks  

Win32::GuiTest::GetWindowText does not return text ?

by Foggy Bottoms (Monk)
on Aug 11, 2003 at 13:45 UTC ( [id://282956]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

Hi,

I'd like to retrieve text included in a GUI type window (a label for instance). However the method provided in Win32::GuiTest (GetWindowText($windowID) only returns the title of the window for such windows as dialogs and popups.
Has anyone heard of another method that could retrieve text included in a popup (for example one generated by net send) ?

Thanks... FB

Heureux qui, comme Ulysse, a fait un beau voyage
Ou comme celui-là qui conquit la Toison,
Et puis est retourné plein d'usage et raison,
Vivre entre ses parents le reste de son âge!

J. du Bellay, poète angevin

  • Comment on Win32::GuiTest::GetWindowText does not return text ?

Replies are listed 'Best First'.
Re: Win32::GuiTest::GetWindowText does not return text ?
by Mr. Muskrat (Canon) on Aug 11, 2003 at 15:06 UTC

    After much trial and error, I came up with this snippet. As always, YMMV.

    Create a sample popup window:

    # popup.pl use Win32; Popup('testing popup detection...', 16, 'Some popup title'); sub Popup { my ($msg, $flags, $title) = @_; return Win32::MsgBox($msg, $flags, $title); die $msg; }

    Find the sample popup window:

    # findpopup.pl use Win32::GuiTest qw(:ALL :SW); my @windows = FindWindowLike(0, 'Some popup title'); for my $win (@windows) { print "Found window $win with title '", GetWindowText($win), "'\ +n"; my @children = GetChildWindows($win); for my $child (@children) { my $text = GetWindowText($child); next if ($text =~ /^\xff/); # you've found the icon next if ($text =~ /^OK|Cancel|Abort|Retry|Ignore|Yes|No$/); # +you've found a button print "Found child $child with text '$text'\n"; } }

    I ran popup.pl from the desktop and opened a command prompt and ran findpopup.pl from there.

    Output:
    Found window 4036 with title 'Some popup title'
    Found child 1444 with text 'testing popup detection...'

      After running a couple tests this morning (I posted the node just before leaving work yesterday) I came to the same conclusion that it actually returned child and parent windows... I had no idea that a popup window was actually made of 2 windows - it seems awkward surely...
      Thanks for your help !

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://282956]
Approved by Mr. Muskrat
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.