Im trying to send text to the place where you type messages in an msn conversation but i cant seem to do it.

{

				char buffer[MAX_PATH];
				char *message = "hello";
				sprintf(buffer, "%s", message); 

				GetWindowText(hwContact, szContact, 256);
				strcpy(&szContact[strlen(szContact)], " - Conversation");

				//GetWindowText(hwMsg, szMsg, 256);
				//strcpy(&szMsg[strlen(szMsg)], "");
				
				HWND fcContact = FindWindow(NULL, szContact);

				ShowWindow(fcContact, SW_SHOWMAXIMIZED);
				SetForegroundWindow(fcContact);
				
				Sleep(5000);
			
				SendMessage(NULL, WM_SETTEXT, 0, (LPARAM)buffer);

				break;
			}

If i change

SendMessage(NULL, WM_SETTEXT, 0, (LPARAM)buffer);

to

SendMessage(fcContact, WM_SETTEXT, 0, (LPARAM)buffer);

it changes the name of the window because fcContact is the windows handle, but how do i get the handle of the section where you type the messages in msn.

I hope im kinda clear on this :(

Member Avatar for iamthwee

Can't you use a global key hook? Well maybe

Hi, this works for notepad, so i think it'll work for msn. Modify it a little and try it.

#include <windows.h>
int main()
{

char buffer[MAX_PATH];
char *message = "hello";
sprintf(buffer, "%s", message); 

//GetWindowText(hwContact, szContact, 256);
//strcpy(&szContact[strlen(szContact)], " - Conversation");

//GetWindowText(hwMsg, szMsg, 256);
//strcpy(&szMsg[strlen(szMsg)], "");
				
HWND fcContact = FindWindow(NULL, "Untitled - Notepad");

ShowWindow(fcContact, SW_SHOWMAXIMIZED);
SetForegroundWindow(fcContact);
//FindWindowEx( hTray, NULL, "Button", NULL);
SendMessage(FindWindowEx(fcContact, NULL, "Edit", NULL), WM_SETTEXT, 0, (LPARAM)buffer);

return 0;
}
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.