Win32API マウスカーソルの位置を移動する SetCursorPos
マウスカーソルの位置を移動するには、SetCursorPos関数を使用する。
SetCursorPosのプロトタイプ
BOOL SetCursorPos( int X, // 水平位置 int Y // 垂直位置 );
使用例:マウスカーソルが円を描くプログラム
#include <windows.h> #include <stdio.h> #include <math.h> int main() { double r = 100; double center = 500; DWORD wait = 10; for (double x = 0.0; x < 20.0; x += 0.05) { SetCursorPos( (int)(r * cos(x) + center), (int)(r * sin(x) + center) ); Sleep(wait); } return 0; }