I'm still not getting the desired response that I expect to get. For instance I want to try and pass some menu commands to my application to upload a program to a serial controller and I need to access the __file menu and select __Download from there, so i theory I need to pass <ALT>F then D or <ALT>F <ALT>D to the application. I've tried to use the messaging system calls as set out in my code to try and open windows notepad menu but there is no response. I managed to get the handle successfull now but the messages passed has no response, can you please elaborate on the sequence to actually pass the keystrokes to the application now?
Below the code of what I've done so far.
Code:
#include "windows.h"
#include <ansi_c.h>
#include <utility.h>
#include <cvirte.h>
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
int ExeHandle;
HWND WindowHandle;
LRESULT Result;
if (InitCVIRTE (hInstance, 0, 0) == 0)
return -1; /* out of memory */
//launch my application here
//system (Notepad.exe WinMSG.txt);
LaunchExecutableEx ("Notepad.exe WinMSG.txt", LE_SHOWNORMAL, &ExeHandle);
//get the handle to the application
WindowHandle = FindWindow(
"Notepad", //LPCTSTR lpClassName - class name
"WinMSG.txt - Notepad"//LPCTSTR lpWindowName - window name
);
//and send a message to the application
Result = SendMessage(
WindowHandle, // handle to destination window
WM_KEYDOWN, // message
VK_MENU, // first message parameter
1 // second message parameter
);
Result = SendMessage(
WindowHandle, // handle to destination window
WM_CHAR, // message
'a', // first message parameter
1 // second message parameter
);
TerminateExecutable (ExeHandle);
RetireExecutableHandle (ExeHandle);
return 0;
}
Code tags added by Hammer