mIRC ScriptBox
Useful Tips and Tricks for mIRC

Overview

This is a collection of tips and tricks I found on the internet. A major part was collected by pai on her "Daily Tips" web page.
Since her website is not available anymore I decided to add those tips to the mScriptBox.
Additionally I added various tips submitted by prescott.


mIRC Tip 01  Back to Top

Holding Ctrl while pressing PgUp and PgDn is an easy shortcut for scrolling up and down a single line at a time.


mIRC Tip 02  Back to Top

Not only does $ifmatch return the matched text from the most recent /if, it also works with /while. For example, try this in a channel window:
//var %n = 1 | while ($nick($chan,%n)) { echo $ifmatch | inc %n }


mIRC Tip 03  Back to Top

When changing mIRC's colors with the /color command (such as applying a theme) you should check if the color is already the same using the $color() identifier. This will speed up your coloring routines dramatically.


mIRC Tip 04  Back to Top

When using /scid to perform a command, it will be reevaluated just like a /timer. Most of the time, this means you want to use $!identifier syntax, or $eval(text,0). For example, /scid $activecid echo -s My nick is $!me. If you're not sure, have the /scid call an alias which does the command, to prevent unwanted reevaluation that can lead to security holes.


mIRC Tip 05  Back to Top

You can press Ctrl+L in any mIRC window to quickly show where you last viewed that window's conversation. Press it again to toggle this off.


mIRC Tip 06  Back to Top

You can use Alt+Q to quickly show and hide the secondary command editbox in a channel window. This editbox can be set to execute a common command, such as /echo or /onotice, in the system menu (Alt+hyphen) of the channel window.


mIRC Tip 07  Back to Top

You can use $mouse.key to check whether the Ctrl or Shift key is being pressed at any given time, to allow different behavior for FKeys, popups, etc.


mIRC Tip 08  Back to Top

When using the /window command on channel windows, you should enclose the window name in quotes. Otherwise, the command will break on +channels. (channels beginning with a plus sign)


mIRC Tip 09  Back to Top

Keep in mind that during a KICK, PART, or QUIT event, that the nicklist and IAL have not been updated to match the changes. However, you can use the /updatenl command to "force" them to update. This will affect future events in other files though, so it is not recommended for compatibility reasons.


mIRC Tip 10  Back to Top

You can quickly check $chan().status to find out if you are in a channel, currently rejoining the channel, or kicked and not rejoining. (status return values include joined, joining, and kicked)


mIRC Tip 11  Back to Top

You can not only use TAB to complete nicknames, but also channels. Type a partial channel name and hit TAB to complete it to match any open channel or channel in your channels folder.


mIRC Tip 12  Back to Top

You can hold Ctrl while copying text with the mouse to copy colors and attributes along with the text.


mIRC Tip 13  Back to Top

If you set a variable with /set -u (to unset it automatically) you can safely /inc and /dec it and it will still unset at the normal time. If you do another /set without a -u, though, it will cancel the timed unset.


mIRC Tip 14  Back to Top

Although you can use /set -u to have mIRC unset a variable for you automatically, sometimes you must use /set -u1 to prevent mIRC from unsetting it too soon. This includes anytime you are "sending" the variables to a /dialog INIT event or when the variables will be referenced in another event triggering later in another file. /timer 1 0, however, seems to wait until all events are complete before triggering.


mIRC Tip 15  Back to Top

When creating popups with $submenu(), keep in mind that the values you return will be reevaluated, and any colons, braces, etc. in the text will be treated as they would had you typed the popup in manually.


mIRC Tip 16  Back to Top

