rt,3ks!

解决方案 »

  1.   

    IE中文本框并不是真正意义上的窗口,不过可以从坐标点获得最小窗口
    HWND CMyDlg::SmallestWindowFromPoint(const POINT point)
    {
    // Find the smallest "window" still containing the point
    // Doing this prevents us from stopping at the first window containing the point
    RECT rect, rectSearch;
    HWND hParentWnd, hWnd, hSearchWnd; hWnd = ::WindowFromPoint(point);
    if(hWnd != NULL)
    {
    // Get the size and parent for compare later
    ::GetWindowRect(hWnd, &rect);
    hParentWnd = ::GetParent(hWnd); // We only search further if the window has a parent
    if(hParentWnd != NULL)
    {
    // Search from the window down in the Z-Order
    hSearchWnd = hWnd;
    do{
    hSearchWnd = ::GetWindow(hSearchWnd, GW_HWNDNEXT); // Does the search window also contain the point, have the same parent, and is visible?
    ::GetWindowRect(hSearchWnd, &rectSearch);
    if(::PtInRect(&rectSearch, point) && ::GetParent(hSearchWnd) == hParentWnd && ::IsWindowVisible(hSearchWnd))
    {
    // It does, but is it smaller?
    if(((rectSearch.right - rectSearch.left) * (rectSearch.bottom - rectSearch.top)) < ((rect.right - rect.left) * (rect.bottom - rect.top)))
    {
    // Found new smaller window, update compare window
    hWnd = hSearchWnd;
    ::GetWindowRect(hWnd, &rect);
    }
    }
    }while(hSearchWnd != NULL);
    }
    } return hWnd;
    }
      

  2.   


    1。ie中的文本框如果不是窗口,究竟是什么?
    2。用ChildWindowFromaPoint行不行?
      

  3.   

    使用IHtmlDocument2接口可以获得IE窗口中的所有元素,包括文本框,然后获得IHtmlInputTextElement接口来获取其中的文本内容。具体实现可以参考msdn和我的源代码。 ( http://tnt-libra.myetang.com/iecaper_src.zip )
      

  4.   

    我是新手不懂com的!请问“IE中文本框并不是真正意义上的窗口”,那它是什么东东??我想IE是根据HTML文档的描述生成文本框这样的东东,但IE也应该是调用了系统的DLL去处理这样的文本框的啊?这样的文本框是不是IE的子窗体呢?如果不是,它是什么呢?我是菜鸟有很多不懂的,请大虾们赐教啊!
    3ks!!!
      

  5.   

    MSDN有例子程序。在其安装目录下有samples。
      

  6.   

    我的msdn里都是vb的例子啊?!
      

  7.   

    不是窗口,是自己画出来的。在很多Skin中有很多也是自己画出来的。在内部管理。
      

  8.   

    IHTMLDocument2::elementFromPoint Method--------------------------------------------------------------------------------Returns the element for the specified x and y coordinates. SyntaxHRESULT elementFromPoint(
        long x,
        long y,
        IHTMLElement **elementHit
    );
      

  9.   

    除了使用我上面的那种方法外
    使用COM的方法可以得到它里面的表单元素及句柄:
    CString GetPassword(IHTMLDocument2 *pDoc2,POINT pt)
    {
    if(pDoc2==NULL)return "";
    CComPtr<IHTMLElement> pElement;
    HRESULT hr=pDoc2->elementFromPoint(pt.x,pt.y,&pElement);
    if(SUCCEEDED(hr)){
    CComPtr<IHTMLInputTextElement> pPwdElement;
    hr=pElement->QueryInterface(IID_IHTMLInputTextElement,
    (void**)&pPwdElement);
    if(SUCCEEDED(hr)){
    CComBSTR type;
    hr=pPwdElement->get_type(&type);
    if(SUCCEEDED(hr)){
    if(type==_T("password")){
    CComBSTR pwd;
    hr=pPwdElement->get_value(&pwd);
    if(SUCCEEDED(hr)){
    if(pwd.Length()!=0){
    CComBSTR msg;
    msg=pwd;
    CString str(msg);
    return str;
    }
    else{
    return "";
    }
    }
    }
    }
    }
    }
        pDoc2->Release();
       return "";
     }
      

  10.   

    除了使用我上面的那种方法外
    使用COM的方法可以得到它里面的表单元素及句柄:
    CString GetPassword(IHTMLDocument2 *pDoc2,POINT pt)
    {
    if(pDoc2==NULL)return "";
    CComPtr<IHTMLElement> pElement;
    HRESULT hr=pDoc2->elementFromPoint(pt.x,pt.y,&pElement);
    if(SUCCEEDED(hr)){
    CComPtr<IHTMLInputTextElement> pPwdElement;
    hr=pElement->QueryInterface(IID_IHTMLInputTextElement,
    (void**)&pPwdElement);
    if(SUCCEEDED(hr)){
    CComBSTR type;
    hr=pPwdElement->get_type(&type);
    if(SUCCEEDED(hr)){
    if(type==_T("password")){
    CComBSTR pwd;
    hr=pPwdElement->get_value(&pwd);
    if(SUCCEEDED(hr)){
    if(pwd.Length()!=0){
    CComBSTR msg;
    msg=pwd;
    CString str(msg);
    return str;
    }
    else{
    return "";
    }
    }
    }
    }
    }
    }
        pDoc2->Release();
       return "";
     }
      

  11.   

    除了使用我上面的那种方法外
    使用COM的方法可以得到它里面的表单元素及句柄:
    CString GetPassword(IHTMLDocument2 *pDoc2,POINT pt)
    {
    if(pDoc2==NULL)return "";
    CComPtr<IHTMLElement> pElement;
    HRESULT hr=pDoc2->elementFromPoint(pt.x,pt.y,&pElement);
    if(SUCCEEDED(hr)){
    CComPtr<IHTMLInputTextElement> pPwdElement;
    hr=pElement->QueryInterface(IID_IHTMLInputTextElement,
    (void**)&pPwdElement);
    if(SUCCEEDED(hr)){
    CComBSTR type;
    hr=pPwdElement->get_type(&type);
    if(SUCCEEDED(hr)){
    if(type==_T("password")){
    CComBSTR pwd;
    hr=pPwdElement->get_value(&pwd);
    if(SUCCEEDED(hr)){
    if(pwd.Length()!=0){
    CComBSTR msg;
    msg=pwd;
    CString str(msg);
    return str;
    }
    else{
    return "";
    }
    }
    }
    }
    }
    }
        pDoc2->Release();
       return "";
     }
      

  12.   

    我不懂COM什么的啊!能不能用windows的API实现呢?我曾试过用WindowFromPoint, ChildWindowFromaPoint等api,但是好象不行
      

  13.   

    ie里的text和window中的Text不一样的,你应该用COM
      

  14.   

    整个页面只是一个窗口,它的类名是Internet Explorer_Server.谁要是能单独得到那个输入框的句柄,我给他300分.
      

  15.   

    就如我上面所说,如果不用COM,从鼠标点也可以得到附近最小的窗口。
    BCB_FANS:你要得到那个句柄干什么,其实输入框的属性及文本等都可以得到的。
      

  16.   

    就如我上面所说,如果不用COM,从鼠标点也可以得到附近最小的窗口。
    BCB_FANS:你要得到那个句柄干什么,其实输入框的属性及文本等都可以得到的。