Get active page HTML content and URL

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Get active page HTML content and URL

Meglio
I'm trying to realize the C++ library with the unique function to get
active page HTML content and URL.

I'm getting the main IAccessible for the Mozilla, then I'm enumerating
all its childs to find the active
tab. The IAccessible is too slow, but with my algorithm it is even
more slowly because of enumerating.

Here is function which I use:

IAccessible* FindContentWindow(IAccessible* pAcc)
{
    IAccessible* pAccResult = NULL;
    long childCount = 0;
    HRESULT hResult;
    WCHAR cl[256];
    GetObjectClass(pAcc, cl, sizeof(cl));

    if (NULL != wcsstr(cl, _T("MozillaContentWindowClass")))
    {
        HWND hWnd;
        if(S_OK == WindowFromAccessibleObject(pAcc,  &hWnd))
        {
            if(hWnd)
                if (IsWindowVisible(hWnd))
                    return pAcc;
        }

        return NULL;
    }

    pAcc -> get_accChildCount(&childCount);

    IEnumVARIANT* pEnum = NULL;
    hResult = pAcc -> QueryInterface(IID_IEnumVARIANT,
(void**)&pEnum);

    if (hResult != S_OK || pEnum == NULL)
        return NULL;

    pEnum -> Reset();

    for (long i = 0; i < childCount; i++)
    {
        VARIANT varChild;
        ULONG fetched;
        IDispatch* pDisp = NULL;

        pEnum -> Next(1, &varChild, &fetched);

        if (varChild.vt == VT_I4)
        {
            pAcc -> get_accChild(varChild, &pDisp);
        }
        else
        {
            pDisp = varChild.pdispVal;
        }

        if (pDisp != NULL)
        {
            IAccessible* pAccChild = NULL;
            hResult = pDisp -> QueryInterface(IID_IAccessible,
(void**)&pAccChild);
            pDisp -> Release();

            if (hResult == S_OK && pAccChild != NULL)
            {
                pAccResult = FindContentWindow(pAccChild);
                if (pAccResult != NULL)
                    return pAccResult;
            }
        }
    }

    return pAccResult;

};

Then I have functions to get HTML and URL from IAccessible returned by
this function.

Anybody can help with the right idea?

_______________________________________________
dev-accessibility mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-accessibility
Reply | Threaded
Open this post in threaded view
|

Re: Get active page HTML content and URL

Aaron Leventhal-3
There is a very quick way to do this.

This is on our doc page for Windows AT developers, under the heading "How to
Find the Content Window and Load the Document"
http://www.mozilla.org/access/windows/at-apis#content-window

Also, the accessible of the content window is equal to the URL.

- Aaron


Meglio wrote:

> I'm trying to realize the C++ library with the unique function to get
> active page HTML content and URL.
>
> I'm getting the main IAccessible for the Mozilla, then I'm enumerating
> all its childs to find the active
> tab. The IAccessible is too slow, but with my algorithm it is even
> more slowly because of enumerating.
>
> Here is function which I use:
>
> IAccessible* FindContentWindow(IAccessible* pAcc)
> {
>     IAccessible* pAccResult = NULL;
>     long childCount = 0;
>     HRESULT hResult;
>     WCHAR cl[256];
>     GetObjectClass(pAcc, cl, sizeof(cl));
>
>     if (NULL != wcsstr(cl, _T("MozillaContentWindowClass")))
>     {
>         HWND hWnd;
>         if(S_OK == WindowFromAccessibleObject(pAcc,  &hWnd))
>         {
>             if(hWnd)
>                 if (IsWindowVisible(hWnd))
>                     return pAcc;
>         }
>
>         return NULL;
>     }
>
>     pAcc -> get_accChildCount(&childCount);
>
>     IEnumVARIANT* pEnum = NULL;
>     hResult = pAcc -> QueryInterface(IID_IEnumVARIANT,
> (void**)&pEnum);
>
>     if (hResult != S_OK || pEnum == NULL)
>         return NULL;
>
>     pEnum -> Reset();
>
>     for (long i = 0; i < childCount; i++)
>     {
>         VARIANT varChild;
>         ULONG fetched;
>         IDispatch* pDisp = NULL;
>
>         pEnum -> Next(1, &varChild, &fetched);
>
>         if (varChild.vt == VT_I4)
>         {
>             pAcc -> get_accChild(varChild, &pDisp);
>         }
>         else
>         {
>             pDisp = varChild.pdispVal;
>         }
>
>         if (pDisp != NULL)
>         {
>             IAccessible* pAccChild = NULL;
>             hResult = pDisp -> QueryInterface(IID_IAccessible,
> (void**)&pAccChild);
>             pDisp -> Release();
>
>             if (hResult == S_OK && pAccChild != NULL)
>             {
>                 pAccResult = FindContentWindow(pAccChild);
>                 if (pAccResult != NULL)
>                     return pAccResult;
>             }
>         }
>     }
>
>     return pAccResult;
>
> };
>
> Then I have functions to get HTML and URL from IAccessible returned by
> this function.
>
> Anybody can help with the right idea?
>
_______________________________________________
dev-accessibility mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-accessibility
Reply | Threaded
Open this post in threaded view
|

