※ 引述《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))) // ...