Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-27-2008, 02:54 AM
Junior Member
 
Join Date: Apr 2008
Posts: 29
Default How To Pass String Data Between Applications Using SendMessage

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);
receive:
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
}
}
who can help me!
Reply With Quote
  #2 (permalink)  
Old 09-28-2008, 07:50 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: How To Pass String Data Between Applications Using SendMessage

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;
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 09:10 AM
Junior Member
 
Join Date: Apr 2008
Posts: 29
Default Re: How To Pass String Data Between Applications Using SendMessage

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)
but i don't know how to receive the string,
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)
}
}
help me again,I wish you good luck!
Reply With Quote
  #4 (permalink)  
Old 10-08-2008, 07:50 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: How To Pass String Data Between Applications Using SendMessage

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();
...
Reply With Quote
  #5 (permalink)  
Old 10-08-2008, 01:08 PM
Junior Member
 
Join Date: Apr 2008
Posts: 29
Default Re: How To Pass String Data Between Applications Using SendMessage

Thank you very much!My dear friends!! That is what i needed!
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:21 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.