There is a subtle difference between /if (#chan ischan) and /if ($me ison #chan). The first is $true anytime the channel is open, even if you're currently disconnected, rejoining, or kicked. The second is only true if you're actually online and on the channel at that moment.


mIRC Tip 17  Back to Top

To quickly perform a command on all connected servers, use /scid -at1 command. Keep in mind that the command will be reevaluated, so be careful with any included identifiers or variables.


mIRC Tip 18  Back to Top

You can "chain" $ifmatch in a series of /if expressions, if you are checking the same item against multiple things. For example:
/if (($stuff > 10) && ($ifmatch < 30) && ($ifmatch == $int($ifmatch))).
This would reduce extra calls to your custom $stuff identifier. Note that $ifmatch only repeats what was on the left side of the last /if expression. (the example would check for an integer value between 10 and 30)


mIRC Tip 19  Back to Top

During a NICK event, anytime you refer to the nick in the nicklist, IAL, or any other identifier, be sure to use $newnick- as the nicklist and IAL have already been updated. However, $me is NOT updated until after the event- so if you're the one changing nicks, $me will still contain your old nick.


mIRC Tip 20  Back to Top

You can use /goto %var to select from one of many choices easily, just name each label after the choice, and have a final :%var label that will catch all unrecognized choices. Note that you should not do /goto $1, as you cannot have a :$1 label. Store $1 in a local %var first.


mIRC Tip 21  Back to Top

When using $nick() to filter channel nicknames, you can use 'o' for ops, 'v' for voice, etc. However, you can also use the actual mode characters- @, +, etc. This is useful when a mode (such as *) is not specifically supported by mIRC.


mIRC Tip 22  Back to Top

You can find out what event or menu is currently running by checking $event and $menu. This allows you to write generic aliases that can have slightly different behavior based on the currently running event or popup.


mIRC Tip 23  Back to Top

The secondary command editbox in channels (Alt+Q) can be resized easily by dragging the divider with the mouse, just like the channel nicklist.


mIRC Tip 24  Back to Top

/filter and $fline() allow you to read fron the channel nicklist. You can use $fline() to write a very quick and dirty nickname completion routine: $line($chan,$fline($chan,p*,1,1),1) would find the first nick starting with p, for example.


mIRC Tip 25  Back to Top

When using color codes followed by unknown text, be sure to use double-digit codes. For example, /echo $chr(3) $+ 5 $+ $1 will cause problems if $1 starts with a number. Use /echo $chr(3) $+ 05 $+ $1 instead. (you can use $color().dd to get double-digit color codes for mIRC's colors.)


mIRC Tip 26  Back to Top

You can use the & symbol (ampersand) in any popup name or dialog item to add an "accellerator" key. This will underline the letter and allow the user to press that key or Alt+key to quickly access that item. (for example, "&Kick".)


mIRC Tip 27  Back to Top

You can use $~() as a shortcut for $eval(), however, this is undocumented and may not be supported in later mIRC versions.


mIRC Tip 28  Back to Top

Although mIRC supports many formats for the /if command, you should always include parenthesis, or mIRC may get confused with more complex expressions. For example, /if %a == %b, although it works, is poor syntax. Use /if (%a == %b) instead.


mIRC Tip 29  Back to Top

When you want to find out mIRC's nickname color for a nickname, you can use $cnick(nickname). An undocumented feature, however, is that if you want to determine their color based on op status, you must append the op prefix to the nickname: $cnick(@nickname) if they are opped, for example.


mIRC Tip 30  Back to Top

You can use $eval(%blah,0) to tell mIRC to NOT evaluate something at all. For example, normally %foo would return the value of the variable %foo. However, $eval(%foo,0) will return the actual text %foo.


mIRC Tip 31  Back to Top

You can quickly access the top servers in mIRC's server list by right-clicking on the setup icon on the toolbar. (second icon over.) Other icons have similar access lists.


mIRC Tip 32  Back to Top

When debugging your script, a very helpful feature is the '-s' switch for set/unset/inc/dec. Using /set -s %var test will tell you exactly what is being set to what, the same works for the other commands. Using these throughout a routine lets you see exactly what is going on, easing debugging. You can then remove the -s switches when it's working. These also work on hash commands.


mIRC Tip 33  Back to Top

You can change the actual colors used for mIRC's 16 built-in colors. Simply go to the color's dialog (Alt+K) and right-click on a color swatch on the bottom.


mIRC Tip 34  Back to Top

The /uwho command provides you with an improved interface with information on the person. You can store and fetch user info and addresses and view all kinds of ctcp information in it


mIRC Tip 35  Back to Top

The help menu has been made dynamic to display all .hlp files in mIRC's directory, as well as the text files like the readme.txt, versions.txt, and update.txt files, for quick access. Also internal aliases are added that match the help filenames, so if you have the file "ircintro.hlp" in mIRC's directory you can type /ircintro (like /help). You can add whatever help files you like to mIRC's help menu!

mIRC Tip 36  Back to Top

You can use $wid (and $window().wid) to get a unique window number for any open window. These numbers are unique and never duplicated, so you can use this to store internal data that applies to a specific window if you don't want that data to apply to any other window- even another window of the same name. (for example, the same channel on another server, or the same window reopened later)