Note: The mainteinance of the scripting examples is discontinued since I no longer have an interest to continue doing so. The pages will remain here, for now, but that might not be the case in the future. You are free to download all the material on these pages and set a up mirror, or even continue the maintenance of the material by enhancing the examples yourself.

All the material in these examples are for the mIRC version 6.03. It is very likely that some or most of these examples won't work in future versions.

Scripting a nick completer

mIRC already has an in-built nick completer. For example mIRC will expand "ge<tab>" to Geetee which should be enough for everyday usage. Just sometimes an user might want something more advanced, like "ge" expanding to "Geetee:"

The easiest way to handle this task is to do a popup or alias although a popup isn't exactly a real nick completer. The identifier $snicks contains all the selected nicks of the nicklist of active channel in the form nick1,nick2,nick3 etc. You can use /editbox -ap <text> to insert the message to the active editbox. The -a means that the text goes to the active window and -p tells mIRC to add a space after the text.

Example script

menu channel,nicklist {
  Talk to: editbox -ap $replace($snicks,$chr(44),$chr(47)) $+ :
alias f5 editbox -ap $replace($snicks,$chr(44),$chr(47)) $+ :

The example script creates popups to channel window and nicklist and binds F5 to the same purpose. Naturally you can change the popup locations and function keys. The example script also changes nick1,nick2,nick3 to nick1/nick2/nick3 to give an example what kind of manipulation you can do.

Anyway that script is still not a real nick completer. For real nick completer you need to use $editbox($active) to get the nick to be completed and $ialchan(<nick with wildcard>,$active,<number of matching nick>).nick for the actual nick.

Example script

alias f5 {
  ; If the active window is not a channel, halt
  if ( $active !ischan ) return
  ; Get the wildcard value from the last word of editbox, for example Ge => Ge*
  var %wildcardnick = $gettok($editbox($active),-1,32) $+ *
  ; If the last search matches current search, the alias is being called again
  ; i.e. the user has pressed f5 two times in a row
  if ( %nickcompleter.lastnick iswm %wildcardnick && $active == ) {
    %wildcardnick = %nickcompleter.lastnick
    inc %nickcompleter.number
  ; Otherwise reset the values for next time
  else {
    set %nickcompleter.lastnick %wildcardnick
    set $active
    set %nickcompleter.number 1
  ; Get the number of matches the wildcard value gets
  var %matches = $ialchan(%wildcardnick,$active,0)
  ; If there is a match and the user hasn't gone through all nicks,
  ; put the completed nick to the editbox
  if ( %matches > 0 && %nickcompleter.number <= %matches ) {
    editbox -ap $ialchan(%wildcardnick,$active,%nickcompleter.number).nick $+ :

However there is still one way to do a nick completer: on INPUT event. This way you can write something like "Ge, I agree", press enter while the script actually sends "Geetee, I agree". There are a few problems with this kind of approach but because some people seem to like it, I will tell how it can be done. The problem is that you type something and the script sends something else. At least I want my client to send exactly what I type. The another problem is that if there are two or more nicks, the script will have to guess which one to use. The example will again use $ialchan with the same methods as in the previous script. That's why this script needs a working Internal Address List (IAL).

Example script

on *:INPUT:#: {
  ; If the first character is /, the user is using a command
  if ( $left($1,1) == / ) return

  ; If the first word ends to a , (ASCII 44)
  if ( $right($1,1) == $chr(44) ) {
    ; Get the wildcard value to be used, for example Ge, => Ge*
    var %matchnick = $left($1,-1) $+ *
    ; Get the matching address from IAL and use .nick property
    var %nick = $ialchan(%matchnick,$chan,1).nick
    ; If there are no matches, return
    if ( %nick == $null ) return
    ; Format the output
    var %message = %nick $+ , $2-
    ; Send the message and halt default actions
    msg $chan %message

Last updated 2003-04-05, Janne 'Geetee' Nikula,