Custom Windows (@windows)

The /window command creates generic text windows - an area with individually colorable text lines, plus an optional side list box and an optional input box at the bottom. Handy for showing script output, logs, listings, or small text interfaces. A practical subset of the official mIRC documentation, with omissions explicitly noted below.

Unlike Dialogs, a @window is not a chat: the echo/say/etc. commands run from its editbox stay in the CONTEXT the /window was opened from, they don't write inside the @window itself. To write in there use /aline explicitly.

The generic on open/on close events (see Scripting) also fire for @windows, not just channels/groups/queries/status: $chan inside those handlers returns the name of the @window just opened/closed (e.g. @log).

Creating a window

/window [-switch] [-tN,..,N] [+style] <@name> [x y w h]
   [/command | [popup.txt] [font [size]] [iconfile]]

@name must start with @. x y w h are optional (without them, the window is centered with a default size). After x y w h comes EITHER a /command (run every time the user types text in the editbox and presses Enter - the typed text arrives as if it had been written right after the command, so as $1- if it's an alias), OR alternatively popup.txt/font [size]/iconfile: these are mutually exclusive here (not combinable in the same call like in real mIRC) so a command name can be reliably told apart from a file name, with no ambiguity.

window -e1l15 @log 50 50 400 300
aline @log Window ready.

/window switches

SwitchWhat it does
-a / -vBrings the window to the front.
-cCloses the window.
-e[N]Adds an input box at the bottom. N=1 multi-line, otherwise single line.
-h / -rHides / shows the window.
-l[N]Adds a side list box, about N characters wide (default ~100px).
-nMinimizes (hides) - ignored if combined with -e, so as not to hide a window that was just created with an editbox.
-xMaximizes/restores.
-o / -uSets/clears "always on top".
-pCreates a picture window (drawing surface) instead of the text area.
-q<S>:<P>Sets the progress bar: S = 0 disabled, 1 in progress, 2 success, 3 error; P = percentage 0-100.
-j<N>Limits the buffer to N lines (the oldest ones are discarded).
-sSorts the main text alphabetically (and the list box, if present).
-SSorts only the side list box.
-w<N>Shows/hides the taskbar button: N=0 hidden, otherwise visible (here a single taskbar acts as both switchbar and treebar, no real distinction between the two).
-k<N>N=0 hides the @ prefix in the taskbar button's text.

-tN,..,N switch (separate from the rest, with a space before it): sets the side list box's tab stops, in characters - a line's text containing tabs (\t) is placed starting at those positions. -t0 hides the text before the first tab.

Appearance styles (+ prefix, e.g. /window +tnx @name ...): t shows the title bar, n shows the minimize button, x shows the maximize button, d removes the border.

Text lines

/aline [c] <@name> <text>      appends a line at the end
/cline [c] <@name> <N>          changes line N's color
/dline <@name> <N[-N2]>          deletes line N (or N to N2)
/iline [c] <@name> <N> <text>   inserts at line N
/rline [c] <@name> <N> <text>   replaces line N
/sline <@name> <N>               selects line N

c (optional, right after the switch) is a 0-15 color number (same classic IRC palette). All of these commands accept -l to operate on the side list box instead of the main text. /aline//iline also accept -n (don't add if the text already exists), -i[N] (indents by N spaces, 2 by default), -s/-a (select the just-added/inserted line). /cline -r resets the line to the default color.

aline @log Connection established
aline 3 @log Warning: timeout
cline 9 @log 1
dline @log 2

/renwin

/renwin <@oldname> <@newname> [topic]

Renames an already-open window. The topic parameter (an extra context argument in real mIRC) is accepted but ignored: here a @window has no real "topic".

$window(N/@name)[.property]

FormWhat it does
$window(0)Number of open @windows.
$window(N)Name of the Nth open @window.
$window(@wildcard,N)Nth @window whose name matches the */? pattern.
$window(@name).propertySee table below.

Supported properties: x, y, cx, cy (identical to x/y here - we don't manage a real multi-monitor distinction), w, h, dw, dh (size of the text area or canvas), mdi, title, fulltitle, state (normal/hidden/maximized), font, fontsize, fontbold, fontitalic, ontop, type (custom or picture), wid, hwnd, lb (0 = no list box, 1 = present), pbstate/ pbpercent (progress bar state/percentage, see /window -q above).

$line(@name,N[,T])[.property]

Optional T: 1 to refer to the side list box instead of the main text (like -l in the commands above). N=0 returns the number of lines.

$line(@log,3)          ; text of line 3
$line(@log,0)          ; how many lines there are
$line(@log,3).color    ; color number of line 3 (empty if none)
$line(@log,3).state    ; 1/0 depending on whether it's the selected line
$line(@log,2,1)        ; line 2 of the side list box

$fline(@name,text,N,T,S)

Finds the position of the Nth line matching text (wildcard by default, T=2 or T=3 for a regular expression; T=1 operates on the list box). N=0 returns the number of matching lines. S sets where to start the search. The found position also stays in $flinen (bare identifier).

popup.txt and iconfile

popup.txt (positional parameter of /window, must end in .txt) loads a right-click menu for the window from a plain text file - same Label:command syntax used in popups.ini, without the [...] sections. iconfile (must have an image extension: ico/png/jpg/jpeg/bmp/gif) sets the titlebar icon - the N index (for files with multiple icons, typical of Windows .ico/.exe) is not supported, ignored.

window @log 50 50 400 300 mypopup.txt "Courier New" 12
window @log 50 50 400 300 icon.png

Picture Windows (/window -p)

A picture window is a @window with a drawing area (<canvas>) instead of text. You draw on it with the /draw* commands, and mouse clicks/movements can be intercepted.

window -p @canvas 50 50 300 200
drawrect -f @canvas 4 1 10 10 100 60
drawtext @canvas 1 Arial 14 20 20 Hi!

Colors in /draw* commands

Without the -r switch, <color> is a 0-15 index into the same classic palette used by /aline etc. With -r, it's a "packed" RGB value like the one returned by $rgb(r,g,b) (R + G×256 + B×65536 format, the same one real mIRC uses internally).

Drawing commands

CommandWhat it does
/drawdot [-r] @ <color> <size> <x y> [x y ...]Draws one or more square dots of side size.
/drawline [-r] @ <color> <size> <x y> <x y> [x y ...]Draws a line (polyline, if multiple x y pairs) of thickness size.
/drawrect [-refd] @ <color> <size> <x y w h> [...]Rectangle (or several, repeating x y w h). -f fills it, -e draws an ellipse instead.
/drawfill [-rs] @ <color> <color2> <x y>Fill starting at x,y. Without -s: "border fill", fills everything except color2 (the border color). With -s: "surface fill", replaces color2 with color.
/drawtext [-rbo] @ <color> [background color] [font size] <x y> <text>Writes text. -b indicates a background color was also given, -o makes it bold.
/drawpic @ [x y [w h]] <file>Loads and draws an image (graphic file) - loading is asynchronous (the drawing appears as soon as the file is ready, not at the same instant as the command).
/drawscroll @ <dx dy> <x y w h>Shifts the given rectangle's content by dx,dy.
/drawcopy [-r] @ <x y w h> @dest <x y [w h]>Copies an area (even onto another picture window), with optional resizing.
/drawrot @ <angle> [x y w h]Rotates the given area (the whole canvas if omitted) around its own center.
/drawreplace [-r] @ <color1> <color2> [x y w h]Replaces every color1 pixel with color2 in the given area.
/drawsize @ <w> <h>Enlarges the drawing surface (up to 8192×8192) - never shrinks it.
/drawsave [-a] @ [x y w h] <file>Exports the canvas (or the area given with -a) to a PNG file.
/clear @nameClears a picture window's canvas (or a normal @window's text). /clear -c @name only clears the click history.

Mouse events

Real mIRC defines them inside a menu @name { mouse:/command sclick:/command ... } block. Here, for consistency with the rest of the scripting engine (same structure as on dialog events), you use instead:

on 1:mouse:@name:event: {
  echo $mouse.x $mouse.y
}
EventWhen it fires
mouseThe mouse moves over the canvas.
sclick / dclick / uclickSingle / double click / button release.
rclickRight click (also shows popup.txt, if present).
lbclickA row selected in the side list box (of any @window, not just picture windows).
leaveThe mouse leaves the window's area - $window (bare) returns the name of the window just left.
dropClick and drag followed by button release.

Picture Windows identifiers

IdentifierWhat it does
$click(@name[,N]).x/.yCoordinates of the Nth recorded click (the last one, if N omitted).
$getdot(@name,x,y)Packed RGB value of the pixel at that position.
$height(text,font,size,bipt) / $width(...)Height/width in pixels of the text with that font. bipt: 4 digits 0/1 for bold/italic/color codes/tabs (here only bold - 1st digit - is considered).
$inrect(px,py,x,y,w,h)1/0 depending on whether the point is inside the rectangle.
$inellipse(px,py,x,y,w,h)1/0 depending on whether the point is inside the ellipse.
$inroundrect(px,py,x,y,w,h,w,h)Approximated: treated as $inrect, rounded corners aren't considered separately.
$inpoly(px,py,x,y,x,y,...)1/0 depending on whether the point is inside the polygon.
$onpoly(n1,n2,x,y,...)1/0 depending on whether two polygons overlap (approximated: checks whether a vertex of one falls inside the other, not a real segment intersection).
$mouse (bare)"x y" of the last mouse event. Properties: .win .x .y .mx .my .cx .cy .dx .dy .key .lb - .key is a bitmask (1=left, 2=ctrl, 4=shift, 8=alt, 16=right), read it with &.
$pic(file).width/.heightDimensions of an image file.
$rgb(r,g,b)Packed RGB value. $rgb(N) with a single number splits it into "r g b". $rgb(name) with a system color (face/shadow/hilight/3dlight/frame/text) returns a fixed approximation.

What is NOT supported