Win32-GuiTest
view release on metacpan or search on metacpan
lib/Win32/GuiTest.pm view on Meta::CPAN
SendMessage( $hwnd, TVM_EXPAND(), TVE_EXPAND(), $hItem );
#
# Give the node some time to expand...
#
select(undef, undef, undef, $delay) if $delay;
if( @parts == 1 ){
return $hItem;
}
if( $fields[ 8 ] ){
my $hChild = SendMessage( $hwnd,
TVM_GETNEXTITEM(),
TVGN_CHILD(),
$hItem );
shift( @parts );
return TVPathWalk( $hwnd,
$tvitem,
$text_buf,
$hChild,
$max_buf,
$delay,
@parts );
}
}else{
$hItem = SendMessage( $hwnd,
TVM_GETNEXTITEM(),
TVGN_NEXT(),
$hItem );
}
}
return 0;
}
=item GetTreeViewSelPath($window)
Returns a string containing the path (i.e., "parent|child") of
the currently selected tree view item.
$oldpath = GetTreeViewSelPath($window);
SelTreeViewItemPath($window, "Parent|Child");
SelTreeViewItemPath($window, $oldpath);
=cut
=item $hpopup = GetPopupHandle($hwnd, $x, $y, [$wait])
This function gets the handle of a popup window generated by
right-clicking at the $x and $y screen coordinates (absolute). An
optional delay can be entered which will wait the given number of
milliseconds after the right-click for the window to appear (default
is 50). Zero is returned when no popup menu is found.
=back
=head2 DibSect
A class to manage a Windows DIB section. Currently limited in functionality to
24-bit images. Pulled from old code into GuiTest when I (jurasz@imb.uni-karlsruhe.de)
needed to create several grayscale screen dumps.
Possible future extenstions: other color resolutions, loading, comparison of bitmaps,
getting from clipboard.
Synopsis:
$ds = new Win32::GuiTest::DibSect;
$ds->CopyWindow($w);
$ds->ToGrayScale();
$ds->SaveAs("bla.bmp");
$ds->ToClipboard();
=over 8
=item bool DibSect::CopyClient(hwnd,[rect])
Copy a client area of given window (or possibly its subset) into a given DibSect.
The rectangle may be optionally passed as a reference to 4-element array.
To get the right result make sure the window you want to copy is not obscured by
others.
=item bool DibSect::CopyWindow(hwnd)
Copy the window rectangle. Equivalent to
$ds->CopyClient(GetDesktopWindow(), \@{[GetWindowRect($w)]});
=item bool DibSect::SaveAs(szFile)
Save the current contents of the DIB section in a given file. With 24-bit
resolution it can grow quite big, so I immediately convert them to PNG (direct
writing of PNG seemed to complicated to implement).
=item bool DibSect::Invert()
Invert the colors in a current DIB section.
=item bool DibSect::ToGrayScale()
Convert the DibSection to the gray scale. Note that it is still encoded as 24-bit
BMP for simplicity.
=item bool DibSect::ToClipboard()
Copies the DibSect to clipboard (as an old-fashioned metafile), so that it can
be further processed with your favourite image processing software, for example
automatically using SendKeys.
=item bool DibSect::Destroy()
Destroys the contents of the DIB section.
=back
=cut
package Win32::GuiTest::Window;
sub new
{
my ( $proto, %params ) = @_;
my $class = ref( $proto ) || $proto;
my $self = {};
$self->{ '-handle' } = $params{ '-handle' };
bless( $self, $class );
return $self;
}
sub SetForegroundWindow
{
my $self = shift;
Win32::GuiTest::SetForegroundWindow( $self->{ '-handle' } );
}
sub GetWindowRect
{
my $self = shift;
return Win32::GuiTest::GetWindowRect( $self->{ '-handle' } );
}
1;
__END__
=head1 UNICODE SUPPORT
Currently (2007) there's no consensus about unicode input in Perl, so
the module declares function C<UnicodeSemantics> that sets whether
information queried from windows should use A or W syscalls. The
function that support this differentiation, and produce different
results depending on value set to C<UnicodeSemantics> is:
C<GetWindowText>, and all its callers, - FindWindowLike, WaitWindow,
WaitWindowLike
C<SendKeys> translated unicode characters into set of ALT+NUMPAD keystrokes.
Note that not all applications can understand unicode input.
=over
=item UnicodeSemantics [BOOL]
( run in 0.476 second using v1.01-cache-2.11-cpan-81fc1098f69 )