C ++在窗口某一点鼠标点击 [英] C++ mouse click on certain spot in window

查看:587
本文介绍了C ++在窗口某一点鼠标点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有我的工作的功能,但我肯定会约了错误的方式。

I have my function here working, but I am certainly going about it the wrong way.

我的程序使用FindWindow函数找到正确的窗口。我需要双击该窗口上的特定位置。

My program uses FindWindow to find the correct window. I need to double click on a specific location on this window.

我把它通过始终把窗口在屏幕上的同一位置工作,但如果我搬到窗口中的程序将会尝试点击我所提供的硬件codeD位置,它不会工作。

I made it work by always putting the window in the same location on the screen, but if I moved the window the program would try click on the hard-coded location I have provided and it would not work.

下面是函数:

void lobbyWindow(HWND main_client)
{
  //RECT arect;

   // GetWindowRect(main_client, &arect); 

    SetCursorPos(748,294);
    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

}

正如你所看到的我只是把鼠标移动到748294和双击。我想要做的是设置鼠标为100,100在main_client窗口,所以如果我移动main_client窗口鼠标仍然点击了正确的位置。

As you can see I just move the mouse to 748,294 and double click. What I want to do is set the mouse to 100,100 in the main_client window, so if I move the main_client window the mouse still clicks on the correct spot.

推荐答案

使用<一个href=\"http://msdn.microsoft.com/en-us/library/windows/desktop/ms646270.aspx\"><$c$c>SendInput()相反,那么你可以使用标志相对光标移动到窗口 -

Use SendInput() instead, then you can use flags to move the cursor relative to the window -

Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP;


  1. How我可以在X模拟在窗口鼠标双击(我khow手柄),y坐标,使用SendInput?

  2. http://www.cplusplus.com/forum/windows/97017/

  1. How i can simulate a double mouse click on window ( i khow handle) on x, y coordinate, using SendInput?
  2. http://www.cplusplus.com/forum/windows/97017/

这篇关于C ++在窗口某一点鼠标点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