I am playing win Internet explorer in the Win32::HUI::AxWindow and OLE.
Downloading and displaying pages looks good and easy, howevere I can not figure
out
if the page has frames how do I treat these frames, means, first , how do
I know if the page has frames or not, and if it has frames, how do I get
the html code, the page source of each frame and how do I know when all
frames are fully loaded.
Is there a docs anywhere on the properties and methods tree of the object
Also what is the difference between, DocumentComplete and DownloadComplete
events
Thanks in advance for reply
Ramy
use Win32::GUI;
use Win32::OLE;
use Win32::GUI::AxWindow;
$|=1;
# main Window
$Window = new Win32::GUI::Window (
-title => "Win32::GUI::AxWindow and Win32::OLE",
-pos => [100, 100],
-size => [600, 600],
-name => "Window",
) or die "new Window";
# Create AxWindow
$Control = new Win32::GUI::AxWindow (
-parent => $Window,
-name => "Control",
-pos => [0, 0],
-size => [400, 300],
-control => "Shell.Explorer", #Shell.Explorer,
Shell.Explorer.1, Shell.Explorer.2
-visible => 01,
) or die "new Control";
# Get Ole object
$OLEControl = $Control->GetOLE();
# Register Event
$Control->RegisterEvent ("DocumentComplete", "DocumentComplete_Event" );
#$Control->RegisterEvent ("DownloadComplete", "DownloadComplete_Event" );
# $Control->Navigate('http://www.google.com', 1,'_BLANK');
# $OLEControl->Navigate("http://www.yahoo.com");
$Control->CallMethod("Navigate", "http://www.yahoo.com");
#print "xx: ", $OLEControl->GetProperty("Document"),"\n";
#$OLEControl->SetProperty('StatusBar', 1);
$Window->Show();
[EMAIL PROTECTED] = $Control->EnumPropertyID();
#print join "\n", @list;
@list = $Control->EnumPropertyName ();
#print "\n----------------Property:------------------\n", join "\n", @list,
"\n--------------------------\n";
@list = $Control->EnumMethodName();
#print "\n----------------Methods:------------------\n", join "\n", @list,
"\n--------------------------\n";
@list = $Control->EnumEventName();
#print "\n----------------Events:------------------\n", join "\n", @list,
"\n--------------------------\n";
#print "HTML: ",$OLEControl->{Document}, "\n";
#%x = $Control->GetPropertyInfo("Document");
#while (($k, $v) = each %x) {print "P: $k=$v\n";}
#%x = $Control->GetPropertyInfo("LocationURL");
#while (($k, $v) = each %x) {print "L: $k=$v\n";}
#print "HTML = ", $OLEControl->{Document}->{body}->innerHTML, "\n";
Win32::GUI::Dialog();
#==============================================================
sub DownloadComplete_Event{
print join "\n", @_,"\n";
print "Done URL: ", $OLEControl->{LocationUrl}, "\n";
print "HTML = ", $OLEControl->{Document}->{body}->innerHTML, "\n";
#$OLEControl->Stop;
#$Control->Hide();
}
#==============================================================
#==============================================================
sub DocumentComplete_Event {
my ($Obj, $x, $y, $URL) = @_;
#print "($Obj, $x, $URL)\n";
print "Done URL: ", $OLEControl->{LocationUrl}, "\n";
#print "Cookies = ", $OLEControl->{Document}->{Cookie}, "\n";
#print "HTML = ",
$OLEControl->{Document}->{frames}->{0}->{Document}->{body}->{innerHTML}, "\n";
#print "HTML = ",
$OLEControl->{Document}->{frames}->{1}->{Document}->{body}->{innerHTML}, "\n";
# my $Length = $OLEControl->{Document}->{frames}->length;
# print "Length=$Length\n\n";
# my $all = $OLEControl->{Document}->{frames};
# print "\$all=$all\n";
#%x = %{$OLEControl->{Document}->{frames}};
#while (($k, $v) = each %x) {print "F: $k=$v\n";}
#List all HTML TAG
# for $i (0..$all->length) {
# my $item = $all->item($i);
# print "TAG: $i = ", $item->outerHTML , "\n\n";
# print "TAG: $i = ", $item->innerHTML , "\n\n";
#print "TAG: $i = ", $item->innerText, "\n\n";
#print "TAG: $i = ", $item->outerText, "\n\n";
# }
}
# Main window event handler
sub Window_Terminate {
# Release all before destroy window
undef $OLEControl;
$Control->Release();
return -1;
}
sub Window_Resize {
if (defined $Window) {
($width, $height) = ($Window->GetClientRect)[2..3];
#$Control->Resize ($width, $height);
$Control->Resize ($width, 500);
}
}