mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#229296 - 29/01/11 06:44 AM Status window open/close
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
Is there any way to know when a status window is opened/closed?

on disconnect is a decent substitute for when closing but i have to add a timer since the window is open after it disconnects.

on connect isn't a good substitute for when opening a status window since it doesn't connect instantly and can be opened without trying to connect to anything.
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#229297 - 29/01/11 07:36 AM Re: Status window open/close [Re: pball]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Originally Posted By: pball
Is there any way to know when a status window is opened?
You can try something like the code below and place it in mIRC's perform dialog:
Code:
window -a $qt(status window) | echo -a * Status Window's been opened!
As to status window being closed, I'm clueless.

Top
#229299 - 29/01/11 08:46 AM Re: Status window open/close [Re: pball]
jaytea Offline
Fjord artisan

Registered: 23/02/06
Posts: 546
an event for all cases: no. but for most cases you can count on an ACTIVE event triggering:

Code:
on *:active:*:{
  if (!$cid($lactivecid)) {
    ; connection ID $lactivecid was just closed
  }
  ; check if $cid has been saved before, then save it etc. to detect a new window
}


unfortunately this doesn't detect things like windows opened via /server -z, or closed when all other windows are minimized, etc.

you should always try to tie in the actions with your /close, /window and /server commands wherever possible. in general, and as ugly as it sounds, a timer is your only failsafe option. using a delay as high as possible (consider if you need to detect open/close very quickly, if you can afford to be imprecise) and checking for changes in $scon(0) should be relatively low impact.
_________________________
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Top
#229300 - 29/01/11 09:27 AM Re: Status window open/close [Re: jaytea]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
jaytea, it should've been $scid() :
Quote:
if (!$scid($lactivecid)) {

Top
#229302 - 29/01/11 09:38 AM Re: Status window open/close [Re: Tomao]
jaytea Offline
Fjord artisan

Registered: 23/02/06
Posts: 546
quite right, thanks!
_________________________
"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde

Top
#229314 - 29/01/11 04:27 PM Re: Status window open/close [Re: jaytea]
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
It seems we just need on open/close to work with all windows. It makes no sense why they don't.

I'm not gonna bother "hacking" a lot to do this. Like monitor /server and other commands. Doing all of that would probably double the size of my script.

If anyone cares I want this for a script that lets you hide/unhide windows from the switchbar. I hide some @windows and status windows for nets I don't really care about.

I made a nice right click menu which has nice dynamic submenus.
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#229321 - 29/01/11 06:19 PM Re: Status window open/close [Re: pball]
Tomao Offline
Hoopy frood

Registered: 07/07/07
Posts: 1129
Loc: United States
Originally Posted By: pball
It seems we just need on open/close to work with all windows. It makes no sense why they don't.
Not sure if this has been suggested before, but it won't hurt if you post that under the feature suggestions.

* Edit - I just saw you did just that.

Top
#229325 - 29/01/11 09:42 PM Re: Status window open/close [Re: pball]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
For possible solutions, I'd want to know why you want to know if status window has been opened or closed. You can always check for the "status window" on your $scid or $scon.

Top
#229328 - 29/01/11 11:01 PM Re: Status window open/close [Re: DJ_Sol]
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
Well I said what the script is in my last post, a script to hide windows from the switchbar. But the technical reason I'd like to know when a status window is open/closed is because I have to update the right click menu. So when a new status window is opened I need to update and add that window to the right click options.

If anyone wants to say use $submenu() and $scon() to make a dynamic submenu. That won't work since I need the right click menus to be 3 deep, which I already have working. I just have to run an update to add/remove status windows from the popup..

Code:
Ex. right click option
Hide Windows
-@windows
--@Spam
--@Highlight
-Rizon
--Rizon (Status Window)
--Chans
---#help.script
---#hmm?
--DCC Chats
--Queries
-2nd Network
etc...
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#229377 - 01/02/11 04:36 PM Re: Status window open/close [Re: pball]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
When I did what you want to do I used popups.dll. This allowed me to put loops in my menu to scan through the different scons. Other than that I can't think of how you would dynamically list all connections and have 3+ deep nested menus.

Oh, picwin menus. Seems like a lot of work though.

With popups.dll:

Code:
;I wrote this 4 or 5 years ago.
;Change paths to your dll.
;$hget(soulfly,$chan(%ch_i)) is the channel name cleaned up.
;these are all aliases. Load to alias section or add the word alias to each one.
;Window List
chann {
  echo -a chan 1= $1 2= $2
  var %a = $active, %m = $mnick
  mdx_pop New ch 16 16
  mdx_pop SetStyle ch bordericon bordertext
  mdx_pop LoadImg ch icon small $mdx_icon(1x)
  mdx_pop LoadImg ch icon small $mdx_icon(o)
  mdx_pop LoadImg ch icon small $mdx_icon(q)
  mdx_pop LoadImg ch icon small $mdx_icon(w)
  mdx_pop LoadImg ch icon small $mdx_icon(refresh)
  mdx_pop AddItem ch end +D,d 1 $str($chr(160),6) Windows List
  mdx_pop AddItem ch end
  var %sc = $scon(0), %sc_i = 1
  while (%sc_i <= %sc) {
    scon %sc_i | var %sx = $scon(%sc_i), %sn = $scon(%sc_i).mnick
    mdx_pop AddItem ch end 1 $chr(160) Status $str($chr(160),3) ( %sn ) $cr sta_sc %sx
    $iif(!$chan(1),mdx_pop AddItem ch end)
    var %ch = $chan(0), %ch_i = 1 | while (%ch_i <= %ch) {
      mdx_pop AddItem ch end +D $iif(%a == $chan(%ch_i),5,2) $iif(%a == $chan(%ch_i),5,1) $str($chr(160),5) -> $hget(soulfly,$chan(%ch_i)) $cr sta_sc %sx $chan(%ch_i)
      inc %ch_i | if (%ch_i > %ch) mdx_pop AddItem ch end
    }
    var %q = $query(0), %q_i = 1
    $iif(%q != 0,mdx_pop AddItem ch end $+(+D,$chr(44),d) 3 $str($chr(160),5) Whispers)
    while (%q_i <= %q) {
      var %qn = $query(%q_i)
      mdx_pop AddItem ch end $iif($1 == %qn,1,2) 1 $str($chr(160),11) %qn $cr sta_sc %sx %qn
      inc %q_i | if (%q_i > %q) mdx_pop AddItem ch end
    }
    inc %sc_i
  }
  var %w = $window(0), %w_i = 1
  $iif(%w > 1,mdx_pop AddItem ch end $+(+D,$chr(44),d) 4 Windows)
  while (%w_i <= %w) {
    var %wn = $window(%w_i)
    $iif(%wn != @uwho,mdx_pop AddItem ch end $iif($1 == %wn,1,2) 1 $str($chr(160),7) $+($chr(40),-,$chr(41)) $str($chr(160),3) $remove(%wn,@) $cr window -a %wn)
    inc %w_i
  }
  pop1 ch $mouse.dx $mouse.dy
}
sta_sc {
  scid $1
  if ($2) window -a $2
  else window -a "Status Window"
}
;popup
mdx_pop {
if ($isid) return soulfly\dll\popups.dll
else dll soulfly\dll\popups.dll $1-
}
pop1 {
tokenize 32 $dll(soulfly\dll\popups.dll,Popup,$1-)
if ($isid) return $1-
$iif($4- != did not select a menu item,$4-)
}


Top
#229378 - 01/02/11 08:28 PM Re: Status window open/close [Re: pball]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Code:
alias rebuildmenu {
  var %popupfile = $qt($scriptdir $+ popups.mrc)
  .fopen -o popups %popupfile
  if ($ferr) { return }
  var %ai = 1, %v1, %n = 1
  while ($isalias(___visible $+ %ai)) {
    .alias ___visible $+ %ai
    inc %i
  }
  .fwrite -n popups menu status $chr(123)
  if ($window(@*,0)) {
    .fwrite -n popups @Windows
    var %@i = 1
    while ($window(@*,%@i)) {
      %v1 = $v1
      .alias ___visible $+ %n $chr(123) return $!iif(!$window( %v1 ).tbstate || !$window( %v1 ).sbstate,0,1) $chr(125)
      .fwrite -n popups $+(.,$!iif(!$___visible $+ %n $chr(44) Show $chr(44) Hide) %v1,: $chr(123) window $!iif(!$___visible $+ %n $chr(44) -w3 $chr(44) -w0) $v1 $chr(125))
      inc %@i
      inc %n
    } 
  }
  if ($chat(0)) { 
    .fwrite -n popups .DCC Chats 
    var %chi = 1
    while ($chat(%chi)) {
      %v1 = $v1
      .alias ___visible $+ %n $chr(123) return $!iif(!$window( = $+ %v1 ).tbstate || !$window( = $+ %v1 ).sbstate,0,1) $chr(125)
      .fwrite -n popups $+(..,$!iif(!$___visible $+ %n $chr(44) Show $chr(44) Hide) %v1,:,$chr(123) scon %ni $chr(124) window $!iif(!$___visible $+ %n $chr(44) -w3 $chr(44) -w0) = $+ %v1 $chr(125))
      inc %chi
      inc %n
    }
  }
  var %ni = 1
  while ($scon(%ni)) {
    scon %ni
    .alias ___visible $+ %n $chr(123) scon %ni $chr(124) return $!iif(!$window(status window).tbstate || !$window(status window).sbstate,0,1) $chr(125)
    .fwrite -n popups $scon(%ni).network
    .fwrite -n popups $+(.,$!iif(!$___visible $+ %n $chr(44) Show $chr(44) Hide) $scon(%ni).network (Status Window):,$chr(123) scon %ni $chr(124) window $!iif(!$___visible $+ %n $chr(44) -w3 $chr(44) -w0) "status window" $chr(125))
    inc %n
    if ($chan(0)) {
      .fwrite -n popups .Channels
      var %ci = 1
      while ($chan(%ci)) {
        %v1 = $v1
        .alias ___visible $+ %n $chr(123) scon %ni $chr(124) return $!iif(!$window( %v1 ).tbstate || !$window( %v1 ).sbstate,0,1) $chr(125)
        .fwrite -n popups $+(..,$!iif(!$___visible $+ %n $chr(44) Show $chr(44) Hide) %v1,:,$chr(123) scon %ni $chr(124) window $!iif(!$___visible $+ %n $chr(44) -w3 $chr(44) -w0) %v1 $chr(125))
        inc %ci
        inc %n
      }
    }
    if ($query(0)) {
      %v1 = $v1
      .fwrite -n popups .Queries
      var %qi = 1
      while ($query(%qi)) {
        %v1 = $v1
        .alias ___visible $+ %n $chr(123) scon %ni $chr(124) return $!iif(!$window( %v1 ).tbstate || !$window( %v1 ).sbstate,0,1) $chr(125)
        .fwrite -n popups $+(..,$!iif(!$___visible $+ %n $chr(44) Show $chr(44) Hide) %v1,:,$chr(123) scon %ni $chr(124) window $!iif(!$___visible $+ %n $chr(44) -w3 $chr(44) -w0) %v1 $chr(125))
        inc %qi
        inc %n
      }
    }
    inc %ni
  }
  .fwrite -n popups $chr(125)
  .fclose popups
  .reload -rs %popupfile
}

on *:join:#:{
  if ($nick == $me) { rebuildmenu }
}
on *:part:#:{
  if ($nick == $me) { rebuildmenu }
}
on *:kick:#:{
  if ($knick == $me) { rebuildmenu }
}
on *:quit:{
  if ($nick == $me) { rebuildmenu }
}
on *:connect:{ rebuildmenu }
on *:disconnect:{ rebuildmenu }
on *:open:?:{ rebuildmenu }
on *:close:*:{ rebuildmenu }


