mIRC Homepage

navigate through visible switchbar buttons

Posted By: nataliad

navigate through visible switchbar buttons - 14/10/07 01:23 PM

hello

I have this script that hides specific switchbar buttons:

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(#hellas #jokes-gr #greece #mad #pathfinder,$chan(%y),32) {
      %x $chan(%y)
    }
    inc %y
  }
}


I have this script that navigates using keyboard keys across switchbar buttons:

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(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) %nwin = $numtok(%wlist,44)
  }
  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),")
}


how can I make mirc to navigate only the visible (with the second script) switchbar buttons?

thanks
Posted By: nataliad

Re: navigate through visible switchbar buttons - 18/10/07 02:14 AM

confused
Posted By: genius_at_work

Re: navigate through visible switchbar buttons - 18/10/07 03:08 AM

We've been through this before. You have the script set to ignore ALL window types, therefore it will never shift to any windows. If you want it to shift only to channels that are visible, try this script:

Code:
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(status chat custom fserv get send,%wtype,32)) continue
      if ($window(*,%c).state == hidden) 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) %nwin = $numtok(%wlist,44)
  }
  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),")
}



Note that if you view one of the hidden channels (by using the window menubar item) it will be considered unhidden by the script. To resume ignoring that window, you need to rehide it.

-genius_at_work
Posted By: nataliad

Re: navigate through visible switchbar buttons - 18/10/07 10:35 PM

Originally Posted By: genius_at_work
We've been through this before. You have the script set to ignore ALL window types, therefore it will never shift to any windows. If you want it to shift only to channels that are visible, try this script:

Code:
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(status chat custom fserv get send,%wtype,32)) continue
      if ($window(*,%c).state == hidden) 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) %nwin = $numtok(%wlist,44)
  }
  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),")
}



Note that if you view one of the hidden channels (by using the window menubar item) it will be considered unhidden by the script. To resume ignoring that window, you need to rehide it.

-genius_at_work


this script works alone or I need any of the above scripts?
Posted By: genius_at_work

Re: navigate through visible switchbar buttons - 19/10/07 12:50 AM

The alias I gave you replaces the only that alias in the script you provided. Leave the other aliases unchanged.

-genius_at_work
Posted By: nataliad

Re: navigate through visible switchbar buttons - 19/10/07 06:01 PM

thanks it works very well

I also have this alias:

Code:
F1 /close -m $active | /F3


it closes the current query and then presses F3

but now F3 goes to channel visible windows, so can I make it go to the next query only and not channel or other window? and if there is no other query window, it should go to the next channel window

thanks
Posted By: genius_at_work

Re: navigate through visible switchbar buttons - 20/10/07 02:21 AM

You would have to duplicate the /shift alias as /shift2 and alter it to do what you want.

Alternatively, you could do something like this:

Code:

F1 {
close -m $active
if ($query(0) <= 0) window -a $+(",$query(1),")
else shift 1
}



This code will go to the FIRST query if one exists, else it will scroll to a channel window.

-genius_at_work
Posted By: nataliad

Re: navigate through visible switchbar buttons - 22/10/07 01:06 AM

thanks

but when I click F1 while at a channel window I get this:

* /window: invalid parameters (line 925, script.ini)

I suppose its normal (since I only want F1 to work while on query), but can I prevent this from appearing?

EDIT: it doesnt work well, when I click F1, it closes the current query and it moves to the next visible channel window, while other queries exist (it should go to one of these queries and only if there are no queries, it should go to the channel)
Posted By: deegee

Re: navigate through visible switchbar buttons - 22/10/07 04:18 AM

Try this
Code:
F1 {
  if (!$query($active)) { return }
  var %i = 1 | while ($query(%i) != $active) { inc %i }
  close -m $active
  if ($query(%i) || $query(1)) { window -a $v1 }
  else shift 1
}

Posted By: nataliad

Re: navigate through visible switchbar buttons - 22/10/07 06:45 AM

thanks it works very well

can you also make it to go to a query when I hit F1 while on channel?
Posted By: deegee

Re: navigate through visible switchbar buttons - 23/10/07 08:37 AM

Code:
F1 {
  if ($me ison $active) {
    if $query(1) { window -a $v1 }
    return
  }
  if (!$query($active)) { return }
  var %i = 1 | while ($query(%i) != $active) { inc %i }
  close -m $active
  if ($query(%i) || $query(1)) { window -a $v1 }
  else shift 1
}
Posted By: nataliad

Re: navigate through visible switchbar buttons - 23/10/07 08:49 PM

umm, it doesnt work frown

specificaly, it doesnt go to any query if I click F1 while on channel window (even if queries exist)

however, the part that it closes the currect query and goes to another query works well
Posted By: deegee

Re: navigate through visible switchbar buttons - 25/10/07 01:22 AM

Seems to work fine for me...:shrugs:
Posted By: nataliad

Re: navigate through visible switchbar buttons - 27/10/07 11:58 PM

mm

when you click F1 while on a channel, you are moved to a query?

even if the query has never been opened before? it seems to only go to the query only if it has been previously activated/focused

EDIT:it doesnt seem to work regardless the query have been activated or not
© 2021 mIRC Discussion Forums