有什么方法可以记录鼠标左键按住然后使鼠标按住左键?

时间:2019-01-03 13:15:16

标签: c++ winapi

我正在编写一个c + +代码,打开画图,然后将鼠标移动记录在数组中(实际上是绘画中的绘制),然后打开另一个画图,并强制鼠标移动到我存储的最后一个动作,在这里我需要强制鼠标来绘制与以前的绘画中相同的东西。我需要一个在按住鼠标左键的同时强制其移动的功能。

#include<iostream>
#include <conio.h>
#include <shlobj.h>
#include <Windows.h>
#include<winuser.h>

int main()
{
    POINT Mouse;
    POINT mousePositions[20];
    int counter = 0;
    ShellExecute(NULL, TEXT("open"), TEXT("F://paint"), NULL, NULL, SW_SHOW);
    while (counter<20)
    {
        GetCursorPos(&Mouse);
        mousePositions[counter] = Mouse;
        counter++;
        Sleep(500);
    }
    counter = 0;
    ShellExecute(NULL, TEXT("open"), TEXT("F://paint"), NULL, NULL, SW_SHOW);
    while (counter<20)
    {

        SetCursorPos(mousePositions[counter].x, mousePositions[counter].y);
        counter++;
        Sleep(500);
    }

    getche();
    return 0;
}

0 个答案:

没有答案