I want to send a single keyboard command (down arrow) to DOSBOX, followed by executing some processing code in C#, then looping. My aim is to automate the running of a DOS program.
The code I have works successfully on Notepad and Windows Explorer however will not work on DOSBOX.
This is my (simplified) code:
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
static void Main(string[] args)
{
Console.ReadKey();
System.Threading.Thread.Sleep(2000); //to give me time to set focus to the other window
SendMessage(new IntPtr(0x001301CE), 0x0100, new IntPtr(0x28), new IntPtr(0));
}
I obtained the handle for the window using WinSpy++, DOSBOX only has one window and no child windows and this process works fine for notepad and explorer. The other perameters I'm sending to the SendMessage method are the code for the keyboard notification keydown and the code for the down arrow key.
So my question is, how can I modify my code to send keypresses to DOSBOX, or is there a different way that I can achieve this?