Important alert: (current site time 7/15/2013 5:44:10 PM EDT)
 

VB icon

[ TypeAndSendToNotepad() ]

Email
Submitted on: 1/17/2005 10:03:22 AM
By: Brenton Andrew Saunders 
Level: Beginner
User Rating: By 7 Users
Compatibility: Microsoft Visual C++
Views: 10513
(About the author)
 
     A function that gets console input from the user and then puts it in Microsoft (R) Notepad. It is really cool! *PLEASE* comment on it or vote for it.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: [TypeAndSendToNotepad()]
// Description:A function that gets console input from the user and then puts it in Microsoft (R) Notepad. It is really cool! *PLEASE* comment on it or vote for it.
// By: Brenton Andrew Saunders
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8816&lngWId=3//for details.//**************************************

#include <windows.h>
#include <stdio.h>
VOID TypeAndSendToNotepad()
{
	CHAR szBuffer[256];
	HWND hwndNotepad;
	HWND hwndEdit;
	gets(szBuffer);
	hwndNotepad = FindWindow("Notepad", (LPCTSTR)NULL);
	if(!hwndNotepad)
		return;
	hwndEdit = FindWindowEx(hwndNotepad, (HWND)NULL, "Edit", (LPCTSTR)NULL);
	if(!hwndEdit)
		return;
	for(int i = 0; i < lstrlen(szBuffer); i ++)
	{
		SendMessage(hwndEdit, WM_CHAR, (WPARAM)(TCHAR)szBuffer[i], (LPARAM)NULL);
	}
	SendMessage(hwndEdit, WM_CHAR, (WPARAM)(TCHAR)'\n', (LPARAM)NULL);
}
void main()
{
	puts("Please enter your name:");
	TypeAndSendToNotepad();
	puts("Please enter your age:");
	TypeAndSendToNotepad();
	puts("Please enter your sign (Aries, Taurus, Gemini, etc.):");
	TypeAndSendToNotepad();
	puts("Please enter (3) of your hobbies:");
	for(int i = 0; i < 3; i ++)
	{
		TypeAndSendToNotepad();
	}
}


Other 46 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
5/18/2005 3:53:30 PM

Hi nice program can u help me out with some thing can u make a simple..e,p sending an email to my frind and recive at da same time the same msg
if yez plz reply back...
(If this comment was disrespectful, please report it.)

 
4/7/2006 7:24:38 AMAlex

Nice, simple and easy code ;)
For a future version maybe make it can open notepad for you
(If this comment was disrespectful, please report it.)

 
9/8/2006 5:20:52 AMEric Pierce

Very nice. Good little learning example. Thanks.
(If this comment was disrespectful, please report it.)

 
9/18/2006 4:49:11 PMFermaN(AYT)

simple and nice code.thanks.(Lamer CwDoktoray)
(If this comment was disrespectful, please report it.)

 
9/21/2006 10:35:09 PMsunny

very good program but kindly tell mehow can run it on borland c++ which does n't have window header file
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.