Kinda messy but it works and it's fast.

I seriously doubt you'll have any aliases called ___visible<N>, but this script will delete and manage all aliases by that name.

Enjoy smile

Top
#229382 - 02/02/11 03:49 AM Re: Status window open/close [Re: hixxy]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
haha I didn't think of doing it that way.

I've written code to file before like that using /write and making sure to /load when I was finished. I'm sure using fopen is much better. lol

Top
#229383 - 02/02/11 04:41 AM Re: Status window open/close [Re: DJ_Sol]
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
@DJ_Sol
I'd rather stay away from dlls

@hixxy
I already have a working script. I personally feel it's better also since all chans, queries, dcc chats, and @windows are all dynamic. Meaning the popups file I make and load only has to be updated and reloaded when a network is open/closed. So checking when a status window is opened/closed is why I made this thread.
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#229385 - 02/02/11 03:42 PM Re: Status window open/close [Re: pball]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
Just a quick glance at hixxy's script. It appears that it dynamically creates a menu for you. Which means that when something happens it will write the code for a menu that includes your status window and will allow you to nest the menu as deep as you like.

If you don't like dll's I can't think of any other solution other than this or possibly working with picwin menus. Good luck!

Top
#229392 - 02/02/11 07:54 PM Re: Status window open/close [Re: pball]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Yeah that was a pretty hideous way of doing it, I don't know what I was thinking!

