mIRC Home    About    Download    Register    News    Help

Print Thread
make scripts work for specific windows #169362 22/01/07 02:00 AM
Joined: Feb 2006
Posts: 307
N
nataliad Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
hello

I have a script that hides specific windows and a script that will navigate to the next (right) or previous (left) window, using keyboard shortcuts

can you tell me how can I make it navigate through the visible windows, and not through all the windows?

thanks

here is the script that hides specific windows:

Code:
alias F8 {
  scon -a toggletabs %hidden
  if (%hidden == $null) set %hidden 1
  else unset %hidden
}
alias -l toggletabs {
  set %x window $iif($0,-w,-h)
  set %y 1
  %x "Status Window"
  while $chan(%y) {
    if $istok(#channel1 #channel2,$chan(%y),32) {
      %x $chan(%y)
    }
    inc %y
  }
}

here are two scipts that do the same job, they navigate through the windows that exist (either visible or not) using F2,F3 keys

I 'd be grateful to comment on which is better

Code:
alias F2 shift -1
alias F3 shift 1
alias shift {
  ; 1: <1=left 0=same >1=right
  ;
  var %wname, %wlist, %wtype, %ccid = $cid, %cwin = $active
  var %a = 0, %aa = $scon(0), %c = 0, %cc = 0, %n = 0, %nwin = 0
  while (%a < %aa) {
    inc %a
    scon %a
    %c = 0
    %cc = $window(*,0)
    while (%c < %cc) {
      inc %c
      %wtype = $window(*,%c).type
      if ($istok(chat custom fserv get send,%wtype,32)) continue
      ;if ($istok(channel status chat custom fserv get send,%wtype,32)) continue
      %wname = $window(*,%c)
      inc %n
      if ((%ccid == $cid) && (%cwin == %wname)) %nwin = %n
      %wlist = $addtok(%wlist,$+($cid,.,%wname),44)
    }
    scon -r
  }
  ;
  if (%nwin == 0) {
    %nwin = $findtok(%wlist,$wildtok(%wlist,$+($cid,.*),1,44),1,44)
    %nwin = $calc(%nwin + $wildtok(%wlist,$+($cid,.*),0,44))
    if ($1 > 0) dec %nwin
  }
  if ($1 < 0) {
    dec %nwin
    if (%nwin == 0) dec %nwin
  }
  elseif ($1 > 0) {
    inc %nwin
    if (%nwin == 0) inc %nwin
  }
  %nwin = $calc(((%nwin - 1) % $numtok(%wlist,44)) + 1)
  %nwin = $gettok(%wlist,%nwin,44)
  if (%nwin != $null) scid $gettok(%nwin,1,46) window -a $+(",$gettok(%nwin,2,46),")
}

or
Code:
alias F3 { 
  var %i = 1 
  while ($window(*,%i)) { 
    if ($window(*,%i) == $active) { 
      inc %i 
      if (!$window(*,%i)) { 
        var %o = 1 
        while ($scon(%o)) { 
          if ($scon(%o) == $cid) { inc %o | if ($scon(%o)) { scon %o window -a "Status Window" | scon %o } | else { scon 1 | window -a "Status Window" } } 
          inc %o 
        } 
      } 
      else { window -a $+(",$window(*,%i),") } 
      break 
    } 
    inc %i 
  } 
} 

alias F2 { 
  var %i = $window(*,0) 
  while ($window(*,%i) !isnum) { 
    if ($window(*,%i) == $active) { 
      dec %i 
      if ($window(*,%i) isnum) { 
        var %o = $scon(0) 
        while ($scon(%o)) { 
          if ($scon(%o) == $cid) { dec %o | if ($scon(%o) != $scon(0)) { scon %o | window -a $window(*,$window(*,0)) } | else { scon $scon(0) | window -a "Status Window" } } 
          dec %o 
        } 
      } 
      else { window -a $+(",$window(*,%i),") } 
      break 
    } 
    dec %i 
  } 
}

Last edited by nataliad; 22/01/07 02:07 AM.
Re: make scripts work for specific windows [Re: nataliad] #169386 22/01/07 02:16 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
To avoid rotating through hidden windows, just check:

$window(%window.variable).state

If it == hidden, then increment your %window.variable instead of activating the window. From a quick scan of your script, I'm guessing that is %nwin, but I didn't really look that closely.


Invision Support
#Invision on irc.irchighway.net
Re: make scripts work for specific windows [Re: Riamus2] #169417 22/01/07 10:53 PM
Joined: Feb 2006
Posts: 307
N
nataliad Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Feb 2006
Posts: 307
ummm can you tell me how the script should be? whats better from the two last scripts?

Re: make scripts work for specific windows [Re: nataliad] #169420 22/01/07 11:07 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I do very little with /scon, so I'll leave that to someone else to decide which is best.


Invision Support
#Invision on irc.irchighway.net
Re: make scripts work for specific windows [Re: nataliad] #169426 23/01/07 12:39 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Ok, Im pretty tired so I'm not really looking at the code you provided sorry. So you have multiple $cid's and you want to scroll through the windows but not the hidden ones.

basically: if ($window(%inc).state == hidden) inc %inc

EDIT:LOL I'm too beat to getit right. As Riamus said ^^^

When you go to /window -a $window, check and make sure its .state != hidden first. If it does inc or dec the variable to skip it.

Last edited by DJ_Sol; 23/01/07 01:28 AM.
Re: make scripts work for specific windows [Re: nataliad] #169442 23/01/07 03:23 AM
Joined: Oct 2005
Posts: 1,741
G
genius_at_work Offline
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
To the first shift code, under this line:

if ($istok(chat custom fserv get send,%wtype,32)) continue

add this line:

if ($window(*,%c).state == hidden) continue

*(Untested)

-genius_at_work