Dear fellow monks,
I need to write an app that opens an Internet Explorer browser and navigates to a certain URL, say www.google.com. Then, I should grab whatever text the user enters in the search form of the page. Is there a way to do that through Win32::OLE?
Reading http://www.perl.com/pub/a/2005/04/21/win32ole.html has helped me navigate to the requested URL and see the events printed in my screen but I haven't found info on how to get the user typed info after the click of the 'Search' button.
Any help would be appreciated!
use Tk;
use Win32;
use Win32::OLE qw(EVENTS);
$mw = new MainWindow (-title => "Application to replicate user data fr
+om web page");
# simple buttons to close IE or application
$mw->geometry("350x100+200+200");
$mw->resizable(0,0);
$customfont = "helvetica 10";
my $closeexlorerbutton = $mw -> Button(-text => "Close IE",
-font => "fixed 10 bold",
-height => "1",
-width => "14",
-command =>\&closeie)
-> place(-x => 200, '-y' => 50);
my $exitbutton = $mw -> Button(-text => "Cancel",
-font => "fixed 10 bold",
-height => "1",
-width => "14",
-command =>\&exitProgram)
-> place(-x => 50, '-y' => 50);
# open browser window and navigate to URL
my $URL = "http://www.google.co.uk";
$IE = Win32::OLE->new("InternetExplorer.Application")
|| die "Could not start Internet Explorer.Application, Win32::OLE:
+:LastError()\n";
Win32::OLE->WithEvents($IE,\&Event,"DWebBrowserEvents2");
$IE->{visible} = 1;
$IE->Navigate($URL);
Win32::OLE->MessageLoop();
MainLoop;
sub exitProgram {
my $response = $mw -> messageBox(-message=>"Are you sure you want
+to exit?",
-type=>'yesno',
-icon=>'question');
if ( $response eq "yes" or $response eq "Yes" ) {
exit;
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.