Skip to main content
gamedev.net
🔒 Locked

SendMessage Between DOS programs

Started by mrdaveo 1 reply 600+ views
Original Post
mrdaveo
mrdaveo
Hello! I'm trying to send a message between two windows, basicly I just have a input waiting in the other window using "cin" and I want another program to make that input. The name of the program is named "GetMessageApp". after some reading I understood that I need the "handle" for this DOS window and I dont really know how to get it. I understand that this is easy in the "Graphical" programs but when you are using DOS windows its a bit harder. This is my little program called GetMessageApp.exe


#include <iostream>
#include <string>
using namespace std;

int main() {
string msg;
cout << "Wating for message.." <<endl;
cin >> msg;
cout << msg <<endl;

system("PAUSE");
return 0;
}
And this is my "not really finished other Dos program" :)


#include <windows.h>
#include <stdio.h>
#include <iostream>
using namespace std;

#pragma comment(lib, "User32.lib")

void Send() {

	HWND GetMessageApp;
	HWND result;
	result = FindWindowEx(GetMessageApp,NULL,NULL,NULL);
	SendMessage(GetMessageApp,WM_KEYDOWN,NULL,NULL);
}

int main(void)
{
	Send();
	cout << "Message sent" <<endl;
	return 0;
}


As you see I'm not really familiar with WinAPI and its functions so I thought maybe anyone want to help me out a bit in finding the handler for my first program so I will able to perform this maybe pretty easy task :) Thanks in advance! / David
workingclass77
workingclass77
There's a function called GetConsoleWindow(). I don't know if it works for an actual console application, or if it only works with a normal win32 application that creates a console for itself. Something to try, anyway.
---"While there is a lower class I am in it; while there is a criminal element I am of it; while there is a soul in prison, I am not free" - Eugene V. Debs---

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.