in reply to Perl application to read the current browser page

Assuming that you are on a Win32 platform (does IE still run on Macs?), this could be done from perl.

It would not be easy, and it would require either a pretty goood understanding of the Win32 APIs or a lot of research and perseverance.

The best starting point would be to look at Win32::GuiTest. Look into the source as the POD as displayed on cpan does not mention most of the functionality available within this module. The particular part of the source that is interesting is the @EXPORT_OK section that lists all the APIs that can be exported by the module. It begins.

@EXPORT_OK = qw( $debug ClientToScreen FindWindowLike GetChildDepth GetChildWindows GetClassName GetCursorPos GetDesktopWindow GetComboText GetComboContents GetListText GetListContents GetParent GetScreenRes GetWindow GetWindowID GetWindowLong GetWindowRect GetWindowText

Most of these function are undocumented in the pod from what I can see, but if you use an interactive debugger session you can explore the apis listed in the source and get a (brief) usage for them as shown here.

perl -de1 C:\test>perl -de1 Default die handler restored. Loading DB routines from perl5db.pl version 1.07 Editor support available. Enter h or `h h' for help, or `perldoc perldebug' for more help. main::(-e:1): 1 DB<1> use Win32::GuiTest qw[:ALL :SW] DB<5> print GetForegroundWindow( 'A totally meaningless parameter' ) Usage: Win32::GuiTest::GetForegroundWindow() at (eval 8)[E:/Perl/lib/p +erl5db.pl:1521] line 2. DB<7> $f = GetForegroundWindow() DB<8> print $f 346162044 DB<10> GetWindowText() Usage: Win32::GuiTest::GetWindowText(hwnd) at (eval 13)[E:/Perl/lib/pe +rl5db.pl:1521] line 2. DB<12> print GetWindowText( $f ) Command Prompt - perl5.6.1 -de1

If any of this makes sense to you and you wish to pursue this course, get that far and come back with any specific qustions you have and I'll try to help further.

Good luck.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Replies are listed 'Best First'.
Re: Re: Perl application to read the current browser page
by cfreak (Chaplain) on Jul 18, 2003 at 14:54 UTC

      Maybe I am mis-interpreting the OP, but I don't see any mention of "across the network" in his post?

      The impression I got from the post was that the small window was at the bottom of the screen on the same machine as the web browser was running?

      Now, if the OP meant that he wants the text replicated in a small textfield or at the bottom of the browser window then maybe I misinterpreted him... but if thats so, a clearer description would have been nice.

      He also says "Say I have my Netscape or IE browser open on a webpage; after opening this application..." which further reenforces my interpretation that this is an application intended to run on the same machine as the browser window, not something used remotely...but hey, I've been known to misinterpret people before:)


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

        Ahh yes you are correct. I read it as "small browser window" rather than "small window". I believe I have made the misinterpretation :). Though I agree the original poster is light on details.

        Lobster Aliens Are attacking the world!
Re^2: Perl application to read the current browser page
by McMahon (Chaplain) on Jun 28, 2004 at 21:40 UTC
    So a year later...

    I see no evidence that "GetComboText" or "GetComboContents" exist at all. Attempting to use either yields
    "Undefined subroutine &main::GetComboText(Contents) called at..."


    Any suggestions would be welcome.

      They do exist. vis.

      P:\test>type 275606.pl #! perl -slw use strict; use Win32::GuiTest qw[ GetComboText GetComboContents ]; eval{ GetComboText() } or print $@; eval{ GetComboContents() } or print $@; P:\test>275606 Usage: Win32::GuiTest::GetComboText(hwnd, index) at P:\test\275606.pl +line 5. Usage: Win32::GuiTest::GetComboContents(hWnd) at P:\test\275606.pl lin +e 6.

      Though the documentation for them seems to be completely absent. Looking through guitest.xs, GetComboText() & GetComboContents() map to a calls to GetTextHelper()

      SV* GetComboText(hwnd, index) HWND hwnd; int index CODE: RETVAL = GetTextHelper(hwnd, index, CB_GETLBTEXTLEN, CB_GETLBT +EXT); OUTPUT: RETVAL SV* GetComboText(hwnd, index) HWND hwnd; int index CODE: RETVAL = GetTextHelper(hwnd, index, CB_GETLBTEXTLEN, CB_GETLBT +EXT); OUTPUT: RETVAL

      Which in turn gets mapped to calls to SendMessage().

      SV* GetTextHelper(HWND hwnd, int index, UINT lenmsg, UINT textmsg) { SV* sv = 0; int len = SendMessage(hwnd, lenmsg, index, 0L); char* text = (char*)safemalloc(len+1); if (text != 0) { SendMessage(hwnd, textmsg, index, (LPARAM)text); sv = newSVpv(text, len); safefree(text); } return sv; }

      So, it would be a case of fightling your way through the MSDN documentation relating to ComboBoxes to work out what and how and why, which the module author must have done to bring you the module in the first place. All of which reenforces my opening comments above:

      It would not be easy, and it would require either a pretty goood understanding of the Win32 APIs or a lot of research and perseverance.

      It all comes down to how desperately you need to do this.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "Think for yourself!" - Abigail
      "Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon
Re: Re: Perl application to read the current browser page
by Anonymous Monk on Jul 19, 2003 at 18:14 UTC
    I need the application to be running on Unix platform . Please let me know if this can be done on Unix platform using Perl . Thankyou !

      My knowledge of Unix is far to old and out-of-date to be of any use with this. Does IE even run on unix platforms?

      In any case, the description you have provided is far from clear. You give a very breif description a replicating bits of text from a browser window into another window as the mouse moves over the former, and you say you want to do this is perl. What is absent from your description is why you are trying to do this.

      I am reminded of a project I was involved in a few years ago. It was a screen reader/speech synthesizer to allow vision impaired users to navigate/read a GUI desktop (the OS/2 Presentation Manager in that case). My contribution was adding the hooks into the guts of the OS to allow an add-on application to track the cursor and access the text beneath it. I can tell you that it required some highly optimised C/assembler code to make this happen in real time, and that was just tracking the cursor and text under it. The speech synthesis was performed by an external dedicated processor. Whilst processors are nearly a hundred times more powerful now, I still think that it is unlikely that it would be usuable if written in a partially interpreted language like perl even now.

      If you provided a fuller explanation of what you are trying to achieve rather than what you think is the way to achieve it, you may well get some good suggestion from the wide range of able and willing unix guys assembled here.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

        Can u tell me how can i add-on an application to Netscape to get the text under cursor position . Can I get a plugin which will do the job for me . Please let me know on tht . Thankyou !
Re: Re: Perl application to read the current browser page
by Anonymous Monk on Jul 20, 2003 at 11:17 UTC
    Hi , I need some more explanation on what u suggested . Perhaps a few more detailed expalnation . Also how can i incorporate Win API in perl on Unix ??? Thankyou !

      You can't. The possibility I spoke of would only be possible if your platform was Win32.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller