mIRC Home    About    Download    Register    News    Help

Print Thread
#9102 31/01/03 06:13 PM
Joined: Dec 2002
Posts: 271
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
hey, i kinda need to know if there is a event trigger that "see's" when an @window is opened, i know there is one for close, but on *:open:*: doesnt seem to pick up @windows like on *:close:*: does, any ideas?

#9103 31/01/03 09:21 PM
Joined: Jan 2003
Posts: 11
T
Pikka bird
Offline
Pikka bird
T
Joined: Jan 2003
Posts: 11
Try something like this.
Code:
 
on *:ACTIVE:@: { 
  if (!%window. [ $+ [ $active ] ]) {
   echo -s <COMMANDS HERE>
   set %window. $+ $active 1
  } 
  else { return }
}
on *:CLOSE:@: { 
  unset %window. $+ $active 
}
 

#9104 01/02/03 01:50 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Another way is aliasing /window itself to raise a /signal WinOpen which you capture with on *:SIGNAL:WinOpen: elsewhere in your script to handle @windows opening.
Code:

alias window {
  if ($isid) return
  window $1-
  var %@ = $wildtok($1-,@*,1,32)
  if ((-c != $1) && (!$window(%@))) .signal -n WinOpen %@
}
on *:SIGNAL:WinOpen:{
  [color:#006600];
  ;  This is your on *:OPEN:@:{ } event.
  ;
  ;    $1 is the @WindowName
  ;[/color]
 
  echo $color(info2) -sebflirt * $1 just opened
}


EDIT: moved window $1- after the initial if ($isid) return to resolve qwerty's very valid points. Should react much better now. I left the signal -n in because we definitely do want to update on WINOPEN immediately, before completing any other scripts.

Last edited by Hammer; 02/02/03 09:06 AM.

DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#9105 01/02/03 04:25 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Just a few thoughts on this. Imo, "window $1-" should precede the /signal -n for two reasons:

1) If invalid parameters (or $null) are used with /window, the window will not open of course but /signal -n will still be executed, so the scripts that use "on WINOPEN" will think the window is (going to) open. However, if /window is called before /signal -n with invalid parameters, the script will halt with a "* /window: invalid parameters" message and /signal -n will not be called: this is the desired behaviour.

2) If the parameters are correct and window is about to open, on WINOPEN will trigger just before the window is opened, which is not what on *:OPEN: does; it's what on ^*:OPEN: does. This is not necessarily wrong, it depends on how one wants on WINOPEN to behave. However, I don't know if there's a point in having the equivalent of on ^*:OPEN: in signals, since you can't /halt the opening of the @window from within on SIGNAL (at least not without some trickery, like setting a global %var to the value "halt" from within on SIGNAL and call %var as a command inside the /window alias, just before "window $1-"...).

Removing the -n from /signal would have the same effect as switching the 3rd and 4th line, so issue (2) would be resolved; still, (1) wouldn't.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#9106 01/02/03 05:16 PM
Joined: Dec 2002
Posts: 271
N
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
Well thanks for the replies, but i got what i needed to work with a /window alias, see i am testing out mdx a little along with the other dll's, and i wanted to have a treevie of servers, channels, @windows, etc, but the @windows had no trigger, so i played with an alias for what i wanted, here it is, and works for what i need:

Code:
alias window {
  if ($left($2,1) == @) {
    if (!$window($2)) {
      window $1-
      .timer -m 1 1 tview
      return
    }
    if ($1 == -c) && ($window($2)) {
      window $1-
      .timer -m 1 1 tview
      return
    }
  }
  window $1-
}  


Link Copied to Clipboard