Attached patch will add new functions qw(Maximize Minimize Hide Show
Resize Move SetForegroundWindow BringWindowToTop
SetActiveWindow) to Win32::IEAutomation, that will call same functions
for browser window created by Win32::IEAutomation object from
Win32::GUI, if it present or just carp about absence of Win32::GUI
otherwise. If present, Win32::GUI also will be used instead of
Win32::IEAutomation::WinClicker to maximize window, guaranteeing that
it will maximize window created by Win32::IEAutomation and not some
other. Another added small getHWND function will return IE window
handle, suitable for other functions from Win32::GUI and similar modules.
Subject: | Win32-IEAutomation-Win32-GUI.patch |
--- old\Win32\IEAutomation.pm 2006-09-25 13:43:12.274429000 +0400
+++ new\Win32\IEAutomation.pm 2006-09-26 17:52:41.303667500 +0400
@@ -6,10 +6,26 @@
use Win32::IEAutomation::Element;
use Win32::IEAutomation::Table;
use Win32::IEAutomation::WinClicker;
+use Carp;
use vars qw($VERSION $warn);
$VERSION = '0.5';
+# Bring in methods to manipulate windows from Win32::GUI module, if it is available
+foreach my $name(qw(Maximize Minimize Hide Show Resize Move SetForegroundWindow BringWindowToTop SetActiveWindow)){
+ no strict 'refs';
+ my $win32guiname="Win32::GUI::$name";
+ *$name = sub {
+ eval { local $SIG{__DIE__}; require Win32::GUI; };
+ unless($@){
+ &$win32guiname(shift->{agent}->{HWND}, @_);
+ }else{
+ $@="";
+ carp "No Win32::GUI module available for call to $name";
+ }
+ };
+}
+
sub new {
my $class = shift;
my %options = @_;
@@ -39,10 +55,15 @@
Win32::OLE->WithEvents($self->{agent});
$self->{agent}->{Visible} = $visible;
if ($maximize){
+ eval { local $SIG{__DIE__}; require Win32::GUI; };
+ unless($@){
+ Win32::GUI::Maximize($self->{agent}->{HWND});
+ }else{
my $clicker = Win32::IEAutomation::WinClicker->new();
$clicker->maximize_ie();
undef $clicker;
}
+ }
return $self;
}
@@ -56,6 +77,10 @@
$self->{element};
}
+sub getHWND{
+ return shift->{agent}->{HWND};
+}
+
sub closeIE{
my $self = shift;
my $agent = $self->{agent};