⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 playtest.cpp

📁 应用程序调试技术(DebuggingApplication)源代码
💻 CPP
字号:
#include "PCH.h"
#include "TInputHlp.h"

int _tmain ( int argc , TCHAR * argv[] )
{
    if ( 1 == argc )
    {
        printf ( "The PlayTest Test Program!\n" ) ;
        printf ( "Usage : PlayTest <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 ) ;

    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!!
        UINT uiErrPos ;
        UINT uiPKRet = PlayKeys ( szReadBuff , &uiErrPos ) ;
        if ( PK_SUCCESS !=  uiPKRet )
        {
            printf ( "PlayKeys failed -> %d!\n" , uiPKRet ) ;
            printf ( "Input     : %s\n" , szReadBuff ) ;
            printf ( "Error Pos : %d\n" , uiErrPos ) ;
        }

    }

    return ( 1 ) ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -