如何编写一个简单的鼠标控制程序
#include
#include
int main()
{
int x, y;
HWND hwnd = GetDesktopWindow();
HDC hdc = GetDC(hwnd);
while (1) {
Sleep(1000);
POINT p;
GetCursorPos(&p);
x = p.x;
y = p.y;
printf("鼠标当前位置: (%d, %d)\n", x, y);
// 在此处添加代码以控制鼠标移动
}
ReleaseDC(hwnd, hdc);
return 0;
}
下载地址
用户评论