Here's a much shorter and more functional way:

Code:
alias server {
  server $1-
  rebuildmenu
}
alias vis { 
  scon $1
  return $iif(!$window(status window).sbstate || !$window(status window).tbstate,0,1)
}
alias mnu { 
  if ($istok(begin end,$1,32)) { return - }
  if ($3 isnum) { scon $3 }
  if ($($+($,$2,$chr(40),$1,$chr(41)),2)) { 
    return $iif($window($iif($2 == chat,=) $+ $($+($,$2,$chr(40),$1,$chr(41)),2)).sbstate || $window($iif($2 == chat,=) $+ $&
      $($+($,$2,$chr(40),$1,$chr(41)),2)).tbstate,Hide,Show) $($+($,$2,$chr(40),$1,$chr(41)),2) : window $iif($window($iif($2 == chat,=) $+ $&
      $($+($,$2,$chr(40),$1,$chr(41)),2)).sbstate || $window($iif($2 == chat,=) $+ $($+($,$2,$chr(40),$1,$chr(41)),2)).tbstate,-w0,-w3) $iif($2 == chat,=) $+ $($+($,$2,$chr(40),$1,$chr(41)),2) 
  }
}
alias mnuwindows {
  if ($istok(begin end,$1,32)) { return - }
  if ($window(@*,$1)) return $iif($window(@*,$1).sbstate || $window(@*,$1).tbstate,Hide,Show) $window(@*,$1) : window $iif($window(@*,$1).sbstate || $window(@*,$1).tbstate,-w0,-w3) $window(@*,$1)
}
alias rebuildmenu {
  var %popupfile = $qt($scriptdir $+ popups.mrc)
  .fopen -o popups %popupfile
  if ($ferr) { return }
  .fwrite -n popups menu status $chr(123)
  var %i = 1
  while ($scon(%i)) {
    scon %i
    .fwrite -n popups $scon(%i).network
    .fwrite -n popups .$iif($vis( %i ),Hide,Show) $scon(%i).network (Status Window) : window $!iif($vis( %i ),-w0,-w3) "status window"
    .fwrite -n popups .$iif($chan(0),Channels)
    .fwrite -n popups ..$submenu($mnu($1,chan, %i ))
    .fwrite -n popups .$iif($query(0),Queries)
    .fwrite -n popups ..$submenu($mnu($1,query, %i ))
    inc %i
  }
  .fwrite -n popups $!iif($chat(0),DCC Chats)
  .fwrite -n popups .$submenu($mnu($1,chat))
  .fwrite -n popups $!iif($window(@*,0),@windows)
  .fwrite -n popups .$submenu($mnuwindows($1))
  .fwrite -n popups $chr(125)
  .fclose popups
  .reload -rs %popupfile
}

