Code: Select all
Send_WM_CopyData(StringToSend, WinTitle) {
; Set up the structure's memory area.
VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)
; First set the structure's cbData member to the size of the string, including its zero terminator:
SizeInBytes := (StrLen(StringToSend) + 1) * (A_IsUnicode ? 2 : 1)
NumPut(SizeInBytes, CopyDataStruct, A_PtrSize) ; OS requires that this be done.
NumPut(&StringToSend, CopyDataStruct, 2*A_PtrSize) ; Set lpData to point to the string itself.
DetectHiddenWindows, On
; 0x4a WM_COPYDATA.
TimeOutTime := 4000
SendMessage, 0x4a, 0, &CopyDataStruct,, %WinTitle%,,,, %TimeOutTime%
; FileAppend, ErrorLevel: %ErrorLevel%`n,*
; Return SendMessage's reply back to our caller.
return ErrorLevel
}
Receiving on c++:
Code: Select all
switch(msg)
{
case WM_COPYDATA:
{
OutputDebugString(L"\nWM_COPYDATA!");
PCOPYDATASTRUCT pcds = reinterpret_cast<PCOPYDATASTRUCT>(lParam);
std::string received_data = (char*)pcds->lpData;
std::string data = received_data;
thread = std::async(std::launch::async, [data]
{ InterpretReceivedData(data); });
return 1;
}
}
However its being received just one character, if i send:
Send_WM_CopyData("abc", WinTitle)
It does receive a.
I could not find the type of the data being sent, if its a char, then im not sure if im receiving it correctly.