How to send key strokes to a background Ogre window?

Problems building or running the engine, queries about how to use features etc.
Post Reply
Ziqian_Xie
Gnoblar
Posts: 2
Joined: Thu Jul 31, 2014 8:01 pm

How to send key strokes to a background Ogre window?

Post by Ziqian_Xie »

I'm running a simulation in Ogre and want to control it externally by other program because there's a lot of calculation involved, does anyone has experience in doing so or know other ways to control Ogre animation by another program?
I'm using Windows, I tried this but it's not working:

Code: Select all

{
	HWND hwnd = FindWindow(0,_T("OGRE Render Window"));
	SendMessage(hwnd,WM_CHAR,0x4F/*VK_O*/,0); //also tried WM_KEYDOWN & WM_KEYUP
	printf("WindowHandle: %10x \n", (int)hwnd);
}
The handle I got is the same as the one I got using spy++, I already enabled Ogre window to render animation when it is not focused.
amartin
Halfling
Posts: 87
Joined: Wed Aug 14, 2013 6:55 am
Location: Norway
x 13

Re: How to send key strokes to a background Ogre window?

Post by amartin »

Assuming that you control both programs then it would be much easier and more robust to put in a named pipe or tcp connection and send the input across that. If you make Ogre a child process of the program that is sending the input then the send message should work without too many issues. If you cannot make the ogre process a child process you probably don't have control of the program and are starting to do things to another program that you normally should not do to another program. It gets very complicated to get the messages going but as a start point you'll need to disable UAC and run as adminstrator.
Ziqian_Xie
Gnoblar
Posts: 2
Joined: Thu Jul 31, 2014 8:01 pm

Re: How to send key strokes to a background Ogre window?

Post by Ziqian_Xie »

amartin wrote:Assuming that you control both programs then it would be much easier and more robust to put in a named pipe or tcp connection and send the input across that. If you make Ogre a child process of the program that is sending the input then the send message should work without too many issues. If you cannot make the ogre process a child process you probably don't have control of the program and are starting to do things to another program that you normally should not do to another program. It gets very complicated to get the messages going but as a start point you'll need to disable UAC and run as adminstrator.
Thanks very much!! I will try pipes first.
Post Reply