ホーム › System.Console › INPUT_RECORD
INPUT_RECORD
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| EventType | WORD | 2 | +0 | +0 | 入力イベントの種類を示す値。キー、マウス、サイズ変更などを区別する。 |
| Event | _Event_e__Union | 16 | +4 | +4 | EventTypeに応じた各種イベント記録を保持する共用体。 |
共用体: _Event_e__Union x64 16B / x86 16B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| KeyEvent | KEY_EVENT_RECORD | 16 | +0 | +0 |
| MouseEvent | MOUSE_EVENT_RECORD | 16 | +0 | +0 |
| WindowBufferSizeEvent | WINDOW_BUFFER_SIZE_RECORD | 4 | +0 | +0 |
| MenuEvent | MENU_EVENT_RECORD | 4 | +0 | +0 |
| FocusEvent | FOCUS_EVENT_RECORD | 4 | +0 | +0 |
各言語での定義
#include <windows.h>
// INPUT_RECORD (x64 20 / x86 20 バイト)
typedef struct INPUT_RECORD {
WORD EventType;
_Event_e__Union Event;
} INPUT_RECORD;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct INPUT_RECORD
{
public ushort EventType;
public _Event_e__Union Event;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure INPUT_RECORD
Public EventType As UShort
Public Event As _Event_e__Union
End Structureimport ctypes
from ctypes import wintypes
class INPUT_RECORD(ctypes.Structure):
_fields_ = [
("EventType", ctypes.c_ushort),
("Event", _Event_e__Union),
]#[repr(C)]
pub struct INPUT_RECORD {
pub EventType: u16,
pub Event: _Event_e__Union,
}import "golang.org/x/sys/windows"
type INPUT_RECORD struct {
EventType uint16
Event _Event_e__Union
}type
INPUT_RECORD = record
EventType: Word;
Event: _Event_e__Union;
end;const INPUT_RECORD = extern struct {
EventType: u16,
Event: _Event_e__Union,
};type
INPUT_RECORD {.bycopy.} = object
EventType: uint16
Event: _Event_e__Unionstruct INPUT_RECORD
{
ushort EventType;
_Event_e__Union Event;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; INPUT_RECORD サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; EventType : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; Event : _Event_e__Union (+4, 16byte) varptr(st)+4 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global INPUT_RECORD
#field short EventType
#field byte Event 16
#endstruct
stdim st, INPUT_RECORD ; NSTRUCT 変数を確保
st->EventType = 100
mes "EventType=" + st->EventType
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。