GetKeyboardState

導入

v1.0

詳細

すべての仮想キーについて、現在のステータスを取得します。

注: このコマンドは、出力引数を使用します。C# および一部のスクリプト言語(JScript、PerlScript、Python など)は、リファレンスによって渡される引数をサポートしていません。このため、状況に応じた適切な回避策を実行する必要があります。

スクリプト言語の場合、このコマンドは出力引数を取得するために使用できる ISIVTCollection を戻します。

C# の場合は、XSIApplication.ExecuteCommand メソッドを使用してこのコマンドを呼び出すことができます。ExecuteCommand は、出力引数を C# の System.Object (出力引数の Array を含む)にパック化します(詳細については、「C# からのコマンドの呼び出し」を参照)。

スクリプト構文

GetKeyboardState( [KeyCode], [Shift] );

パラメータ

パラメータ タイプ 説明
KeyCode Long まだ実装されていません。
Shift siKeyboardState [Shift]キー(1)、[Ctrl]キー(2)、および[Alt]キー(4)に対応した整数マスクを戻します。

1. VBScript の例

dim l_ModifierKey

GetKeyboardState , l_ModifierKey

if CBool(CByte(1) And CByte(l_ModifierKey)) then

	LogMessage "Shift pressed"

elseif CBool(CByte(2) And CByte(l_ModifierKey)) then

	LogMessage "Ctrl pressed"

elseif CBool(CByte(4) And CByte(l_ModifierKey)) then

	LogMessage "Alt pressed"

else

	LogMessage "No modifier key pressed."

end if

2. JScript の例

/*

	This example illustrates how to call the GetKeyboardState command and access 

	the output argument called Shift; this contains the modifier key state.

*/

var rtn = GetKeyboardState();

var mod;

// get modifier by index

modifier = rtn(1);

LogMessage( "modifier = " + modifier, siInfo );

// get modifier by argument name

modifier = rtn("Shift");

LogMessage( "modifier = " + modifier, siInfo );

var str = "";

if ( 1 & modifier )

{

	str = "Shift "

}

if ( 2 & modifier )

{

	str += "Ctrl "

}

if ( 4 & modifier )

{

	str += "Alt "

}

if ( str != "" ) 

{

	LogMessage( str + "pressed", siInfo );

}

else

{

	LogMessage( "No modifier key pressed.", siInfo );

}

//INFO : "modifier = 7"

//INFO : "modifier = 7"

//INFO : "Shift Ctrl Alt pressed"