How to get the URL out of FireFox

This is a discussion on How to get the URL out of FireFox within the C++ Programming forums, part of the General Programming Boards category; Hello World, I'm pretty new to the c++ language and I want to read the URL of a running Browser ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    1

    How to get the URL out of FireFox

    Hello World,

    I'm pretty new to the c++ language and I want to read the URL of a running Browser (in this case FireFox).

    It shoud work in this way.

    you write in the browser: "www.goooogle.de"
    Press enter
    ---> copy url to my program.
    ---> check url == Google
    if not ---> insert google.de

    Is there a documentation for programming firefox addons?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Is there a documentation for programming firefox addons?
    Why don't you google for something like "programming firefox extensions"? That seems like a much better idea than asking here.

    At any rate, one of the first search results is this site which looks like a good tutorial.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    On Windows, reading the current URL can be done easyly with Windows api (see on Win32 ng)

  4. #4
    Registered User CrissyCrisCris's Avatar
    Join Date
    Aug 2009
    Posts
    13
    First get the HWND for the address text box in teh firefox exlporer. you can use programs like Spy++ (I forgot what it was called, but it came with Microsoft Visual Studio 6.0). The you can use SendMessage and send a WM_GETTEXT message to it.

    Here is an example
    Code:
    HWND hFireFox, hAddressBox;
    hFireFox = FindWindow("FireFox", "FireFox");
    hAddressBox = FindWindowEx(hFireFox, NULL, MAKEINTATOM(0x800), "AddressBox");  //Forgot what the 3rd parameter does
    char szAddressBox[MAX_PATH];
    SendMessage(hAddressBox, WM_GETTEXT, MAX_PATH, szAddressBox);
    I haven't tested this out yet, so there might be a few errors from the LPSTR to CHAR[] conversion. I also didn't get the correct names for the firefox menus.

    To check use strcmp() and use WM_SETTEXT to send text to firefox

    Code:
    if (strcmp(hAddressBox, "www.google.de") != 0)
    {
         \\if false then...
         SendMessage(hAddressBox, WM_SETTEXT, NULL, "www.google.de\0");
    }
    Last edited by CrissyCrisCris; 08-13-2009 at 08:49 AM.

  5. #5
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    You can use the boost filesystem library. They make it convenient to work with URLS. Also, you could just use find_if and then tokenize your searches.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,668
    Actually, CrissyCrisCris, it would be better if you provide C++ solutions on the C++ board rather than C solutions. I second boost.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. URL escape issue
    By George2 in forum C# Programming
    Replies: 2
    Last Post: 08-12-2008, 11:45 AM
  2. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  3. Problems with Firefox
    By DavidP in forum Tech Board
    Replies: 28
    Last Post: 12-21-2007, 08:35 AM
  4. Different Firefox question...
    By gcn_zelda in forum Tech Board
    Replies: 8
    Last Post: 06-13-2006, 10:51 AM
  5. HTML tables with firefox and IE nightmare
    By MisterSako in forum Tech Board
    Replies: 6
    Last Post: 03-01-2006, 12:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21