Win32 API 日本語リファレンス
ホームDevices.HumanInterfaceDevice › MOUSE_INPUT_DATA

MOUSE_INPUT_DATA

構造体
サイズx64: 32 バイト / x86: 24 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
UnitIdWORD2+0+0入力元マウスのユニットID。
FlagsWORD2+2+2移動が絶対/相対かなどを示すフラグ群。
Anonymous_Anonymous_e__Union8/4+8+4ボタン状態とフラグを保持する無名共用体。
RawButtonsDWORD4+16+8生のボタン状態を示すビット群。
LastXINT4+20+12X軸方向の移動量。
LastYINT4+24+16Y軸方向の移動量。
ExtraInformationDWORD4+28+20デバイス固有の追加情報。

共用体: _Anonymous_e__Union x64 8B / x86 4B

フィールドサイズx64x86説明
ButtonsDWORD4+0+0
Anonymous_Anonymous_e__Struct8/4+0+0ボタン状態とフラグを保持する無名共用体。

各言語での定義

#include <windows.h>

// MOUSE_INPUT_DATA  (x64 32 / x86 24 バイト)
typedef struct MOUSE_INPUT_DATA {
    WORD UnitId;
    WORD Flags;
    _Anonymous_e__Union Anonymous;
    DWORD RawButtons;
    INT LastX;
    INT LastY;
    DWORD ExtraInformation;
} MOUSE_INPUT_DATA;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct MOUSE_INPUT_DATA
{
    public ushort UnitId;
    public ushort Flags;
    public _Anonymous_e__Union Anonymous;
    public uint RawButtons;
    public int LastX;
    public int LastY;
    public uint ExtraInformation;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure MOUSE_INPUT_DATA
    Public UnitId As UShort
    Public Flags As UShort
    Public Anonymous As _Anonymous_e__Union
    Public RawButtons As UInteger
    Public LastX As Integer
    Public LastY As Integer
    Public ExtraInformation As UInteger
End Structure
import ctypes
from ctypes import wintypes

class MOUSE_INPUT_DATA(ctypes.Structure):
    _fields_ = [
        ("UnitId", ctypes.c_ushort),
        ("Flags", ctypes.c_ushort),
        ("Anonymous", _Anonymous_e__Union),
        ("RawButtons", wintypes.DWORD),
        ("LastX", ctypes.c_int),
        ("LastY", ctypes.c_int),
        ("ExtraInformation", wintypes.DWORD),
    ]
#[repr(C)]
pub struct MOUSE_INPUT_DATA {
    pub UnitId: u16,
    pub Flags: u16,
    pub Anonymous: _Anonymous_e__Union,
    pub RawButtons: u32,
    pub LastX: i32,
    pub LastY: i32,
    pub ExtraInformation: u32,
}
import "golang.org/x/sys/windows"

type MOUSE_INPUT_DATA struct {
	UnitId uint16
	Flags uint16
	Anonymous _Anonymous_e__Union
	RawButtons uint32
	LastX int32
	LastY int32
	ExtraInformation uint32
}
type
  MOUSE_INPUT_DATA = record
    UnitId: Word;
    Flags: Word;
    Anonymous: _Anonymous_e__Union;
    RawButtons: DWORD;
    LastX: Integer;
    LastY: Integer;
    ExtraInformation: DWORD;
  end;
const MOUSE_INPUT_DATA = extern struct {
    UnitId: u16,
    Flags: u16,
    Anonymous: _Anonymous_e__Union,
    RawButtons: u32,
    LastX: i32,
    LastY: i32,
    ExtraInformation: u32,
};
type
  MOUSE_INPUT_DATA {.bycopy.} = object
    UnitId: uint16
    Flags: uint16
    Anonymous: _Anonymous_e__Union
    RawButtons: uint32
    LastX: int32
    LastY: int32
    ExtraInformation: uint32
struct MOUSE_INPUT_DATA
{
    ushort UnitId;
    ushort Flags;
    _Anonymous_e__Union Anonymous;
    uint RawButtons;
    int LastX;
    int LastY;
    uint ExtraInformation;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; MOUSE_INPUT_DATA サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; UnitId : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; Flags : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; Anonymous : _Anonymous_e__Union (+4, 4byte)  varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; RawButtons : DWORD (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; LastX : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; LastY : INT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; ExtraInformation : DWORD (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; MOUSE_INPUT_DATA サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; UnitId : WORD (+0, 2byte)  wpoke st,0,値  /  値 = wpeek(st,0)
; Flags : WORD (+2, 2byte)  wpoke st,2,値  /  値 = wpeek(st,2)
; Anonymous : _Anonymous_e__Union (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; RawButtons : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; LastX : INT (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; LastY : INT (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; ExtraInformation : DWORD (+28, 4byte)  st.7 = 値  /  値 = st.7   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global MOUSE_INPUT_DATA
    #field short UnitId
    #field short Flags
    #field byte Anonymous 8
    #field int RawButtons
    #field int LastX
    #field int LastY
    #field int ExtraInformation
#endstruct

stdim st, MOUSE_INPUT_DATA        ; NSTRUCT 変数を確保
st->UnitId = 100
mes "UnitId=" + st->UnitId
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。