The MOUSEMOVEPOINT structure contains information about the mouse's location in screen coordinates.
Syntax
typedef struct tagMOUSEMOVEPOINT {
int x;
int y;
DWORD time;
ULONG_PTR dwExtraInfo;
} MOUSEMOVEPOINT, *PMOUSEMOVEPOINT;
Members
x
Specifies the x-coordinate of the mouse.
y
Specifies the y-coordinate of the mouse.
time
Specifies the time stamp of the mouse coordinate.
dwExtraInfo
Specifies extra information associated with this coordinate.
Structure Information
Header Declared in Winuser.h, include Windows.h
Minimum operating systems Millennium, Windows 2000
The GetCursorPos function retrieves the cursor's position, in screen coordinates.
Syntax
BOOL GetCursorPos( LPPOINT lpPoint
);
Parameters
lpPoint
[out] Pointer to a POINT structure that receives the screen coordinates of the cursor.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The cursor position is always specified in screen coordinates and is not affected by the mapping mode of the window that contains the cursor.
The calling process must have WINSTA_READATTRIBUTES access to the window station.
Example
For an example, see Using the Keyboard to Move the Cursor.
Function Information
Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
LPPOINT lpPoint // address of structure for cursor position
);
2、我们把鼠标的位置移到要到人物走到的地方,我们就要用到SetCursorPos函数来移动鼠标位置,它的使用方法如下:
BOOL SetCursorPos(
int X, // horizontal position
int Y // vertical position
);
3、模拟鼠标发出按下和放开的动作,我们要用到mouse_event函数来实现,具休使用方法用下:
VOID mouse_event(
DWORD dwFlags, // flags specifying various motion/click variants
DWORD dx, // horizontal mouse position or position change
DWORD dy, // vertical mouse position or position change
DWORD dwData, // amount of wheel movement
DWORD dwExtraInfo // 32 bits of application-defined information
);
在它的dwFlags处,可用的事件很多如移动MOUSEEVENTF_MOVE,左键按下MOUSEEVENTF_LEFTDOWN,左键放开MOUSEEVENTF_LEFTUP,具体的东东还是查一下MSDN吧~~~~~
好了,有了以前的知识,我们就可以来看看人物移走是怎么实现的了: