mIRC ScriptBox
Basics: Introduction into Aliases

Written by Merlin

Table of Content

  Section 1

  1. What is an 'alias'?
  2. How to open the Editor for Aliases?
  3. How to add and call aliases?
  4. Use / or not to call the alias?
  5. Identifiers in aliases
  6. Using the $1-identifier
  7. Multiple Commands
  8. Join multiple channels
  9. The /say command
  10. Multiple lines
  11. The /me command

  Section 2

  1. Shared identifiers
  2. Mode Changes (Opping, etc.)
  3. Proper spacing!
  4. Where can you use Aliases?
  5. Aliases call aliases?
  6. Function keys
  7. Function key examples
  8. More examples
  9. Using evaluation brackets
  10. Aliases in Scripts
  11. Conclusion


This tutorial has first been made public available during my successful CBT Project started in 1998, where Eggdrop Bots on various IRC networks have been set up to give courses on IRC.

These courses have never before been released on any web site or have been submitted to anyone.

1. What is an 'alias'?  Back to Top

An alias is a shortcut to longer commands or repetitive commands. mIRC allows the user to set aliases that enable you to perform IRC functions more quickly by typing a simple command.

1a. How to open the Editor for Aliases?  Back to Top

To open the builtin editor and go to the Aliases section there are two ways you can use:
  • Hold down the ALT-key and while holding it down press the letter 'A' and then release both keys or
  • Click 'Tools', then 'Scripts Editor'.
You can see now a line that looks like this:

Below that there are 5 tabs (because you used ALT-P, the 'Popups'-Tab is put in the foreground):

Below that you can see the Editor window - exactly where we will edit our popups throughout this tutorial.

How to add and call aliases?  Back to Top

To open the alias section in your mIRC editor, press the ALT key plus the letter 'A', or click on 'Tools', then 'Scripts Editor' and then on the 'Aliases'-Tab. All aliases use the format /<aliasname> /<command>
/j /join $1

In other words, first your 'shortcut' name (like '/j' in the example above), then a space, and then the actual command your shortcut is pointing to (like '/join' in the example above).

Use / or not to call the alias?  Back to Top

In placing aliases in the alias section of your mIRC editor, you do not -have- to specify the / command character. It is really only needed when typing commands in a channel or chat. Just for clarity I decided to use the / in this tutorial. Keep in mind that the alias 'j join $1' will work as well.

Identifiers in aliases  Back to Top

Aliases also use a number of special identifiers. There are several identifiers such as: $1, $3-5, $$1, $?, $!, #$1, #$$1, and even #$?. Some are filled in by a standard 'value'. Other important Identifiers are the #, $me and $url but the list of identifiers is long and ever growing.

To give you a better idea; $read, $date, $adate, $fulldate, $time and $day are some other identifiers. Don't worry, we'll explain all of these in good time.

Using the $1-identifier  Back to Top

Right now, let's concentrate on $1. After all, that's the identifier we used in our example above: /j /join $1.

$1 means 'the first word typed after the Alias, whatever that may be.' So if you type '/j #test', mIRC knows that this is a shortcut for '/join #test'. If you type '/j #hello', it will know that this is a shortcut for '/join #hello'.

Multiple Commands  Back to Top

Now, let's say that you'd like to join several channels at once. You can make an alias to do this. Just separate the commands with the | character (on most keyboards, this is the shifted version of the backslash key).

Let's say that you'd like to be able to type '/j3' and then follow it with the names of three channels, and they'll all be joined at once. The alias would be: /j3 /join $1 | /join $2 | /join $3

Join multiple channels  Back to Top

So if you placed this alias in Tools/Aliases and you were to type: /j3 #test1 #test2 #test3 and mIRC would '/join #test1', then '/join #test2', and then '/join #test3'. In this case, you see that $1 means the first word typed after the Alias. And $2 of course means the second word, and $3 the third.

Now, mIRC is obviously expecting three words -- your channel names. So what would happen if you just typed '/j3 #test1'? mIRC would complain about the missing parameters, as it's expecting more channels to be named. (There is a solution to this problem, the $$1 identifier, which will be explained later.)

The /say command  Back to Top

Use /say: Let's say that there's something you find yourself typing into a channel all the time, like your home page address, a greeting, etc. Take a look at these alias examples using the '/say' command: '/say' simply types the indicated text into your current channel or private message window.
Example: /hello /say Hello to all of you...
Example: /www /say The mIRC page is at http://www.mirc.co.uk

Multiple lines  Back to Top

The next examples show how to use mutiple lines. '/say' multiple lines of text in one alias.

Example: /lines /say This is the first line | /say This is the second line | /say This is the last line

Just separate the commands with the | character. You also see that not all aliases always have identifiers in them.

The /me command  Back to Top

Actions in an alias using /me:
Example: /fun /me thinks this is fun!
Example: /hug /me hugs $1 firmly!

The second example uses a identifier, $1. If you were to type '/hug everybody', this would be equivalent to '/me hugs everybody firmly!'

Shared identifiers  Back to Top

Multiple commands can also share the same identifier.
Example: /jtest /join $1 | /topic $1 just testing

In this alias definition the parameter $1 is used twice. If you were to type '/jtest #test', it would first join the channel #test, and then change the channel topic to 'just testing.'

Another example along the same lines:
/love /say I love $1 ! | /say I really love $1 !!

If you were to type '/love everybody', mIRC would know to '/say I love everybody !' and then, '/say I really love everybody !!'

Mode Changes (Opping, etc.)  Back to Top

To put your often-used mode changes in the aliases section, you first need to know the normal structure of the mode commands. Opping somebody on IRC normally requires the command: /mode #<channelname> +ooo <nick1> <nick2> <nick3> in which up to 3 persons can be mentioned. This can be nicely aliased with: /op /mode # +ooo $1 $2 $3

To op John, Jake, and Joan, now you can just type: '/op John Jake Joan' The # in this alias shows the use of one of other the pre-defined identifiers (# and $!).

The # always stands for the #channelname of the channel on which the alias is used. In the same way you can make aliases like...
Example: /deop /mode # -ooo $1 $2 $3
Example: /ban /mode # +b $1
Example: /kick /kick # $1
Example: /dbk /mode # -o $1 | /kick # $1 | /mode # +b $1

Proper spacing!  Back to Top

Proper spacing! This is very important! You MUST include spaces between identifiers and the rest of your text! For example: /like /say I really like $1!!! ...will NOT work!
There needs to be a space between the identifier '$1' and your '!!!''s. (This can sometimes make your text look awkward when using commands like /say, so be careful with your phrasing.)

But /like /say I really like $1 !!! ...WILL work just fine. This is true of ALL identifiers. To make one particular case easier, specifying channels, a few special identifiers have been created that automatically prefix the parameter with the # character. These are #$1, #$$1, and #$?. See the next lesson for details.

Where can you use Aliases?  Back to Top

Aliases can be used in the edit box (the line or lines you normally use to type commands in), and you can even use aliases in the Popups and the Remote sections that will be explained in the following sections.

The function key aliases can also be used on selected nicks in the channel names-list and in query windows, etc....depending on your alias definitions.

Aliases call aliases?  Back to Top

It is even allowed for aliases to call other aliases, or even to call themselves recursively. As a safeguard against infinite loops, the default maximum recurse depth is set at 5. This can be changed with the /maxdepth command. The minimum depth allowed is 1 (aliases can't call other aliases) and the maximum is 100.

Calling aliases from within aliases uses quite a bit of memory, so this might cause problems in certain situations where memory is low etc. In case one of your aliases or remotes got into a loop use the CTRL+Break key combination to stop the process.

Function keys  Back to Top

A special alias definition is possible which can launch commands using the Function keys (F-keys). Define some aliases as follows:
Example: /f1 /say Hello to you all
Example: /f2 /topic # This is a new topic

You now can type '/f1' to say hello to all on a channel ... but also pressing the 'F1' function will work!!

Function key examples  Back to Top

Other examples:
Example: /f5 /me will happily send you the new mIRC.
Example: /f6 /join #mirc
Example: /f9 /dcc send $1 c:\faq.zip
Example:/f10 /dcc send $1 c:\f.exe
Example:/f11 /dcc send $1

In this instance, the F9 key will send the mIRC FAQ to a person selected from the channel names list. Don't forget to select a nick first! If you don't, you will see strange (but logical) things... You can even use the F9 key in a Private, Query or DCC Chat window with this alias definition! The F11 key will prompt you for the nick to whom to send a file.

More examples  Back to Top

Well - invent your own custom use of the F-keys - have fun! You can also use -shift- and -ctrl- in combination with the F keys. Just define aliases like:
Example: /f1 /say I used F1 to say this
Example: /sf1 /say I used Shift+F1 to say this*
Example: /cf1 /say I used CTRL+F1 to say this

Using evaluation brackets  Back to Top

You can now use [ and ] evaluation brackets in aliases to control the order of evaluation of identifiers. The brackets can be uses in popups and remotes as well.

Identifiers within brackets will be evaluated first, from left to right. You can also nest brackets. This allows you to evaluate things any way you like. The brackets will not be shown in the resulting text or command.

Example's are:
/note /notice $1 " $+ [ $read [ -s $+ [ $2 ] ] c:\text\note.txt ] $+ "
/sayvar /say % [ $+ [ $1 ] ]

Definitions without evaluation brackets are evaluated the same way as before.

Aliases in Scripts  Back to Top

You can easily load additional alias files into mIRC along with the one(s) you already have. You can run multiple alias files, simultaneously. Open the aliases editor (Tools/Aliases/... or Alt + A) and go to File/Load/. It is easy to select a file with aliases now. Select 'View' to see all loaded alias files.

This is an easy way to try the aliases your friends created and to give your file with aliases to your friends. Aliases can even be included in a complete script file and distributed together with Remote Commands and Events. We'll explain this in detail later on.

Conclusion  Back to Top

By now, you should have a decent grasp of the Aliases section. You might be interested in a full list of the identifiers that you can use in your aliases and, later on, in popups and remote definitions as well.