我正在编写一个自动在画布上绘制内容的应用程序,具体取决于用户的首选项。 对于初学者,如何将点击事件发送到MS Paint应用程序?
答案 0 :(得分:0)
首先,您需要找到Paint应用程序:
static HWND findMSPaintDrawWindow(void)
{
HWND target;
target = FindWindow(TARGET_PAINT_WINDOW, NULL);
if (NULL != target)
{
target = FindWindowEx(target, NULL, TARGET_PAINT_INPUT_SUBWINDOW, NULL);
if (NULL != target)
{
target = FindWindowEx(target, NULL, NULL, NULL);
}
}
if (/*ENABLE_DEBUG_CONSOLE*/ 0)
{
char name[256];
GetClassName(target, name, 255);
printf("Detected ms paint Draw area with name [%s]\n", name);
}
return target;
}
其次,你与它互动:
static void sendMouseButton(int buttonState)
{
HWND target;
UINT buttonMode = WM_LBUTTONUP;
target = findMSPaintDrawWindow();
if (target)
{
if (buttonState)
{
buttonMode = WM_LBUTTONDOWN;
g_MouseDown = 0;
}
printf("INFO: Mouse [%d] msg %d\n", buttonState, buttonMode);
PostMessage(target, buttonMode, MK_LBUTTON, X, Y));
}
}
您可以随时浏览MSDN文档以获取更多详细信息。
答案 1 :(得分:-2)
您必须搜索谷歌如何将Windows消息发送到不同的应用程序。鼠标单击由2个不同的消息组成:WM_LBUTTONDOWN和WM_LBUTTONUP。
http://stefanstools.sourceforge.net/SendMessage.html http://www.codeproject.com/Articles/137/Sending-a-message-to-the-Main-Frame-Window-of-Anot