locked
FindWindow usage RRS feed

  • Question

  • Hi all. I've narrowed my searches of the FindWindow function down and found out a  lot what i was doing wrong. However i still have a problem, the function compiles and works fine, because i used if/else statements to make sure it was working up until the end. Im trying to get the address bar of IE but i keep failing. I remembered Spy++ 6.0 and used it to find out the class that the address bar is in.

    From what i've found out they go in order:
    IEFrame
    WorkerW
    ReBarWindow32
    Address Band Root
    ComboBoxEx32
    ComboBox
    Edit

    heres my code:

    #include <windows.h>
    #include <stdio.h>
    #include <fstream>
    using namespace std;
    int main()
    {
       char addy[MAX_PATH];
       HWND handle=FindWindow("IEFrame", "Internet Explorer");
        handle=FindWindowEx(handle, 0, "WorkerW", "Navigation Bar");
        handle=FindWindowEx(handle, 0, "ReBarWindow32", 0);
        handle=FindWindowEx(handle,0,"ComboBoxEx32",0);
        handle=FindWindowEx(handle,0,"ComboBox",0);
        handle=FindWindowEx(handle,0,"Edit",0);
      GetWindowText(handle, addy, MAX_PATH);
      if(strstr(addy,"http:") !=NULL)
          printf("Address is: %s\n",addy);
      else
          printf("Nothing was found\n");
     
      system("pause");
      return 0;
    }

    Any suggestions? Thanx in advance
    Wednesday, December 27, 2006 6:57 AM

Answers

  •  dellthinker wrote:

    HWND handle=FindWindow("IEFrame", "Internet Explorer");


    I found one problem in your code. FindWindow return a window handle only if a window whcih has the specified class name and exactly specified Window Text. "Internet explorer" may be not matching with it's orginal title.

    Just pass NULL to the ignorable parameter.

    e.g
    HWND handle=FindWindow("IEFrame", NULL);

    HTH
    Thursday, December 28, 2006 7:35 AM

All replies

  •  dellthinker wrote:

    HWND handle=FindWindow("IEFrame", "Internet Explorer");


    I found one problem in your code. FindWindow return a window handle only if a window whcih has the specified class name and exactly specified Window Text. "Internet explorer" may be not matching with it's orginal title.

    Just pass NULL to the ignorable parameter.

    e.g
    HWND handle=FindWindow("IEFrame", NULL);

    HTH
    Thursday, December 28, 2006 7:35 AM
  • Hello

     

    Re: FindWindow usage

     

    I am going to mark this thread as answered since you have not followed up with any further information on your problem - I assume you solved the problem yourself or one of the suggestions in this thread helped you solved the problem. If you have a solution you could post it so others can find it. If you do not have a solution then please submit further details and then mark the thread as unanswered.

     

    Thanks

    Damien

     

    Wednesday, January 10, 2007 7:56 PM