自動キーボード入力

http://www.softist.com/programming/sendinput/sendinput.htm

/**
* キー入力
*/
void KeyAction( WORD VirtualKey, BOOL bKeepPressing )
{
INPUT input[1];
input[0].type           = INPUT_KEYBOARD;
input[0].ki.wVk         = VirtualKey;
input[0].ki.wScan       = ::MapVirtualKeyW( input[0].ki.wVk, 0 );
input[0].ki.dwFlags     = KEYEVENTF_EXTENDEDKEY;
input[0].ki.time        = 0;
input[0].ki.dwExtraInfo = ::GetMessageExtraInfo();

::SendInput( 1, input, sizeof(INPUT) );

if( !bKeepPressing )
{
input[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP;
::SendInput( 1, input, sizeof(INPUT) );
}
}



void test( HWND hwnd )
{
::SetFocus( hwnd );

KeyAction( VK_SHIFT, TRUE );
{
KeyAction( 'I', FALSE );
}
KeyAction( VK_SHIFT, FALSE );

KeyAction( ' ', FALSE );
KeyAction( 'L', FALSE );
KeyAction( 'O', FALSE );
KeyAction( 'V', FALSE );
KeyAction( 'E', FALSE );
KeyAction( ' ', FALSE );
KeyAction( 'Y', FALSE );
KeyAction( 'O', FALSE );
KeyAction( 'U', FALSE );
KeyAction( VK_OEM_PERIOD, FALSE );

getchar();
}
最終更新:2012年04月24日 09:26
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。