Hi fellow monks, This one has me stumped. I want to use Win32::GUI::AxWindow to load an HTML page and then capture when a user clicks on a link in that page. My intention is to run a subroutine based on the link that is clicked. When I try to capture the BeforeNavigate2 event Perl blows up. I can capture other events fine. Here is the code. What am I doing wrong?
#!perl use strict; use Win32::GUI; use Win32::GUI::AxWindow; ################ MAIN WINDOW ############# my $FormWindow = new Win32::GUI::Window( -name => "FormWindow", -text => "Test", -pos => [0,0], -size => [400,300], ); sub FormWindow_Resize{return 0;} sub FormWindow_Minimize {return 0;} sub FormWindow_Maximize {return 0;} sub FormWindow_Terminate {return -1;} ########################## # Add a WebBrowser AxtiveX my $Control = new Win32::GUI::AxWindow ( -parent => $FormWindow, -name => "Control", -control => "Shell.Explorer.2", #-control => "InternetExplorer.Application", #-control => "{8856F961-340A-11D0-A96B-00C04FD705A2}", -pos => [0, 0], -size => [400, 300], ); # # Register some event # When I try to register the following events, Perl blows up. # NavigateComplete2 # BeforeNavigate2 # NewWindow2 # These events work though # DownloadBegin # DocumentComplete # StatusTextChange $Control->RegisterEvent("StatusTextChange", sub { my $self = shift; my $eventid = shift; my $str=shift; print "Event [$eventid]: ", $str, "\n" if length($str) && $str + !~/done/is; } ); print "Calling Navigate\n"; # Call Method $Control->CallMethod("Navigate", 'http://www.google.com'); print "Done\n"; ########################## $FormWindow->Show(); Win32::GUI::Dialog(); exit;

In reply to Capturing a browser event in an ActiveX Browser Window by slloyd

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.