Hi all! My program is for the capturing mouse behavior on the browsers(opera, IE, firefox, chrome). So I sat a global mouse hook, and now I know where the mouse pointer is , i.e. is the window under the mouse pointer a browser or not. So, when the click is caught on a browser I know the following:
1. browser window handle
2. the browser window process ID
the question is "how can I retrieve the URL in which the browser is?"
please, don't tell me "use SPY++" or something like that, because I've already tried to do that, but failed :(
Also I tried to call javascript "location.href", and... nothing usable (I know nothing in javascript.. maybe do something wrong)
and finally tried to use IWebBrowser2... but get_LocationURL returns an empty string. here is the code (for IE):
<br />
IWebBrowser2 *pIwb;<br />
OleInitialize( 0 );<br />
CoCreateInstance( CLSID_InternetExplorer, NULL, CLSCTX_ALL,IID_IWebBrowser2, (void**)&pIwb );<br />
if( pIwb )<br />
{<br />
VARIANT vEmpty;<br />
VARIANT_BOOL bBusy = VARIANT_TRUE;<br />
VariantInit( &vEmpty );<br />
<br />
HINSTANCE hIEInstance = LoadLibrary( "atl.dll" );<br />
<br />
AttachCtrl AtlAxAttachControl = (AttachCtrl)GetProcAddress( hIEInstance, "AtlAxAttachControl" );<br />
<br />
HWND hWnd = ::GetForegroundWindow();<br />
HRESULT hResult = AtlAxAttachControl( pIwb, hWnd , 0 );<br />
<br />
CComBSTR bufferScript;<br />
hResult = pIwb->get_LocationURL( &bufferScript );<br />
<br />
<br />
SysFreeString( bufferScript );<br />
<br />
pIwb->Quit();<br />
pIwb->Release();<br />
<br />
FreeLibrary( hIEInstance );<br />
}<br />
I hope somebody will provide me a piece of code, which will do this job