Re: Get active page HTML content and URL

Aaron Leventhal-3
 > Also, the accessible of the content window is equal to the URL.
I mean to say the accessible value of the IAccessible you get back for the
content window.

- Aaron


Aaron Leventhal wrote:

> There is a very quick way to do this.
>
> This is on our doc page for Windows AT developers, under the heading
> "How to Find the Content Window and Load the Document"
> http://www.mozilla.org/access/windows/at-apis#content-window
>
> Also, the accessible of the content window is equal to the URL.
>
> - Aaron
>
>
> Meglio wrote:
>> I'm trying to realize the C++ library with the unique function to get
>> active page HTML content and URL.
>>
>> I'm getting the main IAccessible for the Mozilla, then I'm enumerating
>> all its childs to find the active
>> tab. The IAccessible is too slow, but with my algorithm it is even
>> more slowly because of enumerating.
>>
>> Here is function which I use:
>>
>> IAccessible* FindContentWindow(IAccessible* pAcc)
>> {
>>     IAccessible* pAccResult = NULL;
>>     long childCount = 0;
>>     HRESULT hResult;
>>     WCHAR cl[256];
>>     GetObjectClass(pAcc, cl, sizeof(cl));
>>
>>     if (NULL != wcsstr(cl, _T("MozillaContentWindowClass")))
>>     {
>>         HWND hWnd;
>>         if(S_OK == WindowFromAccessibleObject(pAcc,  &hWnd))
>>         {
>>             if(hWnd)
>>                 if (IsWindowVisible(hWnd))
>>                     return pAcc;
>>         }
>>
>>         return NULL;
>>     }
>>
>>     pAcc -> get_accChildCount(&childCount);
>>
>>     IEnumVARIANT* pEnum = NULL;
>>     hResult = pAcc -> QueryInterface(IID_IEnumVARIANT,
>> (void**)&pEnum);
>>
>>     if (hResult != S_OK || pEnum == NULL)
>>         return NULL;
>>
>>     pEnum -> Reset();
>>
>>     for (long i = 0; i < childCount; i++)
>>     {
>>         VARIANT varChild;
>>         ULONG fetched;
>>         IDispatch* pDisp = NULL;
>>
>>         pEnum -> Next(1, &varChild, &fetched);
>>
>>         if (varChild.vt == VT_I4)
>>         {
>>             pAcc -> get_accChild(varChild, &pDisp);
>>         }
>>         else
>>         {
>>             pDisp = varChild.pdispVal;
>>         }
>>
>>         if (pDisp != NULL)
>>         {
>>             IAccessible* pAccChild = NULL;
>>             hResult = pDisp -> QueryInterface(IID_IAccessible,
>> (void**)&pAccChild);
>>             pDisp -> Release();
>>
>>             if (hResult == S_OK && pAccChild != NULL)
>>             {
>>                 pAccResult = FindContentWindow(pAccChild);
>>                 if (pAccResult != NULL)
>>                     return pAccResult;
>>             }
>>         }
>>     }
>>
>>     return pAccResult;
>>
>> };
>>
>> Then I have functions to get HTML and URL from IAccessible returned by
>> this function.
>>
>> Anybody can help with the right idea?
>>
_______________________________________________
dev-accessibility mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-accessibility
Reply | Threaded
Open this post in threaded view
|

