Windows mouse message processing and keyboard simulation functions, windows functions
1. mouse coordinates
BOOL GetWindowRect (
HWNDHWnd,
LPRECT LpRect
);
RECT x; // defines a two-dimensional array x
: GetWindowRect (hwnd, & x );
Point p; // x, y rect x pointer
GetCursorPos (& p); // obtains the coordinate pointer of the current mouse.
SetCursorPos (x + r1.left, y + r1.top); // you can specify the next mouse coordinate pointer.
SetCursorPos (p. x, p. y); // restore the mouse coordinates
2. Simulate mouse messages
LRESULT SendMessage (
HWND HWnd,
UINT Msg,
WPARAM WParam,
LPARAM LParam
);
Int x = ?, Y = ?;
// Y <16) + x =LParam
//LParam can be obtained by SPY ++ interception or computed
// Eg. x = 655; y = 577 lparam 0x0241028f
// 0x0172 01f3
// Y = 370 x = 499
Left-click simulation:
SendMessage (hwnd, WM_LBUTTONDOWN, 0, (y <16) + x );
SendMessage (hwnd, WM_LBUTTONUP, 0, (y <16) + x );
Double-click simulation with the left button:
SendMessage (hwnd,WM_LBUTTONDBLCLK, 0, (y <16) + x );
Right-click simulation:
SendMessage (hwnd, WM_RBUTTONDOWN, 0, (y <16) + x );
SendMessage (hwnd, WM_RBUTTONUP, 0, (y <16) + x );
Right-click simulation:
SendMessage (hwnd,WM_RBUTTONDBLCLK, 0, (y <16) + x );
2. mouse events
VOID mouse_event( DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, DWORD dwExtraInfo);
Left-click message:
Mouse_event (mouse_event_LEFTUP,); // The first parameter cursor operation status
Mouse_event (mouse_event_LEFTDOWN, 0, 0, 0 );
Left-click message:
Mouse_event (mouse_event_LBUTTONDBLCLK, 0, 0, 0 );
Right-click message
Mouse_event (MOUSEEVENTF_REFTUP, 0, 0, 0 );
Mouse_event (MOUSEEVENTF_LEFTDOWN, 0, 0, 0 );
Right-click a message:
Mouse_event (mouse_event_RBUTTONDBLCLK, 0, 0, 0 );
Keyboard simulation functions
VOID keybd_event (
BYTEBVk,
BYTEBScan,
DWORDDwFlags,
PTRDwExtraInfo
);
Call:
Keybd_event (13, 0, 0, 0); // press enter for the first parameter key value 13