SendMessage
int SendMessage(Handle hWnd, int msg, int wParam, int lParam)Description
Sends a Windows message to the window identified by the given handle.
This function calls the Win32 API SendMessage internally and returns the result as an integer.
It can be used to interact with windows and controls at a low level, e.g. sending WM_CLOSE, BM_CLICK, or WM_SETTEXT.
The predefined Windows message constants (WM_CLOSE, WM_KEYDOWN, BM_CLICK, etc.) can be used directly as the msg parameter.
Parameter
- hWnd - A Handle to the target window or control.
- msg - The Windows message to send (e.g. WM_CLOSE, BM_CLICK).
- wParam - Additional message-specific information (WPARAM).
- lParam - Additional message-specific information (LPARAM).
Return
- int - The result of the message processing, as returned by the target window procedure.
Example
void main()
{
int pid = GetProcessID("notepad.exe");
Handle h = GetProcessIDHandle(pid);
// Close the window
SendMessage(h, WM_CLOSE, 0, 0);
}