use Win32::GUI;
use Win32::GUI::DIBitmap;
use Win32::GuiTest qw(FindWindowLike GetWindowText);
my $W = new Win32::GUI::Window (
-title => "Test Window",
-pos => [100, 100],
-size => [400, 400],
-name => "Window"
);
$W->AddButton (
-pos => [100, 100],
-size => [200, 200],
-text => 'tstbtn',
-name => "Button",
-visible => 1
);
$W->Show();
Win32::GUI::Dialog();
my $hdc = Win32::GUI::DC->new($W);
print "hcd is $hdc\n";
print "Window name is '" . GetWindowText($W->{-handle}) . "'\n";
for my $x(keys %{$hdc})
{
print"$x --> $hdc->{$x}\n";
}
print "ERROR: $!\n"
unless my $bmap = Win32::GUI::DIBitmap->newFromDC($hdc);
print "bmap2 is $bmap\n";
my $test = $bmap->SaveToFile("c:/z.bmp");
print "TEST: $test\n";
print "==============================\n";
my @windows = FindWindowLike(0, qr/^search.cpan.org/);
my $hdc2 = Win32::GUI::DC->new($windows[0]);
print "hcd2 is $hdc2\n";
print "Window name is '" . GetWindowText($windows[0]) . "'\n";
for my $x(keys %{$hdc2})
{
print"$x --> $hdc2->{$x}\n";
}
print "HDC2 ERROR: $^E\n"
unless my $bmap2 = Win32::GUI::DIBitmap->newFromDC($hdc2);
print "bmap2 is $bmap2\n";
my $test2 = $bmap2->SaveToFile("c:/z2.bmp");
print "TEST2: $test2\n";
####
W - Button --> Win32::GUI::Button=HASH(0x205c158)
W - -type --> 0
W - -name --> Window
W - -handle --> 4001032
W - -accel --> 0
hcd is Win32::GUI::DC=HASH(0x183f17c)
Window name is 'Test Window'
-window --> 4001032
-handle --> -805233257
bmap2 is Win32::GUI::DIBitmap=SCALAR(0x1fbb988)
TEST: 1
==============================
window[0] = 6490244
Can't call method "SaveToFile" on an undefined value at C:\projects\Perl-9.pl line 51.
hcd2 is Win32::GUI::DC=HASH(0x1fb8980)
Window name is 'search.cpan.org: Win32::GuiTest - Alternate distribution of Perl GUI Test Utilities. - Microsoft Internet Explorer'
-handle --> 6490244
HDC2 ERROR: The handle is invalid
bmap2 is
####
use Win32::GUI;
use Win32::GUI::DIBitmap;
use Win32::GuiTest qw(FindWindowLike GetWindowText GetClassName);
my @windows = FindWindowLike(0, qr/^Linux/);
print "windows[0] = $windows[0]\n";
my $fakeit = {};
bless($fakeit,GetClassName($windows[0]));
$fakeit->{-handle} = $windows[0];
$fakeit->{-name} = GetWindowText($windows[0]);
print "FAKEIT = " . $fakeit->{-handle} . "\n";
my $hdc3 = Win32::GUI::DC->new($fakeit);
print "hcd3 is $hdc3\n";
print "Window name is '" . GetWindowText($windows[0]) . "'\n";
for my $x(keys %{$hdc3})
{
print"$x --> $hdc3->{$x}\n";
}
print "HDC3 ERROR: $^E\n"
unless my $bmap3 = Win32::GUI::DIBitmap->newFromDC($hdc3);
print "bmap3 is $bmap3\n";
my $test3 = $bmap3->SaveToFile("c:/z3.bmp");
print "TEST3: $test3\n";
####
CLASS: Win32::GUI::DC
WINDOW: Win32::GUI::Window=HASH(0x21b8f20)
WINDOW HANDLE: 1576184
W - Button --> Win32::GUI::Button=HASH(0x205bb0c)
W - -type --> 0
W - -name --> Window
W - -handle --> 1576184
W - -accel --> 0
hcd is Win32::GUI::DC=HASH(0x183f17c)
Window name is 'Test Window'
-window --> 1576184
-handle --> -1727981239
bmap2 is Win32::GUI::DIBitmap=SCALAR(0x1fb620c)
TEST: 1
==============================
window[0] = 6490244
CLASS: Win32::GUI::DC
WINDOW:
WINDOW HANDLE:
hcd2 is Win32::GUI::DC=HASH(0x1fba4c0)
handle is
Window name is 'search.cpan.org: Win32::GuiTest - Alternate distribution of Perl GUI Test Utilities. - Microsoft Internet Explorer'
-window -->
-handle --> 402723759
bmap2 is Win32::GUI::DIBitmap=SCALAR(0x1fac690)
TEST2: 1
==============================
windows[0] = 329430
Can't call method "SaveToFile" on an undefined value at C:\projects\Perl-9.pl line 83.
FAKEIT = 329430
CLASS: Win32::GUI::DC
WINDOW: Van Dyke Technologies - SecureCRT=HASH(0x1fac660)
WINDOW HANDLE: 329430
hcd3 is Win32::GUI::DC=HASH(0x1fa45e0)
Window name is 'LinuxVPN - SecureCRT'
-window --> 329430
-handle --> -2113858809
HDC3 ERROR:
bmap3 is