hook搜狗浏览器时的问题
hook搜狗浏览器时,回调函数没有被调用,而同种方法hookIE就行的通?
我用了几种钩子类型(头2种, DEBUG,鼠标,鼠标LL)都试过了,都没有成功。请高手能告诉我为啥没成功的原因。
如果能提供怎么hook搜狗浏览器的方法就更感激不尽了。
[解决办法]
我给的例子里面用
SetMouseHook(FindWindow(“搜狗窗口类名”,NULL) )
hook框架
你可以这样修改。
找主窗口 HWND MainWnd= FindWindow(“搜狗窗口类名”,NULL)
接着再找主窗口下的子窗口具有“Internet Explorer_Server”列名的那个就是主视图了。
再调用 SetMouseHook( 主视图窗口句柄 ) 就可以了
下面的函数也许有用。阿弥陀佛!
- C/C++ code
/****************************************************************************寻找指定类名的子窗口句柄 方法一****************************************************************************/staticHWND FindWithClassName(HWND ParentWnd,const TCHAR* FindClassName){ HWND hChild = ::GetWindow(ParentWnd, GW_CHILD); TCHAR ClassName[100]; for(; hChild!=NULL ; hChild=::GetWindow(hChild,GW_HWNDNEXT)) { ::GetClassName(hChild,ClassName,sizeof(ClassName)/sizeof(TCHAR)); if (_tcscmp(ClassName,FindClassName)==0) return hChild; HWND FindWnd=FindWithClassName(hChild,FindClassName); if (FindWnd) return FindWnd; } return NULL;}/****************************************************************************获取主窗口下某个子窗口的窗口句柄参数1:最顶层父窗口参数2:控件ID,可使用spy++(VS2008版本) 查看****************************************************************************/staticHWND FindControlWnd(HWND ParentWnd,DWORD ControlID){ HWND hChild = ::GetWindow(ParentWnd, GW_CHILD); for(; hChild!=NULL ; hChild=::GetWindow(hChild,GW_HWNDNEXT)) { //判断是否为需要的控件 if ( GetDlgCtrlID(hChild) == ControlID ) return hChild; HWND FindWnd=FindControlWnd(hChild,ControlID); if (FindWnd) return FindWnd; } return NULL;}