What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Resolved] Talking to VB.

Pages: (2): « First « 1 [ 2 ] Last »
[Resolved] Talking to VB.
Author: Message:
Tails
Junior Member
**


Posts: 19
36 / Male / –
Joined: Oct 2004
O.P. RE: Talking to VB.
I have no idea how this is to be done.

This way sounds alot better and alot less complecated then my way!

But i don't know how to make JS raise an event (i supose a class would be better and having public events that JS triggers, with some parameters that are passed when the event is triggered such as text). The ActiveX will work this way.
07-09-2006 04:24 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Talking to VB.
Forget about events and stuff, just as in VB6, in the scripts the events are triggered automatically. Everything is done right inside the scripts. All you need to do is make some functions to handle your text.

Read and study the scripting documentation, examples are shown there.

Also, you can find examples in the scripting database.

eg: Some basic JScript code you need:
code:
function OnEvent_SigninReady(sEmail) {
    var oMyBot = new ActiveXObject('Your.ActiveX');
}

function OnEvent_ChatWndReceiveMessage(pChatWnd, sOrigin, sMessage, nMessageKind) {
    Debug.Trace('Chat window: ' + pChatWnd);
    Debug.Trace('Contact name: ' + sOrigin);
    Debug.Trace('Message recieved: ' + sMessage);
    Debug.Trace('Message type: ' + nMessageKind);
    if (sOrigin != Messenger.MyName) {
        var ReplyMessage = oMyBot.ProcedureToHandleText(sMessage);
        pChatWnd.SendMessage(ReplyMessage);
    }
}
and in your VB6 code all you need is the procedure "ProcedureToHandleText" inside a public class module to handle the text and which will return a string to send back to the convo.

And as you can see, it is actually quite easy to replace
code:
var ReplyMessage = oMyBot.ProcedureToHandleText(sMessage);
with your text manipulating routines in JScript itself. You don't need VB6 at all. JScript isn't that hard...

This post was edited on 07-09-2006 at 10:29 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-09-2006 10:27 AM
Profile PM Find Quote Report
Griffo
Junior Member
**


Posts: 27
Joined: Apr 2006
RE: Talking to VB.
I've been trying to work with DLL's too, not much luck though!

I've tried making a basic script to simply display some test from a DLL.

SCRIPT:
code:
function OnEvent_Initialize(MessengerStart)
{
var MyActiveXObject = new ActiveXObject('Project1.Class1');
Debug.Trace(MyActiveXObject.ShowMyText);
}

VB DLL:
code:
Public Function ShowMyText()
ShowMyText = "Hello World!"
End Function

I am using the code above, but I keep getting the following error..."
code:
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Error: Wrong number of arguments or invalid property assignment.
       Line: 4. Code: -2146827838.
Function OnEvent_Initialize returned an error. Code: -2147352567

Any idea what I am doing wrong?

Thanks :)

This post was edited on 07-09-2006 at 11:06 AM by Griffo.
07-09-2006 11:04 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Talking to VB.
The VB DLL must be an ActiveX DLL, this means your exposed functions need to be in a public class module. Look at the plugin documentation for Plus!3. Plugins are ActiveX DLLs. Example provided in the docs.
.-= A 'frrrrrrrituurrr' for Wacky =-.
07-09-2006 11:11 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Talking to VB.
And you also have to regsvr32 the dll so it is registered on the computer.
07-09-2006 02:27 PM
Profile E-Mail PM Find Quote Report
Griffo
Junior Member
**


Posts: 27
Joined: Apr 2006
RE: Talking to VB.
Yup covered all that, still no joy! :( Anyone got an example at all?
07-09-2006 03:56 PM
Profile E-Mail PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Talking to VB.
quote:
Originally posted by Griffo
code:
function OnEvent_Initialize(MessengerStart)
{
var MyActiveXObject = new ActiveXObject('Project1.Class1');
Debug.Trace(MyActiveXObject.ShowMyText);
}

It should be written as MyActiveXObject.ShowMyText()
code:
function OnEvent_Initialize(MessengerStart)
{
var MyActiveXObject = new ActiveXObject('Project1.Class1');
Debug.Trace(MyActiveXObject.ShowMyText());
}
quote:
Originally posted by Griffo
code:
Public Function ShowMyText()
ShowMyText = "Hello World!"
End Function

When declaring ShowMyText it should return a string
code:
Public Function ShowMyText() As String
ShowMyText = "Hello World!"
End Function

Here you go.

.plsc File Attachment: ActiveXObject Example.plsc (4.74 KB)
This file has been downloaded 340 time(s).

This post was edited on 07-09-2006 at 04:21 PM by matty.
07-09-2006 04:19 PM
Profile E-Mail PM Find Quote Report
Griffo
Junior Member
**


Posts: 27
Joined: Apr 2006
RE: Talking to VB.
Thanks a lot mate, works perfectly now! :D
07-09-2006 08:32 PM
Profile E-Mail PM Web Find Quote Report
Tails
Junior Member
**


Posts: 19
36 / Male / –
Joined: Oct 2004
O.P. RE: Talking to VB.
Script is starting
Script is now loaded and ready
Function called: OnEvent_Initialize
Error: Automation server can't create object.
       Line: 5. Code: -2146827859.
Function OnEvent_Initialize returned an error. Code: -2147352567

It can't create your ActiveX. I tried registering it manually as well. I used the project you provided and tried my own.

EDIT *** The way i got it to work was to comment the register and unregister lines and create my own bat file.

Thank you for this, your way is soo much better.:D:P

This post was edited on 07-09-2006 at 10:59 PM by Tails.
07-09-2006 10:54 PM
Profile E-Mail PM Web Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
RE: [Resolved] Talking to VB.
Also remember that when you make changes to your dll, and even unregister and re-register it, your script won't be able to use the new dll UNLESS:

1. you restart messenger or
2. save the dll with a different project name and use that when creating ActiveXObject
[Image: clb2.jpg]
07-09-2006 11:30 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On