mIRC Homepage
Posted By: bunar @window event - 09/01/04 09:53 AM
is there a code for event like this:

on @window open, play something.wav or midi or whateva

?
Posted By: module Re: @window event - 09/01/04 10:31 AM
ON *:OPEN:@WINDOW_NAME_HERE:{
Commands
}

For more information on this in mIRC type /help on open
Posted By: bunar Re: @window event - 09/01/04 11:07 AM
thank you so much !
Posted By: qwerty Re: @window event - 09/01/04 11:17 AM
The /help on open page mentions that the OPEN event does not trigger for custom windows.
Posted By: bunar Re: @window event - 09/01/04 12:42 PM
so is this code correct huh?

(not eh?) then which one is it?
Posted By: qwerty Re: @window event - 09/01/04 01:02 PM
There's no event for that. Your best alternative is a /timer.
Posted By: krvabo Re: @window event - 09/01/04 01:41 PM
couldn't you use
Code:
on *:TEXT:*open friggin' window*:#: {
window -l @window
beep
aline @window I said beep
}

?
Posted By: theRat Re: @window event - 09/01/04 02:19 PM
Why don't you just play the sound when you open the @window?
Posted By: module Re: @window event - 09/01/04 02:30 PM
My fault, sorry for the misinformed information...
Posted By: bunar Re: @window event - 09/01/04 03:17 PM
well thatz exactly what i want (when window opens something should played) but what code is it?
Posted By: Adrenalin Re: @window event - 10/01/04 03:31 PM
Code:
Alias Window {
  if (@* iswm $1) var %Window = $1
  else var %Window = $2
  if (!$window(%Window)) play ZdobSiZdubCoolSound.wav
  window $1-
}
Posted By: DaveC Re: @window event - 10/01/04 05:52 PM
how many times does someone open a window with no switches, you really need to check up to $4, then again what if its a -c for close, or the window already exists, and after you managed all that, and coded for all possablities, oh no someone went and said !window.

A timer would be alot easier, and if its a sound to be heard, i would guess the windows gonna remain open, so a 1 seconds time would liekly be enough,
Posted By: Adrenalin Re: @window event - 10/01/04 07:50 PM
Code:
Alias Window {
  var %Window = $matchtok($1-, @, 1, 32)
  if (!$window(%Window)) echo -set Taram!
  window $1-
}


And why coder must use ! if the /window work exactly like normal(just not support the quietly mode).

The timers will take too much resource.. And why use timers if that can be do very easy with my alias..
Quote:
A timer would be alot easier

Can you show my you code.. I can't imagine..
Posted By: DaveC Re: @window event - 11/01/04 02:22 AM
on your revised code, try these....
/debug @blah1
(window created but no sound and/or message)

/window -c @blah2
(no window created but a sound and/or message)


On why a coder migth use !, basicly becuase they MIGHT, if this person was writting the code that opened the window they want a sound to play on opening, im sure they could just play the sound, so based from there request I would be quite sure that the code that opens the window(s) is not theres, I would beleive there attempting to play sounds to help notify them when a particular window from someone elses script opens.

Timers take stuff all resources, its not like Mircs going hard out now is it.
Why use timers when it can be done with your alias, basicly becuase your alias may or may not work depending on how the window was created.

I didnt have any code, so i wrote this just now, i test ran it and it seems to work ok, it might need more debugging but seemed ok, as an example, it deals with 3 windows it detects opening, giving a sound message for each if it detected an open, it also detects if the window was renamed to the window from another name, but wont detect a rename if the original window was closed at the same time (i do this to block windows being closed, using on close, i create a duplicate window, rename and let the old one close)
The code isnt optimized much as its just an example, also i wouldnt normally hard code 3 windows in, but rather use a hash table, but for the example i felt it was fine.
Code:
 
open.window.detector.startup {
  ;
  ; lets have 3 monitored windows, list the NAME STATUS(0=closed/1=open) SOUNDFILE
  set %owd.window.data.1 @blah1 ? DF.MP3
  set %owd.window.data.2 @debug ? DC.MP3
  set %owd.window.data.3 @xdccklipper ? DS.MP3
  ;
  ; correct there STATUS
  %owd.window.data.1 = $puttok(%owd.window.data.1,$iif(($window($gettok(%owd.window.data.1,1,32)) == $null),0,1),2,32)
  %owd.window.data.2 = $puttok(%owd.window.data.2,$iif(($window($gettok(%owd.window.data.2,1,32)) == $null),0,1),2,32)
  %owd.window.data.3 = $puttok(%owd.window.data.3,$iif(($window($gettok(%owd.window.data.3,1,32)) == $null),0,1),2,32)
  ;
  ; Start the monitoring timer
  .timer.open.window.detector -o 0 1 open.window.detector.timer
}
open.window.detector.timer {
  ;
  ; load w1,2,3 with window NAME & STATUS (used local vars as why do the gettoks in the if over and over %i times)
  var %w1 = $gettok(%owd.window.data.1,1-2,32)
  var %w2 = $gettok(%owd.window.data.2,1-2,32)
  var %w3 = $gettok(%owd.window.data.3,1-2,32)
  ;
  ; loop through all the windows open
  var %w
  var %i = $window(0)
  while (%i) {
    ;
    ; get CURRENTWINDOW
    %w = $window(%i)
    ;
    ; if CURRENTWINDOW 0(closed) NAME & STATUS of a monitored window (and that STATUS is closed) then Play the open sound, cause its now open.
    if (%w 0 == %w1) splay $gettok(%owd.window.data.1,3-,32)
    if (%w 0 == %w2) splay $gettok(%owd.window.data.2,3-,32)
    if (%w 0 == %w3) splay $gettok(%owd.window.data.3,3-,32)
    ;
    ; i cant rember why this is here <grin>
    dec %i
  }
  ;
  ; correct there STATUS (i thought about doing this in the If statments, it would reduce code per execution, but worried if there status could get outa sync with there real status)
  %owd.window.data.1 = $puttok(%owd.window.data.1,$iif(($window($gettok(%owd.window.data.1,1,32)) == $null),0,1),2,32)
  %owd.window.data.2 = $puttok(%owd.window.data.2,$iif(($window($gettok(%owd.window.data.2,1,32)) == $null),0,1),2,32)
  %owd.window.data.3 = $puttok(%owd.window.data.3,$iif(($window($gettok(%owd.window.data.3,1,32)) == $null),0,1),2,32)
}
 


