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();
    }

Recommended Answers

All 3 Replies

Is this a question or code snipped?
Either way you are missing proper description. So please describe the problem or describe what sort of task this code does.

The purpose is in the title, it sends a string that the user enters to a minimized notepad. And I posted it as snippet since it was requested more than once.

I don't know why it said "no complile tool is associated with the file extension

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.