RAWMOUSE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| usFlags | MOUSE_STATE | 2 | +0 | +0 | マウス移動が相対か絶対かを示すフラグである。 |
| Anonymous | _Anonymous_e__Union | 8/4 | +8 | +4 | ボタン状態を保持する無名共用体である。 |
| ulRawButtons | DWORD | 4 | +16 | +8 | 生のボタン状態を示すビット値である。 |
| lLastX | INT | 4 | +20 | +12 | X方向の移動量である。 |
| lLastY | INT | 4 | +24 | +16 | Y方向の移動量である。 |
| ulExtraInformation | DWORD | 4 | +28 | +20 | デバイスからの追加情報値である。 |
共用体: _Anonymous_e__Union x64 8B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| ulButtons | DWORD | 4 | +0 | +0 | |
| Anonymous | _Anonymous_e__Struct | 8/4 | +0 | +0 | ボタン状態を保持する無名共用体である。 |
各言語での定義
#include <windows.h>
// RAWMOUSE (x64 32 / x86 24 バイト)
typedef struct RAWMOUSE {
MOUSE_STATE usFlags;
_Anonymous_e__Union Anonymous;
DWORD ulRawButtons;
INT lLastX;
INT lLastY;
DWORD ulExtraInformation;
} RAWMOUSE;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RAWMOUSE
{
public ushort usFlags;
public _Anonymous_e__Union Anonymous;
public uint ulRawButtons;
public int lLastX;
public int lLastY;
public uint ulExtraInformation;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RAWMOUSE
Public usFlags As UShort
Public Anonymous As _Anonymous_e__Union
Public ulRawButtons As UInteger
Public lLastX As Integer
Public lLastY As Integer
Public ulExtraInformation As UInteger
End Structureimport ctypes
from ctypes import wintypes
class RAWMOUSE(ctypes.Structure):
_fields_ = [
("usFlags", ctypes.c_ushort),
("Anonymous", _Anonymous_e__Union),
("ulRawButtons", wintypes.DWORD),
("lLastX", ctypes.c_int),
("lLastY", ctypes.c_int),
("ulExtraInformation", wintypes.DWORD),
]#[repr(C)]
pub struct RAWMOUSE {
pub usFlags: u16,
pub Anonymous: _Anonymous_e__Union,
pub ulRawButtons: u32,
pub lLastX: i32,
pub lLastY: i32,
pub ulExtraInformation: u32,
}import "golang.org/x/sys/windows"
type RAWMOUSE struct {
usFlags uint16
Anonymous _Anonymous_e__Union
ulRawButtons uint32
lLastX int32
lLastY int32
ulExtraInformation uint32
}type
RAWMOUSE = record
usFlags: Word;
Anonymous: _Anonymous_e__Union;
ulRawButtons: DWORD;
lLastX: Integer;
lLastY: Integer;
ulExtraInformation: DWORD;
end;const RAWMOUSE = extern struct {
usFlags: u16,
Anonymous: _Anonymous_e__Union,
ulRawButtons: u32,
lLastX: i32,
lLastY: i32,
ulExtraInformation: u32,
};type
RAWMOUSE {.bycopy.} = object
usFlags: uint16
Anonymous: _Anonymous_e__Union
ulRawButtons: uint32
lLastX: int32
lLastY: int32
ulExtraInformation: uint32struct RAWMOUSE
{
ushort usFlags;
_Anonymous_e__Union Anonymous;
uint ulRawButtons;
int lLastX;
int lLastY;
uint ulExtraInformation;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; RAWMOUSE サイズ: 24 バイト(x86)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; usFlags : MOUSE_STATE (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Anonymous : _Anonymous_e__Union (+4, 4byte) varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; ulRawButtons : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lLastX : INT (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; lLastY : INT (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; ulExtraInformation : DWORD (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; RAWMOUSE サイズ: 32 バイト(x64)
dim st, 8 ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; usFlags : MOUSE_STATE (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Anonymous : _Anonymous_e__Union (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; ulRawButtons : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; lLastX : INT (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; lLastY : INT (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; ulExtraInformation : DWORD (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global RAWMOUSE
#field short usFlags
#field byte Anonymous 8
#field int ulRawButtons
#field int lLastX
#field int lLastY
#field int ulExtraInformation
#endstruct
stdim st, RAWMOUSE ; NSTRUCT 変数を確保
st->usFlags = 100
mes "usFlags=" + st->usFlags
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。