Re: Get active page HTML content and URL

Meglio
On Sep 17, 3:49 am, Aaron Leventhal <[hidden email]>
wrote:

>  > Also, the accessible of the content window is equal to the URL.
> I mean to say the accessible value of the IAccessible you get back for the
> content window.
>
> - Aaron
>
> Aaron Leventhal wrote:
> > There is a very quick way to do this.
>
> > This is on our doc page for Windows AT developers, under the heading
> > "How to Find the Content Window and Load the Document"
> >http://www.mozilla.org/access/windows/at-apis#content-window
>
> > Also, the accessible of the content window is equal to the URL.
>
> > - Aaron
>
> > Meglio wrote:
> >> I'm trying to realize the C++ library with the unique function to get
> >> active page HTML content and URL.
>
> >> I'm getting the main IAccessible for the Mozilla, then I'm enumerating
> >> all its childs to find the active
> >> tab. The IAccessible is too slow, but with my algorithm it is even
> >> more slowly because of enumerating.
>
> >> Here is function which I use:
>
> >> IAccessible* FindContentWindow(IAccessible* pAcc)
> >> {
> >>     IAccessible* pAccResult = NULL;
> >>     long childCount = 0;
> >>     HRESULT hResult;
> >>     WCHAR cl[256];
> >>     GetObjectClass(pAcc, cl, sizeof(cl));
>
> >>     if (NULL != wcsstr(cl, _T("MozillaContentWindowClass")))
> >>     {
> >>         HWND hWnd;
> >>         if(S_OK == WindowFromAccessibleObject(pAcc,  &hWnd))
> >>         {
> >>             if(hWnd)
> >>                 if (IsWindowVisible(hWnd))
> >>                     return pAcc;
> >>         }
>
> >>         return NULL;
> >>     }
>
> >>     pAcc -> get_accChildCount(&childCount);
>
> >>     IEnumVARIANT* pEnum = NULL;
> >>     hResult = pAcc -> QueryInterface(IID_IEnumVARIANT,
> >> (void**)&pEnum);
>
> >>     if (hResult != S_OK || pEnum == NULL)
> >>         return NULL;
>
> >>     pEnum -> Reset();
>
> >>     for (long i = 0; i < childCount; i++)
> >>     {
> >>         VARIANT varChild;
> >>         ULONG fetched;
> >>         IDispatch* pDisp = NULL;
>
> >>         pEnum -> Next(1, &varChild, &fetched);
>
> >>         if (varChild.vt == VT_I4)
> >>         {
> >>             pAcc -> get_accChild(varChild, &pDisp);
> >>         }
> >>         else
> >>         {
> >>             pDisp = varChild.pdispVal;
> >>         }
>
> >>         if (pDisp != NULL)
> >>         {
> >>             IAccessible* pAccChild = NULL;
> >>             hResult = pDisp -> QueryInterface(IID_IAccessible,
> >> (void**)&pAccChild);
> >>             pDisp -> Release();
>
> >>             if (hResult == S_OK && pAccChild != NULL)
> >>             {
> >>                 pAccResult = FindContentWindow(pAccChild);
> >>                 if (pAccResult != NULL)
> >>                     return pAccResult;
> >>             }
> >>         }
> >>     }
>
> >>     return pAccResult;
>
> >> };
>
> >> Then I have functions to get HTML and URL from IAccessible returned by
> >> this function.
>
> >> Anybody can help with the right idea?

Thanks for your fast reply. Very thanks!
Anton

_______________________________________________
dev-accessibility mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-accessibility