Win32 API 日本語リファレンス
ホームUI.WindowsAndMessaging › GetInputState

GetInputState

関数
マウスやキーボードの入力が待機中かを判定する。
DLLUSER32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL GetInputState(void);

パラメーターなし。戻り値: BOOL

各言語での呼び出し定義

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

BOOL GetInputState(void);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool GetInputState();
<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function GetInputState() As Boolean
End Function
Declare PtrSafe Function GetInputState Lib "user32" () As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetInputState = ctypes.windll.user32.GetInputState
GetInputState.restype = wintypes.BOOL
GetInputState.argtypes = []
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
GetInputState = Fiddle::Function.new(
  lib['GetInputState'],
  [],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GetInputState() -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool GetInputState();
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetInputState' -Namespace Win32 -PassThru
# $api::GetInputState()
#uselib "USER32.dll"
#func global GetInputState "GetInputState"
; GetInputState   ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global GetInputState "GetInputState"
; res = GetInputState()
; BOOL GetInputState()
#uselib "USER32.dll"
#cfunc global GetInputState "GetInputState"
; res = GetInputState()
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetInputState = user32.NewProc("GetInputState")
)

r1, _, err := procGetInputState.Call()
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetInputState: BOOL; stdcall;
  external 'USER32.dll' name 'GetInputState';
result := DllCall("USER32\GetInputState", "Int")
●GetInputState() = DLL("USER32.dll", "bool GetInputState()")
# 呼び出し: GetInputState()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。