|
|||
|
I am trying to send a WM_COPYDATA message to another application in SWFKitpro3.2.but it not work!
I have copied the code below.what's wrong with it. send: Code:
struct{
long wpData
long cbData
String lpData
}COPYDATASTRUCT
var ws=Window.getWindowsByName("receive");
var hwnd=ws[0].handle
var msg="hello world"
var cds = new Struct(COPYDATASTRUCT)
cds.cbData = msg.length
cds.lpData = msg
Application.sendMessage(hwnd, 0x004A, null, cds);
Code:
struct{
long wpData
long cbData
String lpData
}COPYDATASTRUCT
var wnd=getMainWnd()
var receMsg
wnd.onMessage=function(msg, wparam,lparam){
if(msg==0x004A){
var cds = new Struct(COPYDATASTRUCT)
receMsg=cds.lpData
}
}
|
|
|||
|
The Application.sendMessage method doesn't accept a parameter of structure type. You must import the SendMessage function yourself, and declare the last parameter to be a structure explicitly.
Code:
dllimport "user32.dll" stdcall long SendMessageA(long, long, long, COPYDATASTRUCT*) as sendMsg; |
|
|||
|
dear SWFKit!
thank you for your reply,now the sender script is works perfectly! Code:
struct{
long wpData
long cbData
String lpData
}COPYDATASTRUCT
dllimport "user32.dll" stdcall long SendMessageA(long, long, long, COPYDATASTRUCT*) as
sendMsg;
var ws=Window.getWindowsByName("receive");
var hwnd=ws[0].handle
var wnd=getMainWnd()
var mwh=wnd.handle
var msg="hello world"
var csd = new Struct(COPYDATASTRUCT)
csd.cbData = msg.length
csd.lpData = msg
var obj1=new Object()
obj1.value=csd
sendMsg(hwnd, 0x004A, mwh, obj1)
as follows,what i'm doing wrong. I hope you can help me again. Code:
struct{
long wpData
long cbData
String lpData
}COPYDATASTRUCT
var cds=new Struct(COPYDATASTRUCT)
var obj1=new Object()
obj1.value=cds
var wnd=getMainWnd()
wnd.onMessage=function(msg, wparam,obj1){
if(msg==0x004A){
var receMsg=obj1.value.lpData
trace(receMsg)
}
}
|
|
|||
|
The parameter "obj1" of the "onMessage" event handler will always be an integer. FFish script is a kind of Javascript, and it cannot convert an integer to an object automatically as c/c++. However, the "Dll" object provides a couple of methods to read data from memory. In your case, you may try something like the following code
Code:
// reads the memory pointed by "obj1" to a stream object // the size of the memory is the same as that of the structure var ss = Dll.getPointerValue(obj1, cds.structSize); // now it's possible to read the stream var wpData = ss.getLong(); var cbData = ss.getLong(); // Note that the item of "string" type is also a pointer var lpData = ss.getLong(); ... |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|