ホーム › Devices.HumanInterfaceDevice › MOUSE_INPUT_DATA
MOUSE_INPUT_DATA
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| UnitId | WORD | 2 | +0 | +0 | 入力元マウスのユニットID。 |
| Flags | WORD | 2 | +2 | +2 | 移動が絶対/相対かなどを示すフラグ群。 |
| Anonymous | _Anonymous_e__Union | 8/4 | +8 | +4 | ボタン状態とフラグを保持する無名共用体。 |
| RawButtons | DWORD | 4 | +16 | +8 | 生のボタン状態を示すビット群。 |
| LastX | INT | 4 | +20 | +12 | X軸方向の移動量。 |
| LastY | INT | 4 | +24 | +16 | Y軸方向の移動量。 |
| ExtraInformation | DWORD | 4 | +28 | +20 | デバイス固有の追加情報。 |
共用体: _Anonymous_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| Buttons | DWORD | 4 | +0 | +0 | |
| Anonymous | _Anonymous_e__Struct | 8/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 Structureimport 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: uint32struct 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 非対応)。必要に応じ手動でアクセス。