1、鼠標坐標問題
BOOL GetWindowRect(
HWND hWnd,
LPRECT lpRect
);
RECT x;//定義一個二維數組x
::GetWindowRect(hwnd,&x);
POINT P;//x,y RECT型 X 的指針
GetCursorPos(&p); //取當前鼠標坐標指針
SetCursorPos(x+r1.left,y+r1.top); //設置下一步鼠標坐標指針
SetCursorPos(p.x,p.y); //還原鼠標坐標
2、模擬鼠標消息
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
int x=?,y=?;
//y<<16)+x=lParam
//lParam可由SPY++攔截獲取,亦可計算
//eg.x=655;y=577 lparam 0x0241028f
// 0x 0172 01f3
// y=370 x= 499
左鍵單擊模擬:
SendMessage(hwnd,WM_LBUTTONDOWN,0,(y<<16)+x);
SendMessage(hwnd,WM_LBUTTONUP,0,(y<<16)+x);
左鍵雙擊模擬:
SendMessage(hwnd,WM_LBUTTONDBLCLK,0,(y<<16)+x);
右鍵單擊模擬:
SendMessage(hwnd,WM_RBUTTONDOWN,0,(y<<16)+x);
SendMessage(hwnd,WM_RBUTTONUP,0,(y<<16)+x);
右鍵雙擊模擬:
SendMessage(hwnd,WM_RBUTTONDBLCLK,0,(y<<16)+x);
2、鼠標事件
VOID mouse_event( DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, DWORD dwExtraInfo );
左鍵單擊消息:
mouse_event(mouse_event_LEFTUP,0,0,0,0); //第一個參數位 鼠標操作狀態
mouse_event(mouse_event_LEFTDOWN,0,0,0,0);
左鍵雙擊消息:
mouse_event(mouse_event_LBUTTONDBLCLK,0,0,0,0);
右鍵單擊消息
mouse_event(MOUSEEVENTF_REFTUP,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
右鍵雙擊消息:
mouse_event(mouse_event_RBUTTONDBLCLK,0,0,0,0);
鍵盤模擬函數
VOID keybd_event(
BYTE bVk,
BYTE bScan,
DWORD dwFlags,
PTR dwExtraInfo
);
調用:
keybd_event(13, 0, 0 ,0); //第一參數鍵值 13 回車