Win32 API 日本語リファレンス
ホームUI.Input.KeyboardAndMouse › GetMouseMovePointsEx

GetMouseMovePointsEx

関数
マウスの移動座標履歴を取得する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// USER32.dll
#include <windows.h>

INT GetMouseMovePointsEx(
    DWORD cbSize,
    MOUSEMOVEPOINT* lppt,
    MOUSEMOVEPOINT* lpptBuf,
    INT nBufPoints,
    GET_MOUSE_MOVE_POINTS_EX_RESOLUTION resolution
);

パラメーター

名前方向
cbSizeDWORDin
lpptMOUSEMOVEPOINT*in
lpptBufMOUSEMOVEPOINT*out
nBufPointsINTin
resolutionGET_MOUSE_MOVE_POINTS_EX_RESOLUTIONin

戻り値の型: INT

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

INT GetMouseMovePointsEx(
    DWORD cbSize,
    MOUSEMOVEPOINT* lppt,
    MOUSEMOVEPOINT* lpptBuf,
    INT nBufPoints,
    GET_MOUSE_MOVE_POINTS_EX_RESOLUTION resolution
);
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern int GetMouseMovePointsEx(
    uint cbSize,   // DWORD
    IntPtr lppt,   // MOUSEMOVEPOINT*
    IntPtr lpptBuf,   // MOUSEMOVEPOINT* out
    int nBufPoints,   // INT
    uint resolution   // GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetMouseMovePointsEx(
    cbSize As UInteger,   ' DWORD
    lppt As IntPtr,   ' MOUSEMOVEPOINT*
    lpptBuf As IntPtr,   ' MOUSEMOVEPOINT* out
    nBufPoints As Integer,   ' INT
    resolution As UInteger   ' GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
) As Integer
End Function
' cbSize : DWORD
' lppt : MOUSEMOVEPOINT*
' lpptBuf : MOUSEMOVEPOINT* out
' nBufPoints : INT
' resolution : GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
Declare PtrSafe Function GetMouseMovePointsEx Lib "user32" ( _
    ByVal cbSize As Long, _
    ByVal lppt As LongPtr, _
    ByVal lpptBuf As LongPtr, _
    ByVal nBufPoints As Long, _
    ByVal resolution As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetMouseMovePointsEx = ctypes.windll.user32.GetMouseMovePointsEx
GetMouseMovePointsEx.restype = ctypes.c_int
GetMouseMovePointsEx.argtypes = [
    wintypes.DWORD,  # cbSize : DWORD
    ctypes.c_void_p,  # lppt : MOUSEMOVEPOINT*
    ctypes.c_void_p,  # lpptBuf : MOUSEMOVEPOINT* out
    ctypes.c_int,  # nBufPoints : INT
    wintypes.DWORD,  # resolution : GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
GetMouseMovePointsEx = Fiddle::Function.new(
  lib['GetMouseMovePointsEx'],
  [
    -Fiddle::TYPE_INT,  # cbSize : DWORD
    Fiddle::TYPE_VOIDP,  # lppt : MOUSEMOVEPOINT*
    Fiddle::TYPE_VOIDP,  # lpptBuf : MOUSEMOVEPOINT* out
    Fiddle::TYPE_INT,  # nBufPoints : INT
    -Fiddle::TYPE_INT,  # resolution : GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GetMouseMovePointsEx(
        cbSize: u32,  // DWORD
        lppt: *mut MOUSEMOVEPOINT,  // MOUSEMOVEPOINT*
        lpptBuf: *mut MOUSEMOVEPOINT,  // MOUSEMOVEPOINT* out
        nBufPoints: i32,  // INT
        resolution: u32  // GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", SetLastError = true)]
public static extern int GetMouseMovePointsEx(uint cbSize, IntPtr lppt, IntPtr lpptBuf, int nBufPoints, uint resolution);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetMouseMovePointsEx' -Namespace Win32 -PassThru
# $api::GetMouseMovePointsEx(cbSize, lppt, lpptBuf, nBufPoints, resolution)
#uselib "USER32.dll"
#func global GetMouseMovePointsEx "GetMouseMovePointsEx" sptr, sptr, sptr, sptr, sptr
; GetMouseMovePointsEx cbSize, varptr(lppt), varptr(lpptBuf), nBufPoints, resolution   ; 戻り値は stat
; cbSize : DWORD -> "sptr"
; lppt : MOUSEMOVEPOINT* -> "sptr"
; lpptBuf : MOUSEMOVEPOINT* out -> "sptr"
; nBufPoints : INT -> "sptr"
; resolution : GET_MOUSE_MOVE_POINTS_EX_RESOLUTION -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global GetMouseMovePointsEx "GetMouseMovePointsEx" int, var, var, int, int
; res = GetMouseMovePointsEx(cbSize, lppt, lpptBuf, nBufPoints, resolution)
; cbSize : DWORD -> "int"
; lppt : MOUSEMOVEPOINT* -> "var"
; lpptBuf : MOUSEMOVEPOINT* out -> "var"
; nBufPoints : INT -> "int"
; resolution : GET_MOUSE_MOVE_POINTS_EX_RESOLUTION -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT GetMouseMovePointsEx(DWORD cbSize, MOUSEMOVEPOINT* lppt, MOUSEMOVEPOINT* lpptBuf, INT nBufPoints, GET_MOUSE_MOVE_POINTS_EX_RESOLUTION resolution)
#uselib "USER32.dll"
#cfunc global GetMouseMovePointsEx "GetMouseMovePointsEx" int, var, var, int, int
; res = GetMouseMovePointsEx(cbSize, lppt, lpptBuf, nBufPoints, resolution)
; cbSize : DWORD -> "int"
; lppt : MOUSEMOVEPOINT* -> "var"
; lpptBuf : MOUSEMOVEPOINT* out -> "var"
; nBufPoints : INT -> "int"
; resolution : GET_MOUSE_MOVE_POINTS_EX_RESOLUTION -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetMouseMovePointsEx = user32.NewProc("GetMouseMovePointsEx")
)

// cbSize (DWORD), lppt (MOUSEMOVEPOINT*), lpptBuf (MOUSEMOVEPOINT* out), nBufPoints (INT), resolution (GET_MOUSE_MOVE_POINTS_EX_RESOLUTION)
r1, _, err := procGetMouseMovePointsEx.Call(
	uintptr(cbSize),
	uintptr(lppt),
	uintptr(lpptBuf),
	uintptr(nBufPoints),
	uintptr(resolution),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function GetMouseMovePointsEx(
  cbSize: DWORD;   // DWORD
  lppt: Pointer;   // MOUSEMOVEPOINT*
  lpptBuf: Pointer;   // MOUSEMOVEPOINT* out
  nBufPoints: Integer;   // INT
  resolution: DWORD   // GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
): Integer; stdcall;
  external 'USER32.dll' name 'GetMouseMovePointsEx';
result := DllCall("USER32\GetMouseMovePointsEx"
    , "UInt", cbSize   ; DWORD
    , "Ptr", lppt   ; MOUSEMOVEPOINT*
    , "Ptr", lpptBuf   ; MOUSEMOVEPOINT* out
    , "Int", nBufPoints   ; INT
    , "UInt", resolution   ; GET_MOUSE_MOVE_POINTS_EX_RESOLUTION
    , "Int")   ; return: INT
●GetMouseMovePointsEx(cbSize, lppt, lpptBuf, nBufPoints, resolution) = DLL("USER32.dll", "int GetMouseMovePointsEx(dword, void*, void*, int, dword)")
# 呼び出し: GetMouseMovePointsEx(cbSize, lppt, lpptBuf, nBufPoints, resolution)
# cbSize : DWORD -> "dword"
# lppt : MOUSEMOVEPOINT* -> "void*"
# lpptBuf : MOUSEMOVEPOINT* out -> "void*"
# nBufPoints : INT -> "int"
# resolution : GET_MOUSE_MOVE_POINTS_EX_RESOLUTION -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。