Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
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:
[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.
-----signature-----
|
Link to this post
|
Virindi-Inquisitor
Posts:
6,908
Registered:
Nov 18, '01
Extended Info (if available)
Real Post Cnt: 6,646
User ID: 511,923
|
Subject:
Trying to figure out chat in Decal
|
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
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
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.
-----signature-----
|
Link to this post
|
Virindi-Inquisitor
Posts:
6,908
Registered:
Nov 18, '01
Extended Info (if available)
Real Post Cnt: 6,646
User ID: 511,923
|
Subject:
Trying to figure out chat in Decal
|
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
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
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.
-----signature-----
|
Link to this post
|
Virindi-Inquisitor
Posts:
6,908
Registered:
Nov 18, '01
Extended Info (if available)
Real Post Cnt: 6,646
User ID: 511,923
|
Subject:
Trying to figure out chat in Decal
|
//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
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
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.
-----signature-----
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
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?
-----signature-----
|
Link to this post
|
Digero
Posts:
7,435
Registered:
Oct 21, '02
Extended Info (if available)
Real Post Cnt: 7,359
User ID: 729,875
|
Subject:
Trying to figure out chat in Decal
|
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
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
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
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.
-----signature-----
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
Ok myabe I try a different direction.
How would I click a control button in the Decal GUI?
Something like:
button1.PerformClick();
Where button1 is within PluginCore.
-----signature-----
|
Link to this post
|
Virindi-Inquisitor
Posts:
6,908
Registered:
Nov 18, '01
Extended Info (if available)
Real Post Cnt: 6,646
User ID: 511,923
|
Subject:
Trying to figure out chat in Decal
|
Just call your handler method...?
-----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
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
For some reason I cannot seem to figure myself out of a paper bag.
Thank you for the help. I knew the solution was evading me easily because I am getting frustrated.
The error I am getting completely infuriates me. When I click a button in decal, the function WriteToChat works just fine, but when I call it, it does not. Maybe I should explain what I am trying to do.
This is my goal.
I am trying to do is have a function trip in Decal to send chat type in from outside Decal’s form into AC. I have a form that starts when a user clicks a Decal GUI button.
As soon as that is done, chat from AC begins to appear in this form.
What I would like to do is then allow a person to chat back into AC from this form. Therefore at some point, Decal must get the string from this form and send it to the chatbar. Now there is no issue with the string. I can get it and it will sit and wait to be displayed. I now just need to send it to the chatbox.
This is what I have tried.
The method I first tied was using a timer. This however did not work as I began to get the above error. I tried both the system timer and the forms timer and get the same result (There was a suggestion from an old thread that the form timer might be a better choice). So I asked and someone assisted me in figuring out the proper way of calling a function in my plugin from my outside form.
So I passed the calling Decal object into the form and used that to call a function. When the user clicks the Form “Chat†button, the string is saved and the function WriteToChat within the plugin is called and then the Wrapper function is called.
The error above fallowed me there.
Next I thought, “Well I can click the button and it works, so what if I try and call the button?†Well that does not work either. I get the same error.
I am out of ideas.
-----signature-----
|
Link to this post
|
Virindi-Inquisitor
Posts:
6,908
Registered:
Nov 18, '01
Extended Info (if available)
Real Post Cnt: 6,646
User ID: 511,923
|
Subject:
Trying to figure out chat in Decal
|
Oh, I bet you are having thread issues. If you have a separate thread for your windows form you need to marshal any calls from that to Decal functions. Decal functions must be called from within the AC main thread (where most of the plugin normally resides).
-----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
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
I figured that was what my issue was.
So I thought (foolishly) that I could use System.Timers to call it, but I guess it too is not within the main thread but I am guessing it’s the same whether my form calls it or the System.Timers call it the call comes from outside.
I am not sure of how I would marshal call from my outside forms thread. An example of how to do this could point me in the right direction.
An alternate to that is the Decal Timer. I know it is not the ideal timer to use, but since it is within the main thread it should work (albeit irregularly for tabbed folks). Much of the examples of using this timer are old and I am not sure if it works in the same way.
It seemed like an easy thing for my first plugin to use chat. I mean nearly every plugin in the game uses chat so it should not be hard.
I seemed to have found a way to make it hard. Thank you for your help.
-----signature-----
|
Link to this post
|
Virindi-Inquisitor
Posts:
6,908
Registered:
Nov 18, '01
Extended Info (if available)
Real Post Cnt: 6,646
User ID: 511,923
|
Subject:
Trying to figure out chat in Decal
|
Create a System.Windows.Forms.Timer on the AC thread that polls for updates from the other thread.
-----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
|
Link to this post
|
Xnumt
Posts:
????
Registered:
????
Extended Info (if available)
Real Post Cnt: 0
User ID: 0
|
Subject:
Trying to figure out chat in Decal
|
I am such an r-tard. I understood that I was likely cross threading and because of that the timer was not working. It never occurred to me that the timer itself was cross threaded because I put it in Decal.
But the function I put it in was part of the new thread.
So I have a button that starts the form. That button has the following:
formthread = new System.Threading.Thread(formthreadstartup);
formthread.Start();
Inside formthreadstartup I had the following
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Enabled = true;
myTimer.Interval = 1000;
myTimer.Start();
myform = new Form2(this);
myform.Controls.Add(mylist);
Application.Run(myform);
Now not paying attention, I missed the fact that formthreadstartup was part of the new thread.
I moved the myTimer out of that and into the button directly and now everything functions.
I have a few finishing touches on this and then I will release it all for the masses to mock me.
Thank your all for you help in all of this. It is very much appreciated.
-----signature-----
|
Link to this post
|
Virindi-Inquisitor
Posts:
6,908
Registered:
Nov 18, '01
Extended Info (if available)
Real Post Cnt: 6,646
User ID: 511,923
|
Subject:
Trying to figure out chat in Decal
|
A note: the System.Threading.Timer class fires on a threadpool thread (separate from the thread you created the timer on). The System.Windows.Forms.Timer class fires in the thread that created it, and that thread must have a windows message loop.
-----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
|
Link to this post
|