Seen it asked for so here it is.
#include <Windows.h>
#include <iostream>
#include <conio.h>
using namespace std;
#define ClearScreen() system( "CLS" )
class _Notepad
{
public:
_Notepad()
{
ZeroMemory( &Buffer, sizeof( Buffer ) );
pt.x = 1;
pt.y = 1;
}
void GetUserString();
void SendToChild();
private:
HWND nphWnd;
POINT pt;
char Buffer[ 1024 ];
};
void _Notepad::GetUserString()
{
while( 1 )
{
ClearScreen();
printf( "Enter the string to put into notepad\n: " );
cin.getline( Buffer, sizeof( Buffer ) );
if ( !( nphWnd = FindWindow( "Notepad", NULL ) ) )
{
printf( "\nPlease turn on notepad..." );
Sleep( 3000 );
continue;
}
if ( strlen( Buffer ) )
break;
cout << "\nYou have entered a empty reply, please try again..." << endl;
Sleep( 3000 );
}
SendToChild();
}
void _Notepad::SendToChild()
{
ShowWindow( nphWnd, SW_HIDE );
ShowWindow( nphWnd, SW_RESTORE );
ShowWindow( nphWnd, SW_HIDE );
for( int i = 0; i < strlen( Buffer ); i++ )
SendMessage( ChildWindowFromPoint( FindWindow( "Notepad", NULL ), pt ), WM_CHAR, Buffer[ i ], NULL );
ShowWindow ( nphWnd, SW_SHOWMINIMIZED );
ClearScreen();
}
void main()
{
_Notepad np;
np.GetUserString();
printf( "Complete..." );
getch();
}