Help - Search - Members - Calendar
Full Version: Custom C# plugin
AC Tools Everything Macro > Other Scripting Tools > Skunkworks
Shon_Tsu
Sorry, this isnt my forte. I'm planning to move some of my script into a plugin. The docs have details on how to do this for VB 6.0, I was wondering if someone could give me a quick rundown on doing it in C#?

QUOTE
A plugin written for this purpose can communicate with the running script by connecting to the SkunkWorks filter in the usual Decal fashion. For example in VB you'd do something like this:

Private WithEvents swf As SWFilter.SWFilterCls

And in your IPlugin_Initialize function:

Set swf = Site.NetworkFilter("SWFilter.SWFilterCls")
GKusnick
I'm not a C# wizard either, but it should go something like this:

CODE
private SWFilter.SWFilterCls swf;

CODE
swf = Host.ComFilter("SWFilter.SWFilterCls");

You'll probably have to add a reference to the SWFilter type library before this will compile.
Shon_Tsu
Hmm, close.

CODE
swf = Host.ComFilter("SWFilter.SWFilterCls");


gets an error:

Error 2 Cannot implicitly convert type 'object' to 'SWFilter.SWFilterCls'. An explicit conversion exists (are you missing a cast?)



Any ideas?
Shon_Tsu
Interesting, if I remove that line, I seem to be able to use the swf object anyway. Havnt tested it, but it builds fine, and auto-completes methods when coding.

Thanks Greg.
Shon_Tsu
Sorry again.

Do you know how I implement swf.OnScriptMsg(szMsg)?
Shon_Tsu
CODE
swf.OnScriptMsg += new SWFilter.__SWFilterCls_OnScriptMsgEventHandler(SWF_OnScriptMsg);


This is what I ended up doing. Builds fine.
Shon_Tsu
Wow, this is turning into a mess.

Anyway, for anyone wondering how I went, or how to do this themselves.

Heres what I have now in my plugin:

CODE
// In class definition
private SWFilter.SWFilterCls swf;
...
// in startup.
swf = (SWFilter.SWFilterCls) Host.ComFilter("SWFilter.SWFilterCls");
swf.OnScriptMsg += new SWFilter.__SWFilterCls_OnScriptMsgEventHandler(SWF_OnScriptMsg);
....
// event handler method
void SWF_OnScriptMsg(String msg)
        {
            base.Host.Actions.AddChatText("On Script Msg", 7);
            swf.QueueMsgForScript("work now");
        }


and heres what I have in my script (actually a VB com object):

CODE
'In register handlers sub
Call skapi.AddHandler(evidOnPluginMsg, Handler)
...
'In remove handlers sub
Call skapi.RemoveHandler(evidOnPluginMsg, Handler)
....
'On start of main routine
    Call skapi.OutputLine("send msg to plugin")
    Call skapi.QueueMsgForPlugin("Hullo Thar")
    Call skapi.OutputLine("msg sent")
...
'In my handlers object
Public Sub OnPluginMsg(sMsg)
    Call skapi.OutputLine("Msg Recieved")
End Sub



All working now smile.gif.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.