(repeated below as inside code blocks it cant be copied ok)

open.window.detector.startup {
;
; lets have 3 monitored windows, list the NAME STATUS(0=closed/1=open) SOUNDFILE
set %owd.window.data.1 @blah1 ? DF.MP3
set %owd.window.data.2 @debug ? DC.MP3
set %owd.window.data.3 @xdccklipper ? DS.MP3
;
; correct there STATUS
%owd.window.data.1 = $puttok(%owd.window.data.1,$iif(($window($gettok(%owd.window.data.1,1,32)) == $null),0,1),2,32)
%owd.window.data.2 = $puttok(%owd.window.data.2,$iif(($window($gettok(%owd.window.data.2,1,32)) == $null),0,1),2,32)
%owd.window.data.3 = $puttok(%owd.window.data.3,$iif(($window($gettok(%owd.window.data.3,1,32)) == $null),0,1),2,32)
;
; Start the monitoring timer
.timer.open.window.detector -o 0 1 open.window.detector.timer
}
open.window.detector.timer {
;
; load w1,2,3 with window NAME & STATUS (used local vars as why do the gettoks in the if over and over %i times)
var %w1 = $gettok(%owd.window.data.1,1-2,32)
var %w2 = $gettok(%owd.window.data.2,1-2,32)
var %w3 = $gettok(%owd.window.data.3,1-2,32)
;
; loop through all the windows open
var %w
var %i = $window(0)
while (%i) {
;
; get CURRENTWINDOW
%w = $window(%i)
;
; if CURRENTWINDOW 0(closed) NAME & STATUS of a monitored window (and that STATUS is closed) then Play the open sound, cause its now open.
if (%w 0 == %w1) splay $gettok(%owd.window.data.1,3-,32)
if (%w 0 == %w2) splay $gettok(%owd.window.data.2,3-,32)
if (%w 0 == %w3) splay $gettok(%owd.window.data.3,3-,32)
;
; i cant rember why this is here <grin>
dec %i
}
;
; correct there STATUS (i thought about doing this in the If statments, it would reduce code per execution, but worried if there status could get outa sync with there real status)
%owd.window.data.1 = $puttok(%owd.window.data.1,$iif(($window($gettok(%owd.window.data.1,1,32)) == $null),0,1),2,32)
%owd.window.data.2 = $puttok(%owd.window.data.2,$iif(($window($gettok(%owd.window.data.2,1,32)) == $null),0,1),2,32)
%owd.window.data.3 = $puttok(%owd.window.data.3,$iif(($window($gettok(%owd.window.data.3,1,32)) == $null),0,1),2,32)
}

PS : the timer just goes off once a second, as i felt that was a fine rate of scanning, considering its a sound your playing to allert someone whoes then gonna take 10 seconds to get there anyway.
Posted By: Adrenalin Re: @window event - 11/01/04 04:15 PM
Quote:

/window -c @blah2

Why coder must use /window -c @blah2 if custom-window @blah2 don't exist ? If that is so big problem.. The if(-*c* iswm $1) will solve the problem..

Quote:

/debug @blah1

Forget about debug, but that alias will also help the coder wink

Code:
Alias Debug {
  var %Window = $matchtok($1-, @, 1, 32)
  if (!$window(%Window)) echo -set Taram!
  debug $1-
}


You code is a solution.. But imo my solution is better.. And faster..
Posted By: DaveC Re: @window event - 11/01/04 11:21 PM
I do "/window -c @blah" all the time, the command does not error when the window is not present, and it allows me to set new parameters for the window in the next /window

Well if u cover for all posabilities then ill give you that your alias well work and now your having to monitor debug as well, but you again still cant catch !window or !debug, and i have answered why the coder may do this, basicly becuase the person wanting to intercept the open window event isnt the coder, but someone else. The original request was for how to code for an event, well if there is no "on event" & u cant trap all of the occurances of the event with an alias, your down to only one thing that I know a timer to monitor the situation, and report back or take action as needed.

My solution is by no means fool proof, its only checking once a second, if i wanted to take actions beyond just playing a sound, i would have to monitor a lot closer than that, and even then, a whole script well be run before my timer gets another chance to have a look at whats happened, and as well all know, a script can run for a long long time.
© mIRC Discussion Forums