Project

General

Profile

API and Windows (AdiIRC, not the OS) help desired

Added by Larry Estep 3 months ago

I would like to create a filter that moves traffic to other windows.

I would like to be able to check to see if the windows I want to write to already exist, and if they don't, then create them.

Is there a direct way to create a window with the API?

If I create the window, I can use the API to find it, but when I try to output to it, the output goes to the server window.

This is the C# code I use to find and write to an existing window called @announce :

   var activewin = _host.ActiveIWindow;
   var winlist = _host.GetWindows;

   IWindow outwin = activewin;  // default value in case @announce does not exist.

   foreach (IWindow w in winlist)
   {
      if (w.Name == "@announce") {
         outwin = w;
         break;
      }
   }

   outwin.OutputText($"Testing {outwin.Name}\n");

The result is Testing @announce , but it shows up in the server window instead of the @announce window.


Replies (5)

RE: API and Windows (AdiIRC, not the OS) help desired - Added by Per Amundsen 3 months ago

It should work, I'll do some testing.

For now, you could do host.ActiveIWindow.ExecuteCommand("/echo @announce bla bla bla");

RE: API and Windows (AdiIRC, not the OS) help desired - Added by Per Amundsen 3 months ago

Also, There isn't an API for creating custom windows yet, but you can use the ExecuteCommand API to create the window, e.g ActiveIWindow.ExecuteCommand("/window @announce");

You can also call identifiers with IWindow.Evaluate("identifier", "parameters"); which could also be used to check if a window exists, if necessary, something (untested) like:

if (ActiveIWindow.Evaluate("$window(@announce)", "") == "") {
  ActiveIWindow.ExecuteCommand("/window @announce");
}

RE: API and Windows (AdiIRC, not the OS) help desired - Added by Larry Estep 3 months ago

For now, you could do host.ActiveIWindow.ExecuteCommand("/echo @announce bla bla bla");

Thanks. I hadn't thought of that. I believe I will give it a try.

if (ActiveIWindow.Evaluate("$window(@announce)", "") == "") {
  ActiveIWindow.ExecuteCommand("/window @announce");
}

This I had considered, but hadn't tried it yet. The example is much appreciated.

RE: API and Windows (AdiIRC, not the OS) help desired - Added by Larry Estep 3 months ago

Just wanted to say that I am using your suggested workarounds and they are working great.

Thank you!

RE: API and Windows (AdiIRC, not the OS) help desired - Added by Per Amundsen 3 months ago

Awesome, thanks for letting me know.

    (1-5/5)