cro*_*wdy 2 windows perl internet-explorer automation win32ole
我正在努力控制一个IE预览控件,它是带有perl的外部Windows应用程序上的'Internet Explorer_Server'类.
Internet Explorer_Server是窗口的类名,我用Spy ++找到它.这是我的断言代码
$className = Win32::GUI::GetClassName($window);
if ($className eq "Internet Explorer_Server") {
...
}
Run Code Online (Sandbox Code Playgroud)
我可以使用"Internet Explorer_Server"处理Win32::GUI::GetWindow,但不知道下一步该做什么.
更新:你走错了路.你需要的是什么Win32::OLE.
#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE;
$Win32::OLE::Warn = 3;
my $shell = get_shell();
my $windows = $shell->Windows;
my $count = $windows->{Count};
for my $item ( 1 .. $count ) {
my $window = $windows->Item( $item );
my $doc = $window->{Document};
next unless $doc;
print $doc->{body}->innerHTML;
}
sub get_shell {
my $shell;
eval {
$shell = Win32::OLE->GetActiveObject('Shell.Application');
};
die "$@\n" if $@;
return $shell if defined $shell;
$shell = Win32::OLE->new('Shell.Application')
or die "Cannot get Shell.Application: ",
Win32::OLE->LastError, "\n";
}
__END__
Run Code Online (Sandbox Code Playgroud)
因此,此代码找到一个带有Document属性的窗口并打印HTML.您必须决定使用哪个标准来查找您感兴趣的窗口.