WM_COPYDATA
Printed from: StrokesPlus Forum
Topic URL: https://www.strokesplus.com/forum/topic.asp?TOPIC_ID=544
Printed on: 10/08/2024
Topic:
Topic author: plunt
Subject: WM_COPYDATA
Posted on: 12/20/2012 14:40:37
Message:
Do SP support WM_COPYDATA?
Replies:
Reply author: Rob
Replied on: 12/20/2012 16:05:41
Message:
Would you mind being a little more specific?
Reply author: plunt
Replied on: 12/20/2012 16:33:24
Message:
http://msdn.microsoft.com/it-it/library/windows/desktop/ms649011%28v=vs.85%29.aspx
http://www.ghisler.ch/board/viewtopic.php?t=32658
Reply author: Rob
Replied on: 12/20/2012 16:43:29
Message:
I'm familiar with what WM_COPYDATA is, I guess I was looking to understand how you're trying to implement it.
It certainly should be possible through the use of Lua and alien. You'd have to define the structure and declare a SendMessage function. Unfortunately, I don't have any sample code handy.
There's a good bit of stuff in this thread which should help..basically everything you need to do is there, just not put together for your request:
http://www.strokesplus.com/forum/topic.asp?TOPIC_ID=468
Reply author: plunt
Replied on: 12/22/2012 02:01:01
Message:
I try this but not work, how to fix?
_WM_COPYDATA_Send('PowerProMain', "messagebox(?'ok', ?'hi', ?'by')", 1, 0)
function _WM_COPYDATA_Send(Win, sString, dwData, WinRetId)
local hHandle = acFindWindow(Win)
local tp, cd, dw
tp=aliencore.buffer(sString)
dw=dwData
--COPYDATASTRUCT
cd = defstruct{{'dwData', 'pointer'}, {'cbData', 'ulong'}, {'lpData', 'pointer'}}
cd.dwData=dw
cd.cbData=tp.size+1
local buf2 = aliencore.buffer(4)
buf2:set(0, tp:topointer(), "pointer")
cd.lpData=buf2
acSendMessage(hHandle, 0x004A, WinRetId, cd)
end
Reply author: Rob
Replied on: 12/22/2012 10:01:54
Message:
Honestly, that's going to be a tricky one to troubleshoot. As I said before, I'm definitely not a Lua expert :-)
I would recommend using something like Spy++ to examine the message being sent, and maybe Windows Debugger Tools, throwing a message box before sending the message and examining the data structure in memory. Or maybe build a simple program which accepts a 0x004A message and displays the contents of cd when it receives the message.
If I have some time (which won't be in the next few days), I'll see if I can figure anything out for you by doing the above.
Reply author: plunt
Replied on: 12/23/2012 10:37:19
Message:
Spy++ not detects sent messages.
also using:
local SendMessage = user32.SendMessageA
SendMessage:types{ret = "long", abi = "stdcall", "ulong", "uint", "ulong", "ulong"}
local a=SendMessage(hHandle, 0x004A, WinRetId, cd)
hHandle is ok!
0x004A is ok!
Reply author: Rob
Replied on: 12/23/2012 12:10:07
Message:
Try this:
http://www.strokesplus.com/files/StrokesPlus_2.4.6_SendString_x86.zip
I added an (undocumented) acSendString function which fires a WM_COPYDATA message with the string and dwData passed in. This function only supports sending a string, not other structures.
Also, I've added a check for WM_COPYDATA in StrokesPlus.exe (which assumes/supports a string being in lpData) that displays a message box with the dwData and lpData. The purpose of this is simply to test that the structure/message is being received (and presumably would be by other applications as well).
This will send a WM_COPYDATA with the string to the S+ main window, which will cause S+ to read the structure and display the values:
acSendString("messagebox(?'ok', ?'hi', ?'by')", 1, acFindWindow("STROKESPLUS"),nil,nil)
The template the new function is:acSendString(lpData, dwData, handle, x, y)
Reply author: plunt
Replied on: 12/23/2012 13:37:27
Message:
Good, it work perfectly :)
x, y parameters in acSendString have some meaning?
On long term, would be nice to have all the S+ and user functions accessible via WM_COPYDATA as now messagebox in example.
Ty, Ty.
Reply author: Rob
Replied on: 12/23/2012 15:29:05
Message:
x, y functions like it does for other actions; if you don't specify anything in handle, x & y will be used to assign the window handle as the owner window of the window below those coordinates.
Reply author: plunt
Replied on: 12/23/2012 16:21:35
Message:
Not work completelly.
Maybe because there \00?
If so, do you use a character jolly, for example \04, to be replaced then internally \00?
Reply author: Rob
Replied on: 12/23/2012 16:28:24
Message:
You have to escape \ with \\. Look up Lua escape sequences for strings.
Reply author: plunt
Replied on: 12/23/2012 16:37:46
Message:
I have escaped. The \00 not have to escape because is the chr(0) value.
Reply author: Rob
Replied on: 12/23/2012 16:43:15
Message:
I'll have to revisit in the new year :)
I'm getting the evil eye for spending too much time on the computer during my christmas holiday!
Reply author: plunt
Replied on: 12/23/2012 16:47:16
Message:
Ok, you 're right :) Happy Holidays
Reply author: Rob
Replied on: 12/23/2012 21:41:27
Message:
Ok, one last update!
I've updated acSendString (use the same link above, I replaced the .zip) to replace \004 with \000 (before being assigned to the copy data struct).
I've also updated the S+ WM_COPYDATA block to report the size of lpData. So if you call:
acSendString('1234\0046789', 1, acFindWindow("STROKESPLUS"),nil,nil)
\004 is replaced with \000 and S+ reports:
dwData: 1
lpData: 1234
lpData Size: 9
Since MessageBox is using a c-string, it stops at "1234", but the size shows that there are 5 more characters; the null and "6789".
I also did test with a substr of lpData, starting at pos 5 to len and "6789" was displayed.
Hopefully this works! I'm going offline =)
Reply author: plunt
Replied on: 12/24/2012 10:19:29
Message:
It work fine. Ty.
Merry Christmas :)
StrokesPlus Forum : https://www.strokesplus.com/forum/
© 2011-2018 Rob Yapchanyk