VaultNetwork.netVault Network Boards
Author Topic: Trying to figure out chat in Decal [Locked]
Xnumt
Posts: 47
Registered:
I know this might not be the most perfect place to post about Decal development but the Decal Dev boards seem to have little traffic so I am trying here.


What I am trying to do is send chat from AC to an outside program. The purpose of this is to create a plugin that launches an application that duplicates chat so the user can have many chat windows without using up AC window space.


The method I am trying to use is sendmessage. It has worked for me before in a different application, but for some reason not here.


This is what I have that works outside Decal:


Quote:

[DllImport("user32.dll"]

public static extern IntPtr SendMessagebyString(IntPtr hWnd, Int32 Msg, IntPtr wParam, String lParam);


[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]

public static extern IntPtr SendMessage(IntPtr hWnd1, Int32 Msg1, IntPtr wParam1, Int32 lParam1);

[DllImport("user32.dll", SetLastError = true)]

public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll", SetLastError = true)]

public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);



Now I have determined that FindWindow/FindWindowEx both are providing the window I need. But SendMessage/SendMessagebyString are not “sending”. (As a note, any variable passed to SendMessagenbyString’s lParam is null after the call. This is an artifact I have not experienced using this before)


However this whole scheme might be a wrong direction. I have tried to use older plugins that manipulate chat to uncover how they send chat out (like the IRC), but I have not been able to.


So does any plugin dev have any idea why SendMessage is not working, and if this is even a good tool to use in this application? Also, if a dev has used a tool to bring in chat from outside, how did you time it? Is there a way to trip the ChatEventsArg in Decal from outside? Or did you use a timer?


Any ideas would be appreciated.
Virindi-Inquisitor  4 stars
Posts: 1,538
Registered: 2001-11-18 22:25:54
Personally I would use TCP. I'm sure there are many people out there (myself being one) who have multiple computers set up next to each other, and it might be nice to be able to have stuff spread between the machines.

Of course, the simplest thing to do would be simply to open an extra window inside the AC process, which is pretty easy with .net.

 

-----signature-----
Virindi
---
****Virindi Plugins FAQ**** http://www.virindi.net/wiki/index.php/Virindi_Plugins_FAQ
http://www.virindi.net - Virindi Tank, Follower, Integrator, Reporter, VCS5, XPHelper, Item Tool, HUDs, etc...
Decal Core Dev - http://www.decaldev.com
Xnumt
Posts: 47
Registered:
The request from a friend was to have the chat window on the same computer, but in a different window. The issue I think moving across machines would be that you could not send chat from the window unless you were focused on that machine. I also wanted the coding to be simple. I chose something that within a machine that I thought was readily available.


If I were to open a new window within AC’s process, wouldn’t it have to be within AC’s window? This is why I created an exe to run alongside AC. I start the application through Decal and run it. It is its own process although the plugin can send start and kill commands.
Virindi-Inquisitor  4 stars
Posts: 1,538
Registered: 2001-11-18 22:25:54
Xnumt posted:

If I were to open a new window within AC’s process, wouldn’t it have to be within AC’s window?



Nope. You probably need to run it in a separate thread, though, and do some thread marshaling.

 

-----signature-----
Virindi
---
****Virindi Plugins FAQ**** http://www.virindi.net/wiki/index.php/Virindi_Plugins_FAQ
http://www.virindi.net - Virindi Tank, Follower, Integrator, Reporter, VCS5, XPHelper, Item Tool, HUDs, etc...
Decal Core Dev - http://www.decaldev.com
Xnumt
Posts: 47
Registered:
Excellent. Threads in .net are not too difficult (when compared to C++ on Linux).


Do you know where I could find an example of this process? None of the code I have seen seems to demonstrate this and I am unsure where to start within Decal.


I appreciate the help. I am interested in this new direction.
Virindi-Inquisitor  4 stars
Posts: 1,538
Registered: 2001-11-18 22:25:54
//Example C# plugin to display AC chat in a listbox in an external window
//Threading allows the window to be moved without affecting AC
//Uses a windows form called testform with a public listbox called listBox1
using System;
using System.Collections.Generic;
using System.Text;
using Decal.Adapter;
using Decal.Adapter.Wrappers;
using System.Windows.Forms;