on *:active:*:{
  if (!$istok(%popup_cids,$cid,32)) { 
    rebuildmenu
    set %popup_cids $addtok(%popup_cids,$cid,32) 
  }
  elseif (!$scid($lactivecid)) {
    rebuildmenu
    if ($remtok(%popup_cids,$lactivecid,1,32)) { set %popup_cids $v1 }
    else { unset %popup_cids }
  }
}


Seems to work perfectly! Let me know if there's anything it doesn't catch.

Top
#229406 - 03/02/11 05:55 AM Re: Status window open/close [Re: hixxy]
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
I really appreciate that you are trying to help but you are not addressing the issue this thread was made for. I have a working script with multi level deep dynamic right click menus already.

Can we please get back on topic. I simply want to know when a status window is opened/closed without doing anything too round about.
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#229409 - 03/02/11 10:35 AM Re: Status window open/close [Re: pball]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
The event at the bottom does just that..

Code:
on *:active:*:{
  if (!$istok(%popup_cids,$cid,32)) { 
    rebuildmenu
    set %popup_cids $addtok(%popup_cids,$cid,32) 
    ; Status window opening.
  }
  elseif (!$scid($lactivecid)) {
    rebuildmenu
    if ($remtok(%popup_cids,$lactivecid,1,32)) { set %popup_cids $v1 }
    else { unset %popup_cids }
    ; Status window closing.
  }
}


The only thing it doesn't address is things like /server -z, which opens a new server window but doesn't activate it, which is why I aliased the /server command at the top.

I wouldn't say any of that is "too round about" and it does what you ask for, no?

Top
#229426 - 04/02/11 12:44 AM Re: Status window open/close [Re: hixxy]
pball Offline
Fjord artisan

Registered: 04/11/09
Posts: 295
Well it improves on what I have currently but I found a bit of bug somewhere. When I'm in a debugging mood I'll play with it more and see what the cause is.
_________________________
http://scripting.pball.win
My personal site with some scripts I've released.

Top
#229428 - 04/02/11 05:18 AM Re: Status window open/close [Re: pball]
DJ_Sol Offline
Hoopy frood

Registered: 04/01/07
Posts: 1156
Loc: Seattle
Originally Posted By: pball
Can we please get back on topic. I simply want to know when a status window is opened/closed without doing anything too round about.


Oh, well in that case. No, you are out of luck. Or you can try Hixxy's idea.


Edited by Khaled (04/02/11 07:33 AM)

Top
#229429 - 04/02/11 12:16 PM Re: Status window open/close [Re: pball]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
If you're using my code, to keep the menu up to date it should rebuild the menu on start, easy fix:

Code:
on *:start:{ rebuildmenu }


If you're using your own, I don't know :P

Top
Page 1 of 2 1 2 >