StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Lua Scripts
 General Action Scripts
 WM_COPYDATA
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

plunt

Italy
83 Posts

Posted - 12/20/2012 :  14:40:37  Show Profile  Reply with Quote
Do SP support WM_COPYDATA?

Rob

USA
2516 Posts

Posted - 12/20/2012 :  16:05:41  Show Profile  Visit Rob's Homepage  Reply with Quote
Would you mind being a little more specific?
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/20/2012 :  16:33:24  Show Profile  Reply with Quote
http://msdn.microsoft.com/it-it/library/windows/desktop/ms649011%28v=vs.85%29.aspx

http://www.ghisler.ch/board/viewtopic.php?t=32658
Go to Top of Page

Rob

USA
2516 Posts

Posted - 12/20/2012 :  16:43:29  Show Profile  Visit Rob's Homepage  Reply with Quote
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
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/22/2012 :  02:01:01  Show Profile  Reply with Quote
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
Go to Top of Page

Rob

USA
2516 Posts

Posted - 12/22/2012 :  10:01:54  Show Profile  Visit Rob's Homepage  Reply with Quote
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.
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/23/2012 :  10:37:19  Show Profile  Reply with Quote
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!
Go to Top of Page

Rob

USA
2516 Posts

Posted - 12/23/2012 :  12:10:07  Show Profile  Visit Rob's Homepage  Reply with Quote
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)
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/23/2012 :  13:37:27  Show Profile  Reply with Quote
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
Go to Top of Page

Rob

USA
2516 Posts

Posted - 12/23/2012 :  15:29:05  Show Profile  Visit Rob's Homepage  Reply with Quote
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.
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/23/2012 :  16:21:35  Show Profile  Reply with Quote
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
Go to Top of Page

Rob

USA
2516 Posts

Posted - 12/23/2012 :  16:28:24  Show Profile  Visit Rob's Homepage  Reply with Quote
You have to escape \ with \\. Look up Lua escape sequences for strings.
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/23/2012 :  16:37:46  Show Profile  Reply with Quote
I have escaped. The \00 not have to escape because is the chr(0) value.
Go to Top of Page

Rob

USA
2516 Posts

Posted - 12/23/2012 :  16:43:15  Show Profile  Visit Rob's Homepage  Reply with Quote
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!
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/23/2012 :  16:47:16  Show Profile  Reply with Quote
Ok, you 're right :) Happy Holidays
Go to Top of Page

Rob

USA
2516 Posts

Posted - 12/23/2012 :  21:41:27  Show Profile  Visit Rob's Homepage  Reply with Quote
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 =)
Go to Top of Page

plunt

Italy
83 Posts

Posted - 12/24/2012 :  10:19:29  Show Profile  Reply with Quote
It work fine. Ty.
Merry Christmas :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000