mIRC Home    About    Download    Register    News    Help

Print Thread
#107072 06/01/05 06:32 PM
Joined: Dec 2002
Posts: 230
G
greeny Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Hi there,

is there any way to detect that a channel window is being closed while NOT connected to a server? Since on part obviously only triggers while connected to a server...

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
I don't think so, I thought on close might work but this is at the bottom:

Quote:
Note: These events do not trigger for any other types of windows. Channel windows are handled by the on JOIN/PART events.


New username: hixxy
Joined: Dec 2002
Posts: 230
G
greeny Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
On close didn't work, already tried that smirk

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
That's what tidy said, that it wouldn't work.

Joined: Dec 2002
Posts: 230
G
greeny Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Yeah.. I guess it's time for a feature suggestion then..

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
How would we benefit though? Not being connected to a server an all, IMO, it is pretty pointless.

Joined: Dec 2002
Posts: 230
G
greeny Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Well, I need it for a treeview switchbar I'm making. I often disconnect from servers and then close channels while disconnected, so I don't rejoin them.

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Even if nobody benefits it makes sense that you should be able to detect a channel window closing when you're not connected, since you can with every other type of window.


New username: hixxy
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Well, I guess so. smile

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well, it's certainly possible, but to be honest, the code is far from pretty :tongue:

So I suppose the choice you have to make is: either find a dll that triggers on the closing of a channel window, and gives a signal so you can handle it. Though then you have one more dll in your script.

Or you could try out this script, it worked for me, but perhaps you're not too fond of using timers. Note that the interval right now for checking the windows is at 50 ms. Adjust it at will.

When a channel is closed, a signal will be sent to CHANCLOSE with two parameters: 1 = cid, 2 = window name.

Code:
on *:SIGNAL:chanclose:{
  ; your code here 
  ; example: echo -sa Closed channel $2 from server window with cid $1 
}
[color:red]  [/color] 
on *:DISCONNECT: owin.start
on *:CONNECT: owin.stop 
 [color:red]  [/color] 
alias owin.start {
  var %a = 1, %b = net $+ $cid
  while $window(#*,%a) { hadd -m %b $v1 1 | inc %a } 
  if $hget(%b) { .timerowin.chk -m 0 50 owin.chk $cid %b }
}
 [color:red]  [/color] 
alias owin.stop {
  if $hget(net $+ $cid) { .timerowin.chk off | hfree $v1 }
}
[color:red]  [/color] 
alias owin.chk {
  scid $1
  if $hget($2,0).item > $window(#*,0) { 
    var %a = $v1, %b = %a - $v2, %c
    while %b && $hget($2,%a).item {
      %c = $v1
      if !$window(%c) {
        hdel $2 %c
        signal chanclose $1 %c
        if !$hget($2,1).item { owin.stop | return }
        dec %b
      }
      dec %a 
    }
  }
}


Greets

Last edited by FiberOPtics; 07/01/05 12:04 AM.

Gone.
Joined: Dec 2002
Posts: 230
G
greeny Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Well, I managed to find another way to achieve this...

I'm looking at the on active event, check $lactive and if it no longer exists, I trigger my aliases smile

Better than timers I think.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Lol that doesn't really work, well it does but only in limited cases.

Because it requires for you to actually left click on the channel window before closing it.

Try it like this: go with your mouse over a channel button, and right click and press close. Active event won't have triggered for that window, and the $lactive identifier won't be filled with this window when you click another window, so nothing will happen.

Also if you programmatically close windows, it won't happen either. For example: connect to a server, join channels #one and #two. Then disconnect from the server, and then type /part #one. The channel window will close, but once again, active event didn't trigger, so nothing happens.

Anyway, that code was for you, so you should just use whatever you please, if you rather go with the active event, then thats your choice of course.

Greets


Gone.
Joined: Dec 2002
Posts: 230
G
greeny Offline OP
Fjord artisan
OP Offline
Fjord artisan
G
Joined: Dec 2002
Posts: 230
Well FiberOptics, in my case it does work, because as I said I'm using a treeview switchbar, and I don't have no channel buttons, so the window always becomes active before I can close it.

And if I _am_ connected to a server, I can still use the on part event.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Ah ok, Ic, if it's one of those treeview bars that hide the regular bar, then of course those aren't issues for you. I never customize my mIRC with stuff like docked dialogs, switchbars etc, just regular mIRC here.

Oh, the /part thing I noted that it doesn't work when you are offline. Seems the on part event doesn't trigger when you aren't connected, even though it closes the channel window.

Anyway, cya around!


Gone.

Link Copied to Clipboard