【发布时间】:2012-03-22 13:10:17
【问题描述】:
环境:
视窗 7
Visual Studio 2010 C++ Win32 API
Internet Explorer 9
OpenGL
项目目标:
在 3d 平面(GL_QUADS)上实时纹理 Internet Explorer9 的屏幕。和鼠标在 3d 平面上拾取,带有相对鼠标位置的点击消息发布在真正的 Internet Explorer 9.
目标是“在我的应用程序上使用 3D 纹理和鼠标操作控制其他程序”
代码:
HWND target;
//...
//in winmain
target = ::FindWindow("IEFrame",NULL);
glutMouseFunc(MouseEvent);
//...
//in MouseEvent
void MouseEvent(int iButton, int iState, int x, int y)
{
if(iState == GLUT_DOWN)
{
if(iButton == GLUT_LEFT_BUTTON)
{
POINT p;
p.x = x; p.y = y;
POINT pOut = PickWithPlane(target,p);
//I don't explain this function. cuz it has very long codes and so complicated and don't important.
//it is a simply transform point from my application's Client picking point 'p' to target application(=HWND target)'s relative picking point.
//send a click message to target. but this SendMessage don't work.
SendMessage(target, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(pOut.x, POut.y);
}
}
}
我使用了 SendMessage 的 PostMessage,但结果是一样的。
互联网探索不发送任何反应。
我使用 Microsoft Spy++ 消息窗口观看。
// on real-click IE9's window any point
<10972> 000C0F82 S WM_PARENTNOTIFY fwEvent: WM_LBUTTONDOWN xPos:475 yPos:700
<10973> 000C0F82 R WM_PARENTNOTIFY
<10974> 000C0F82 S WM_MOUSEACTIVATE hwndTopLevel:000C0F82 nHittest:HTCLIENT uMsg:WM_LBUTTONDOWN
<10975> 000C0F82 R WM_MOUSEACTIVATE fuActivate:MA_ACTIVATE
<10976> 000C0F82 S WM_SETCURSOR hwnd:00231438 nHittest:HTCLIENT wMouseMsg:WM_LBUTTONDOWN
<10977> 000C0F82 R WM_SETCURSOR fHaltProcessing:False
//mouseup
<10978> 000C0F82 S WM_SETCURSOR hwnd:00231438 nHittest:HTCLIENT wMouseMsg:WM_MOUSEMOVE
<10979> 000C0F82 R WM_SETCURSOR fhaltProcessing:False
接下来是使用我的应用程序代码发送消息:
// on my application's messge
<13106> 000C0F82 S WM_LBUTTONDOWN fwKeys:MK_LBUTTON xPos:1231 yPos:289
<13107> 000C0F82 R WM_LUBTTONDOWN
我猜想发送更多消息。但我不知道什么消息可以做到这一点。
谁知道解决方法?
谁知道用这种方式控制通用应用程序?
帮帮我!
【问题讨论】:
标签: c++ windows visual-studio winapi win32-process