namespace pluginwindowtest
{
public class Class1: PluginBase
{
testform myform = null;
ListBox mylist = null;
System.Threading.Thread formthread;
delegate void delempty();
delegate void deladd(string txt);

//////////////////////////////////////////Begin stuff for the other thread
void formthreadstartup()
{
myform = new testform();
mylist = myform.listBox1;
Application.Run(myform);
}

void formthreadkill()
{
myform.Dispose();
myform = null;
mylist = null;
}

void formthreadaddstr(string txt)
{
mylist.Items.Add(txt.TrimEnd('\n');
}
//////////////////////////////////////////End stuff for the other thread

void Core_ChatBoxMessage(object sender, ChatTextInterceptEventArgs e)
{
if (mylist == null) return;
mylist.Invoke(new deladd(formthreadaddstr), e.Text);
}

protected override void Startup()
{
formthread = new System.Threading.Thread(formthreadstartup);
formthread.Start();
Core.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(Core_ChatBoxMessage);
}

protected override void Shutdown()
{
Core.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(Core_ChatBoxMessage);
myform.Invoke(new delempty(formthreadkill));
}
}
}

 

-----signature-----
Virindi
---
****Virindi Plugins FAQ**** http://www.virindi.net/wiki/index.php/Virindi_Plugins_FAQ
http://www.virindi.net - Virindi Tank, Follower, Integrator, Reporter, VCS5, XPHelper, Item Tool, HUDs, etc...
Decal Core Dev - http://www.decaldev.com
Xnumt
Posts: 47
Registered:
HA HA HA, this is why I need more friends who code.


It never donned on me just to create the window within Decal. I have done that so many times in applications but I left my senses it seems when I began to look at Decal. Somehow it was different.


Thank you for the help. I really appreciate it.
Xnumt
Posts: 47
Registered:
I have another question.


What do I call to send chat out?


I have been using AddChatText, but that just puts the text in the box. What would I call to say send a tell to another, or send chat to the /a channel?
Digero  3 stars
Posts: 580
Registered: 2002-10-21 23:55:01
Host.Actions.InvokeChatParser("/t digero, hello";

 

-----signature-----
[LotRO] Digero (Guardian), Digrim (Burglar), Dignite (LM), Azrea (Hunter) - Landroval
[AC] Digero, Lyera, Draxxe - Leafcull (Retired)
[CoH] Devil's Zealot, Scinta, Izzard - Guardian (Retired)
Digero's AC Decal Plugins: http://decal.acasylum.com
Xnumt
Posts: 47
Registered:
I really appreciate the help. I have an error I have been getting that prevents me from finishing. I have posted in on the DecalDev boards but I will re-iterate it here.


I am getting the following error from the log


Quote:

9/5/2009 1:04:23 PM

Error: Unable to cast COM object of type 'Decal.Interop.Core.ACHooksClass' to interface type 'Decal.Interop.Core.IACHooks'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{93FD982E-D1CE-46C3-9428-532ACCDA06CE}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).

Source: Decal.Interop.Core

Stack: at Decal.Interop.Core.ACHooksClass.AddChatText(String szText, Int32 lColor, Int32 lTarget)

at Decal.Adapter.Wrappers.HooksWrapper.AddChatText(String text, Int32 color)

at XnuTalk.PluginCore.WriteToChat(String Message) in C:\Documents and Settings\Joe\My Documents\Visual Studio 2005\Projects\XnuTalk\XnuTalk\ChatEvents.cs:line 94



To see the total post I created on Decavdev:

http://forums.acdev.org/phpBB2/viewtopic.php?p=26164#26164

It explains what the code is and my intentions.


I hope someone has an idea of what I am doing incorrectly.

VaultNetwork.net is an independently operated community forum and is not affiliated with, endorsed by, or technically based on IGN, GameSpy, FilePlanet, GameStats, or the former IGN/GameSpy Vault Network.
References to VaultNetwork.net mean this site/domain. VNBoards-style presentation is a visual homage only. By using this site, you agree to the forum rules.