※ 引述《student23489 (云§淡)》之铭言:
: 问题(Question):
: 目前有个问题是要抓鼠标所在位置的座标
之前用 FFI 抓鼠标座标、判断颜色,再模拟鼠标点击。
参考下列两篇文章可以找到正确的位置。
https://stackoverflow.com/questions/4839623/getting-pixel-color-in-c
HINSTANCE _hGDI = LoadLibrary("gdi32.dll");
HDC _hdc = GetDC(NULL);
pGetPixel = GetProcAddress(_hGDI, "GetPixel");
POINT _cursor;
GetCursorPos(&_cursor);
COLORREF _color = (*pGetPixel) (_hdc, _cursor.x, _cursor.y);
https://bit.ly/2X2oDAV
SendInput API
int SCREEN_WIDTH = GetSystemMetrics( SM_CXVIRTUALSCREEN );
int SCREEN_HEIGHT = GetSystemMetrics( SM_CYVIRTUALSCREEN );
MInput.dx = (x * 65536 / SCREEN_WIDTH + 1);
MInput.dy = (y * 65536 / SCREEN_HEIGHT);
MInput.dwFlags |= MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.type = INPUT_MOUSE;
Input.mi = MInput;
if (SendInput(1, &Input, sizeof(Input))) // ...