Struct with data sent(hwnd, wchar[1024]) is naturally stored in lpdata(ref: http://msdn.microsoft.com/query/dev10.qu...2B%22%29;k%28TargetOS-WINDOWS%)
c++ code and struct sent...
///////////////////////////////// //make_struct c(L"text"); // just a struct with ctor, hwnd and text(passed) are stored in struct //c.text //c.hwnd ///////////////////// COPYDATASTRUCT cds; ::ZeroMemory(&cds, sizeof(COPYDATASTRUCT)); cds.dwData = 1; cds.lpData = c; ::SendMessage(g_main, WM_COPYDATA, (WPARAM)::GetDesktopWindow(), (LPARAM)&cds);
Now the receiving part from autoit. I cant figure how to slice the struct in autoit code and get info piece by piece(hwnd then text(wchar))...
The only thing i managed to do is simply send wchar[1024] in lpdata, with the following code... I would prefer to send a struct as lpdata instead so i can receive hwnd as well without sending more wm_copydata messages.
Func WM_COPYDATA($hWnd, $MsgID, $wParam, $lParam) Switch $hWnd Case $myform Local $tCOPYDATA = DllStructCreate("ULONG_PTR;DWORD;PTR", $lParam) Local $tMsg = DllStructCreate("WCHAR[1024]", DllStructGetData($tCOPYDATA, 3)) $sWM_COPYDATA_Received_String = DllStructGetData($tMsg, 1) ConsoleWrite("received str > "&$sWM_COPYDATA_Received_String&@LF) EndSwitch EndFunc ;==>WM_COPYDATA
Edited by Aktonius, 31 January 2012 - 06:28 AM.






