📄 ppktest.cpp
字号:
#include "PCH.h"
#include "TInputHlp.h"
#include "ParsePlayKeysString.h"
BOOL TestIt ( LPCTSTR szString )
{
PINPUT pInput = NULL ;
UINT uiErrChar = 0 ;
UINT uiCount = 0 ;
printf ( "The test string : %s\n" , szString ) ;
BOOL bRet = ParsePlayKeysString ( szString ,
uiErrChar ,
pInput ,
uiCount ) ;
if ( 0 != uiCount )
{
for ( UINT i = 0 ; i < uiCount ; i++ )
{
printf ( "%02x(%02x) " ,
pInput[i].ki.wVk ,
pInput[i].ki.wScan ) ;
}
printf ( "\n" ) ;
UINT iRet = SendInput ( uiCount , pInput , sizeof ( INPUT ) ) ;
DWORD le = GetLastError ( ) ;
printf ( "SendInput returned : %d, LE = (0x%08X)\n" , iRet , le ) ;
}
else
{
printf ( "Failure at position : %d\n" , uiErrChar ) ;
}
if ( NULL != pInput )
{
delete [] pInput ;
}
printf ( "\n" ) ;
return ( bRet ) ;
}
int _tmain ( int argc , TCHAR * argv[] )
{
if ( 1 == argc )
{
printf ( "The PlayKeys Test Program!\n" ) ;
printf ( "Usage : PPKTest <file>\n" ) ;
printf ( " <file> - The file to use.\n" ) ;
printf ( "All output goes to a spawned copy of Notepad\n\n" ) ;
printf ( "The input file contains the strings to test, one per line\n" ) ;
printf ( "Comment lines start with a semicolon in the first position.\n" ) ;
printf ( "A line with ':Sleep' on it will cause a 1 sec sleep.\n" ) ;
return ( 0 ) ;
}
FILE * pFile = _tfopen ( argv[ 1 ] , _T ( "rt" ) ) ;
if ( NULL == pFile )
{
printf ( "Unable to open the file : %s\n" , argv[ 1 ] ) ;
}
// Start Notepad.
printf ( "Watch Notepad!!!! The output goes there!\n" ) ;
WinExec ( "Notepad" , SW_SHOWNORMAL ) ;
Sleep ( 500 ) ;
printf ( "The codes are displayed as : VirtKey(ScanCode)\n\n" ) ;
TCHAR szReadBuff[ MAX_PATH ] ;
LPTSTR pReadStart = szReadBuff ;
while ( NULL != fgets ( szReadBuff , MAX_PATH , pFile ) )
{
// Does the line start with a semicolon?
if ( _T ( ';' ) == szReadBuff[ 0 ] )
{
// Print the comment to stdout.
printf ( szReadBuff ) ;
continue ;
}
// Strip off the \n on the end.
LPTSTR pCRLF = pReadStart + _tcslen ( szReadBuff ) - 1 ;
*pCRLF = _T ( '\0' ) ;
// Don't let empty lines through.
if ( _T ( '\0' ) == szReadBuff[ 0 ] )
{
continue ;
}
// Check for special codes.
if ( 0 == _tcscmp ( _T ( ":Sleep" ) , szReadBuff ) )
{
Sleep ( 1000 ) ;
continue ;
}
// DO IT!!
TestIt ( szReadBuff ) ;
}
return ( 1 ) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -