I have the following code:
IAccessible *pAccessible = NULL;
IServiceProvider *pServProv = NULL;
AccessibleObjectFromWindow((HWND)0x0025093A, OBJID_CLIENT, IID_IAccessible, (void**)&pAccessible);
HRESULT hr = pAccessible->QueryInterface(IID_IServiceProvider, (void**)&pServProv);
if (SUCCEEDED(hr) && (pServProv != NULL))
{
const GUID unused;
ISimpleDOMDocument *pAccDoc = NULL;
hr = pServProv->QueryService(unused, IID_ISimpleDOMDocument, (void**)&pAccDoc);
if (SUCCEEDED(hr) && (pAccDoc != NULL))
{
// Success
}
else
{
// Failure
}
}
The hard-coded HWND above is to an instance of MozillaContentWindowClass.
I can get as far as QueryService - AccessibleObjectFromWindow and QueryInterface both succeed and return non-NULL objects; however, QueryService returns 'Invalid Parameter'. I've seen other suggestions, one of which is not using QueryService - just calling QueryInterface with IID_ISimpleDom* - but those calls return a 'No Service' error.
I've also seen suggestions to navigate to the Document object, and get a reference to the node from there - but I'm not quite sure how to accomplish that (I'm new to IAccessibility).
I appreciate any insight.
Magic GUID provided by Mozilla
Now, between
AccessibleObjectFromWindow
and getting the provider, you may need to move around the accessible heirarchy, that can be a bit messy.Have a look at this Code Project - XMSAALib for suggestions.
Here is an example of some of the tree walking covering various issues. Modified from the original to use ATL smart pointers and some bug fixes (or introduced ;) )