Author |
Topic |
|
plunt
Italy
88 Posts |
Posted - 12/20/2012 : 14:40:37
|
Do SP support WM_COPYDATA? |
|
Rob
USA
2615 Posts |
Posted - 12/20/2012 : 16:05:41
|
Would you mind being a little more specific? |
|
|
plunt
Italy
88 Posts |
|
Rob
USA
2615 Posts |
Posted - 12/20/2012 : 16:43:29
|
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 |
|
|
plunt
Italy
88 Posts |
Posted - 12/22/2012 : 02:01:01
|
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 |
|
|
Rob
USA
2615 Posts |
Posted - 12/22/2012 : 10:01:54
|
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. |
|
|
plunt
Italy
88 Posts |
Posted - 12/23/2012 : 10:37:19
|
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! |
|
|
Rob
USA
2615 Posts |
Posted - 12/23/2012 : 12:10:07
|
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) |
|
|
plunt
Italy
88 Posts |
Posted - 12/23/2012 : 13:37:27
|
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. |
Edited by - plunt on 12/23/2012 13:39:06 |
|
|
Rob
USA
2615 Posts |
Posted - 12/23/2012 : 15:29:05
|
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. |
|
|
plunt
Italy
88 Posts |
Posted - 12/23/2012 : 16:21:35
|
Not work completelly. Maybe because there \00? If so, do you use a character jolly, for example \04, to be replaced then internally \00? |
Edited by - plunt on 12/26/2012 16:09:38 |
|
|
Rob
USA
2615 Posts |
Posted - 12/23/2012 : 16:28:24
|
You have to escape \ with \\. Look up Lua escape sequences for strings. |
|
|
plunt
Italy
88 Posts |
Posted - 12/23/2012 : 16:37:46
|
I have escaped. The \00 not have to escape because is the chr(0) value. |
|
|
Rob
USA
2615 Posts |
Posted - 12/23/2012 : 16:43:15
|
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! |
|
|
plunt
Italy
88 Posts |
Posted - 12/23/2012 : 16:47:16
|
Ok, you 're right :) Happy Holidays |
|
|
Rob
USA
2615 Posts |
Posted - 12/23/2012 : 21:41:27
|
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 =)
|
|
|
plunt
Italy
88 Posts |
Posted - 12/24/2012 : 10:19:29
|
It work fine. Ty. Merry Christmas :) |
|
|
|
Topic |
|
|
|