jaytea's Highlight Thing

By jaytea on Mar 15, 2011

This highlight thing adds extra features and functionality to mIRC's own highlight system. You need to add entries to mIRC's system for it to work, so check out:

/help Highlight

if you are not already familiar with it.

Compatibility: this script now works on versions earlier than 7.1.


  jaytea's Highlight Thing

  Builds upon mIRC's own highlight system by providing a window
  to display all highlights and easily view them in context.

  Activate the script by using the channel or status window popup,
  or use the command /hl_start anywhere.

  Once activated, all highlights will be added to a window named
  @Highlights visible at the end of your switchbar or treebar.
  You may single click on any of those lines to activate the 
  window and automatically scroll back to the original message.

  If the message no longer exists in the source window buffer then
  it will not be clickable in @Highlights.


; Change the return value to reflect the colour you would
; like moused over lines to switch to in @Highlights.
alias -l highlightCol return 4

menu @Highlights {
    close -@ @Highlights

menu channel,status {
  jaytea's Highlight Thing:{

alias -l tab return $chr(9)
alias -l ellipsis {
  return $iif($version < 7, $&
    $utfdecode($+($chr(226), $chr(128), $chr(166))), $&

on *:text:*:*:{
  hl_checkHL $cid $iif(#, #, $nick) $1-

on *:action:*:*:{
  hl_checkHL $cid $iif(#, #, $nick) $1-

on *:close:@Highlights:{
  if ($hget(hl)) hfree hl

on *:input:@Highlights:{
  if ($1 == /clear) {

alias hl_checkHL {
  if ($3- isnum) || (!$window(@Highlights)) || (!$highlight($3-)) halt
  hl_addLine $1-

alias hl_start {
  if ($window(@Highlights)) window -c @Highlights

  window -ezin -t2,18,40  @Highlights

  echo -egac info2 * jaytea's Highlight Thing started. See documentation for information.

alias hl_init {
  if ($hget(hl)) hfree hl
  hmake hl
  clear @Highlights
  echo @Highlights $+($tab, $chr(31), Network, $tab, Window, $tab, Message)
  echo @Highlights $tab

on ^*:hotlink:*:@Highlights:{
  var %l = $gettok($hotlinepos, 2, 32)
  if (!$hget(hl, %l)) halt
  if ($mouse.key & 1) {
    hl_switchTo %l
  if ($hget(hl, hlp) != $hotlinepos) { 
    hadd hl hlp $v2
    if ($hget(hl, ln) != %l) {
      hl_unHL $v1
      if (!$hl_hlLine(%l)) halt 
    if ($mid($1, -1) == $ellipsis) && ($int($hotlinepos) < 3) {
      editbox @Highlights $gettok($hget(hl, %l), $calc(1 + $v1), 32)
  elseif ($timer(hl)) hl_timer
  else halt

; /hl_addLine <cid> <window> <message>

alias hl_addLine {
  scid $1
  var %ln = $line($2, 0), %col = $mid(0 $+ $line($2, %ln).color, -2), $&
    %net = $network, %name = $2, %l = $line($2, %ln)

  hadd hl $calc(1 + $line(@Highlights, 0)) $1 %net $2 %l
  echo -i41 @Highlights $+($tab, $&
    $left(%net, 12), $iif($len(%net) > 12, $ellipsis), $tab, $&
    $left(%name, 18), $iif($len(%name) > 18, $ellipsis), $tab, $&  
    %l) | ; %col could be incorporated here, though it looks slightly worse.
  echo @Highlights $tab
  scid -r

alias hl_switchTo {
  tokenize 32 $hget(hl, $1)
  if ($hl_findLine($1, $3, $4-)) {
    scid $1
    window -a $3
    findtext $4-
    scid -r

alias hl_unHL {
  if ($1) || ($hget(hl, ln)) {
    rline $color(normal) @Highlights $v1 $line(@Highlights, $v1)

alias hl_clear {
  hdel hl ln
  hdel hl hlp
  editbox @Highlights

alias hl_hlLine {
  tokenize 32 $1 $hget(hl, $1)
  hadd hl ln $1
  if ($hl_findLine($2, $4, $5-)) {
    rline $highlightCol @Highlights $1 $line(@Highlights, $1)
    return $true

alias hl_findLine {
  scid $1
  return $fline($2, $replace($3, *, ?), 1)
  scid -r

alias hl_timer {
  hadd hl mp $mouse.x $mouse.y
  .timerhl -m 0 50 if ($mouse.x $!mouse.y == $!hget(hl, mp)) return $(|) $&
    hl_clear $(|) .timerhl off


Sign in to comment.
KindOne   -  Aug 13, 2013

Seems to not work (the clicking part in the highlight tab) when your nick is at the end.
/me test $nick
/msg #channel lol $nick
Edit: nevermind, I was wrong, has to deal with a space at the end.

Yawhatnever   -  May 14, 2012

I ended up replacing all extra spaces while storing the line with this:

%re = /( $+ $chr(32) $chr(124) $!)/g
hadd <stuff> $regex($line($2,%l),%re) $regsubex($line($2,%l),%re,$str($chr(160),$len(\t))

and then for hotlinks I used:


and then to find the text in the window I either used /findtext if no extra spaces had been replaced, or used a com if they had:

    if (!$3) findtext $5-
    else { .comopen a WScript.Shell | .comclose a $com(a,SendKeys,3,bstr,^f $+ $regsubex($replace($5-,$chr(160),$chr(32)),/([\Q+^%~(){}[]\E])/Sg,$+($chr(123),\t,$chr(125))) $+ {enter}{esc}) } 

It will still break if somebody actually sends a message with $chr(160)... but I'll take my chances on that one :P

I modified a number of other things to fit my own preferences, but I really couldn't find anything to improve.

jaytea   -  May 14, 2012

hi! wow, thanks for investigating that :P

yeah it seems as though i entirely overlooked the prospect of excess spaces... or simply didn't want to handle them.... can't really remember. i've been battling with the 'excess spaces' problem in mIRC for as long as i can remember, and as much as i hate to leave the script in such a defeated state, the solution would require more time than i can afford to commit right now. i do have an easy way to fix it in your case though:

you'll notice the /findtext itself is not very precise. the /findtext ends up looking for that line, already stripped of excess spaces, anywhere in the buffer. thus it could potentially find too much (where the line is part of a larger line) or too little (where the line contains multiple consecutive spaces in the middle and therefore won't be found). i figured that since most people use timestamps, the first case was not likely to happen often enough to cause distress. now, in your case, mIRC needs to get a chance to "/findText [tstamp] Yawhatnever:" (trailing space gone), since it would then find the right line. the only problem is that it has to first pass successfully through $hl_findLine(). quickest solution is to just add '*' to the end of the search term, ie:

return $fline($2, $replace($3, *, ?) $+ *, 1)

now it resembles /findText in that it could report partial matches, but if you use a timestamp then the prospect of error is really slim. it isn't perfect, but i don't expect that the potential problems would cause anyone too much grief.

an almost bulletproof solution could be:

1) store the line in a way that retains information about excess spaces. maybe store the line as a regex (see below)
2) use $fline() with a regular expression (changing spaces to \x escapes etc.) to find the exact line
3) seek to the line using one or more /findTexts

number 3) is a bit complicated:

/findText will never be able to find a line containing excess spaces if you use those excess spaces in the search term. it is also limited in that it doesn't accept wildcards or any type of search other than a sort of "isin". we need to cut the line up, either before or after the first excess space and use that chunk in /findText. with this approach, we need to be able to know which line our next /findText is going to take us to. to do this, you can use /findText -n one or more times to seek to the last occurrence of in the buffer. the maximal number of times to do this can be found with $fline() and a precise search with regex. now you know that every /findText you do will take you back through $fline(, , N-1, 2) $fline(, , N-2, 2) $fline(, , N-3, 2) etc. and you can use $fline().text or $line() to retrieve the line currently in focus and compare it to the saved line and check for equality.

why is this almost bulletproof? because if your exists on several lines in a single message that wraps in your window, /findText will treat those as separate occurrences and cycle through them individually! but i think i have a better chance of being struck by lightning while cashing in a winning lottery ticket than witnessing that happen in practice.

Beautiful script though, I learned a lot just figuring out how it works :P

thank you :* glad people are still learning and playing with mIRC. i'll be back on regularly soon

Yawhatnever   -  May 09, 2012


Ok, so I tracked down a bug that happened literally on my first test message of the highlight window. I was using mibbit to test and it seemed to be failing to change colors and be clickable for some of the lines.

Eventually I realized it was because mibbit adds another space after tabbing a name. Consecutive spaces and trailing spaces are causing $fline to fail on the hotlink because the line in the hash has had the extra spaces stripped out during /hl_addLine.

I managed to find a workaround by replacing the extra $chr(32) with $chr(160) and then replacing them back for $hl_findLine so that the line would change colors and was clickable, but again ran into mIRC stripping all of the spaces for /findtext :(

I can't find any way to manipulate a window to scroll to the correct line to avoid /findtext (somebody suggested $com but it took 7 seconds to scroll 1500 lines) and I also can't figure out any way to keep /findtext from stripping the extra spaces. Using ctrl+f with multiple consecutive spaces does work, so I think I'll try to use sendKeys for that (I barely understand COM yet :( )

It wasn't your fault, just "mIRC being an asshole" (direct quote).

Beautiful script though, I learned a lot just figuring out how it works :P

jaytea   -  Mar 28, 2011

don't be a tease, what's the bug? :P

Callumlord   -  Mar 27, 2011

Nice script, I think I found a bug, but I will Beta it for a few days and see. :)

jaytea   -  Mar 20, 2011

update: alright, i finally tweaked it to work on earlier versions of mIRC. also modified the mouse over colouring so that it only colours lines that can still be found in the source window buffer.

thanks for the feedback everyone!

sunslayer: i don't think that colour is used anywhere now. it was introduced over 10 years ago accompanied by this versions.txt entry:

93.Added "Highlight nicknames" option to Display/options dialog, it
colours nickname prefixes in messages with the "highlight text"

this option was then moved a couple of versions later, and now it doesn't seem to exist anymore.

MaSOuD, why? the point of this addon was to add functionality onto mIRC's own highlight system which is already very easy to configure and rich in features.

MaSOuD   -  Mar 17, 2011

I think it was so good if it had an option to add/remove its own words for highlight instead of using mIRC's built-in Highlight system...
However, it was so nice. Well done jaytea, 9/10 and a like.

Jethro   -  Mar 16, 2011

Very nice, jaytea. I can use this code and modify it for my own use. 10/10 and like.

Scakk   -  Mar 16, 2011

Even though I can not use this 100% as was scripted , due to my version of mIRC, I can use bits for my own I am working on.

I give this a +Like as it is nicely done and gave me ideas I did nto think of on my own.

sunslayer   -  Mar 15, 2011

hmm I had always assumed that was what it was used for, just from skimming the help file it doesn't seem to explain what it's purpose is?

jaytea   -  Mar 15, 2011

'Highlight text' does not relate to mIRC's highlight system in any way. recall that different highlight entries can each have their own colour, which is why i create a %col variable in /hl_addLine though i elected not to use it anywhere, at least not for the message portion of each line in @Highlights. to use it as the moused over line's colour is an idea, but not one i see being attractive.

also, it would be a poor design choice to have a local script setting controlled by a global mIRC option.

sunslayer   -  Mar 15, 2011

I'd use $color(Highlight text) instead of defaulting to 4, so instead of having to edit the script users can simply alt-k to change it

jaytea   -  Mar 15, 2011

ye, $line() (which i use to grab the full highlight line from the window) didn't support @WID until 7.12. i used it so that /hl_checkHL could be abstracted; it uniquely identifies a window through its wid. this can't be done perfectly any other way, but cid+window name is close enough. it's just much more sensible to do it through wid, but as i said i'm happy to modify it if there's enough interest

Scakk   -  Mar 15, 2011

Ah. Aside the no message showing everything else works fine and I use 6.35.

jaytea   -  Mar 15, 2011

i should probably add that this snippet requires mIRC 7.12 or higher - it uses @WID in its window commands and $line(). if a few people really want me to adapt this to older versions of mIRC i will do so, but i implore people to upgrade to the latest version :P

Scakk   -  Mar 15, 2011

I am not seeing the message that highlighted me in the @window itself. I see the network and channel though.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.