Picture Windows

 

The picture window is a special type of custom window that can display a combination of text, graphics, and pictures, and can trigger script events relating to mouse clicks and movements.

 

Once you have opened a picture window using the /window command, you can use the following commands and identifiers to draw and monitor activity in this window.

 

Drawing commands

 

/drawsize @ <w h>

Sets the minimum bitmap size for a picture window to the specified width and height, up to a maximum of 8192 x 8192 pixels.

 

Normally, the maximum point that can be drawn to is based on the size of the visible window.

 

If you make the window bigger, the bitmap is enlarged.

 

If you make the window smaller, the bitmap is shrunk but only to the largest point that has already been drawn on it.

 

The largest point can be reset with the /clear command.

 

The /drawsize command allows you to set a minimum bitmap size.

 

Note: Bitmaps use a large amount of memory and can cause Windows to run out of memory if not used carefully. You should always use the smallest bitmap that you need.

 

/drawdot -ihnr @ <color> <size> <x y> [<x y>...]

Draws a dot using the specified color and size at the x,y co-ordinates. Multiple co-ordinates can be provided.

 

The -i switch draws in inverse mode.

 

The -h switch highlights the windows icon if it is minimized.

 

The -n switch prevents the display from being updated immediately. This allows you to make changes to the window in the background and then display the results only when you have finished. You can update the display by using any of the /draw commands with only the window name specified.

 

The -r switch indicates that the color is in RGB format. You can use $rgb(N,N,N) to create an RGB value.

 

The whole window can be cleared by using the /clear command, eg. /clear @name. You can also specify the -n switch in /clear to delay the effect as described above.

 

/drawline -ihnr @ <color> <size> <x y> <x y> [<x y>...]

Draws a line from the first <x y> co-ordinate to the second, if more co-ordinates are specified, the line is continued. The switches are the same as those in /drawdot.

 

/drawrect -ihnrfecd @ <color> <size> <x y w h> [<x y w h>...]

Draws a rectangle at the specified co-ordinates of the specified width and height. If more co-ordinates are specified these are also drawn as separate rectangles.

 

The -f switch fills the rectangle with the current color.

 

The -e switch draws an Ellipse instead of a rectangle. You can draw a filled ellipse if you also specify the -f switch.

 

The -c switch draws a focus rectangle.

 

The -d switch draws a rounded rectangle, using the format /drawrect -d x y w h [w h],  where w and h are the width and height of the ellipse used to draw the corners.

 

The remaining switches are the same as those in /drawdot.

 

/drawfill -ihnrs @ <color> <color> <x y> [filename] [<x y>...]

Fills an area with the specified color starting at the specified co-ordinates.

 

The -s switches indicates that the second color parameter is the color that should be filled (surface fill). If no -s is specified, the second color is the border color at which filling should stop (border fill).

 

The optional [filename] specifies a bitmap .BMP file that is 8 by 8 pixels in size and is used as a fill pattern.

 

The remaining switches are the same as those in /drawdot.

 

/drawtext -dhnrpbocv @ <color> [color] [fontname fontsize] <x y [w h]> <text>

Draws text at the specified co-ordinates.

 

The -p switch processes and interprets color/bold/etc. codes in the text.

 

The -d switch disables tab character support.

 

The -b switch indicates that you have specified the second color parameter as the background color for the text.

 

The -o switch means the specified font should be in bold.

 

The -c switch means that you have specified the [w h] values as the rectangle in which text should be printed. Text will be clipped if it extends beyond this rectangle.

 

The -v switch means that you have specified a &binvar binary variable instead of text.

 

The remaining switches are the same as those in /drawdot.

 

Note: If you use a negative number for the font size, it will match the size of fonts in the font dialog.

 

/drawsave -abNqNvNdu @ [x y w h] <filename|&binvar>

This saves the background picture of the specified picture @window to a .bmp filename.

 

The -a switch specifies the [x y w h] area of the bitmap to be saved.

 

The -bN switch allows you to specify the bit depth of the saved file, which can be 1, 4, 8, 16, 24, or 32.

 

The -qN switch allows you to specify the quality of the jpeg file that is being saved, where N is between 1 and 100.

 

The -vN switch allows you to save the bitmap to a &binvar, where N is optional and can be p = png, g = gif, j = jpg.

 

The -du switches dither and quantize the bitmap, for use with the -b switch.

 

/drawscroll -hn @ <x> <y> <x y w h> [<x> <y> <x y w h>...]

Scrolls the region inside the specified rectangle. The first <x> and <y> parameters represent the distance to scroll and can be positive or negative.

 

The remaining switches are the same as those in /drawdot.

 

/drawcopy -ihmnt @ [color] <x y w h> @ <x y [w h]>

Copies part of a picture to a different position in the same window or to another window. If the second [w h] parameters are specified, the picture is stretched/squeezed to fit.

 

The -t switch indicates that you have specified the [color] RGB value as a transparent color in the source bitmap.

 

The -m switch changes the stretch mode quality when the picture is resized.

 

The remaining switches are the same as those in /drawdot.

 

/drawpic -ifhmnotsclgNv @ [color] <x y [w h]> [x y w h] [N] [M] <filename|&binvar>

Loads and draws a picture at the specified co-ordinates. The picture can be a graphics file, or an ico/exe/dll file.

 

If the first [w h] are specified, it is stretched or squeezed to fit. The second [x y w h] rectangle specifies which portion of the loaded bitmap should be displayed ie. a bitmap could contain multiple pictures.

 

The -t switch indicates that you have specified the [color] RGB value as a transparent color in the specified bitmap.

 

The -s switch indicates that you have specified the first [w h] parameters (as explained above) to squeeze/stretch the bitmap.

 

The -c switch indicates that the bitmap should be cached. This greatly speeds up subsequent references to this bitmap. If you specify -c and the bitmap is already in the cache, it is loaded and used from the cache, otherwise it is reloaded from the file. You can clear the entire cache with /drawpic -c.

 

The -l switch tiles the picture.

 

The -m switch changes the stretch mode quality when the picture is resized.

 

The -o switch indicates that you have specified the [N] value before the filename represents the index of the icon in the file. This also works with GIF files to  specify the Nth frame.

 

The -f switch works with -o to specify the Nth icon and the Mth frame in that icon, for an icon that contain multiple icons.

 

The -gN switch attempts to load the large icon in an icon file, if none exists, it loads the small icon. If N is specified, N = 0 loads the small icon, N = 1 loads the large icon, and N = 2 loads the actual icon.

 

The -v switch loads a picture from a &binvar instead of a filename.

 

If you try to load and cache a bitmap and there are already 30 bitmaps in the cache, the bitmap with the lowest reference count is freed and replaced by the new bitmap.

 

If you try to load a bitmap and there is not enough memory, mIRC repeatedly frees the least referenced bitmap and tries to load again.

 

The remaining switches are the same as those in /drawdot.

 

/drawrot -hmnpbfc @ [color] <angle> [x y w h]

Rotates an area of a bitmap by the specified angle.

 

The -b switch indicates that you have specified the background color value.

 

The -f switch fits the newly rotated bitmap into the original width/height.

 

The -c switch centers the rotated image if -f is not specified.

 

The -m switch changes the stretch mode quality when the picture is resized.

 

The -p switch clips the rotated rectangle.

 

The remaining switches are the same as those in /drawdot.

 

/drawreplace -nr @ <color1> <color2> [x y w h]

Replaces color1 with color2 in the specified picture window.

 

The remaining switches are the same as those in /drawdot.

 

Events

 

Mouse events can be defined in a scripts menu definition, where they must be placed first above all other menu items:

 

menu @test {

 mouse:/echo mouse moved at $mouse.x $mouse.y in $active $1

 sclick:/echo single click at $mouse.x $mouse.y

 dclick:/echo double click at $mouse.x $mouse.y

 uclick:/echo mouse released at $mouse.x $mouse.y

 rclick:/echo single right-click at $mouse.x $mouse.y in $active $1

 lbclick:/echo mouse selected $active $1

 leave:/echo mouse left $leftwin $leftwinwid $leftwincid

 drop:/echo drag and drop at $mouse.x $mouse.y

}

 

The mouse event is triggered when you move a mouse inside a picture window. You can use the $mouse identifier (see below) for the x and y position of the mouse.

 

The sclick event is triggered when you click once inside a picture window. It will also trigger if you double-click.

 

The dclick event is triggered when you double-click inside a picture window.

 

The uclick event is triggered when a mouse button is released inside a picture window.

 

The lbclick event is triggered when an item is selected in a listbox, either with the mouse or the cursor keys.

 

The leave event is triggered when the mouse is moved outside the borders of a custom window.

 

The drop event is triggered if you click and drag the mouse in a window and then let go of the button.

 

Identifiers

 

$click(@,N)

This stores a history of x,y clicks for a window.

 

Properties: x, y

 

You can use /clear -c @name to clear the history of clicks for a window. If you use $click() with no properties it returns x y.

 

$getdot(@,x,y)

Returns the RGB color value of the dot at the specified position.

 

$height(text,font,size,bipt)

Returns height of text in pixels for the specified font.

 

Where bipt set the options for bold, italic, process control codes, and process tabs. Each of these can be followed by an N value of zero or one to indicate whether they are disabled or enabled respectively.

 

Note: If you use a negative number for the font size, it will match the size of fonts in the font dialog.

 

$inellipse(x,y,x,y,w,h)

Returns $true if the point x y is inside the specified ellipse, and $false if it is not.

 

$inrect(x,y,x,y,w,h)

Returns $true if the point x y is inside the specified rectangle, and $false if it is not.

 

$inroundrect(x,y,x,y,w,h,w,h)

Returns $true if the point x y is inside the specified rounded rectangle, and $false if it is not.

 

$inpoly(x,y,a1,a2,b1,b2,...)

Returns $true if the point x y is inside the polygon defined by the specified points, and $false if it is not.

 

$mouse

Returns the x, y position of the current mouse event, and whether the left mouse button, shift key, and/or control key are pressed.

 

Properties: win, x, y, mx, my, cx, cy, dx, dy, key, lb

 

The $mouse identifier can be used in the mouse/click events.

 

With $mouse.key, you can use the & bitwise operator to check if the left button, shift key, and/or control key are pressed.  It can also be used to check if the right-shift/control/menu keys are pressed or the capital/scroll/numlock keys are set.

 

if ($mouse.key & 1) echo left button is pressed.

if ($mouse.key & 2) echo control key is pressed.

if ($mouse.key & 4) echo shift key is pressed.

if ($mouse.key & 8) echo alt key is pressed.

if ($mouse.key & 16) echo right mouse button is pressed.

 

The following properties can also be used:

 

The .win property returns the name of the active window.

 

The .x/.y, .mx/.my, .cx/.cy, and .dx/.dy properties return the x and y position of the mouse relative to the active window, the main mIRC window, the primary monitor, and the desktop respectively.

 

The .lb property returns $true if a mouse event occurred over a listbox, or $false if it did not.

 

$onpoly(n1,n2,x,y,x,y,...)

Returns $true if two polygons overlap. n1 is the number of points in the first polygon, n2 in the second polygon.

 

$pic(filename,N,M)

Returns properties for bmp, jpg, png, or icon files.

 

Properties: size, width, height, icons, frames, delay

 

Note: The N and M values are optional and need to be specified with the icons, frames, and delay properties when retrieving values for GIF and icon files that can contain multiple frames and icons.

 

$rgb(N,N,N|N|name)

Returns an RGB color value for use in /draw commands.

 

If you use only one parameter and it is a number, it assumes it is an RGB color value and returns N,N,N.

 

If it is not a number, it assumes it is one of these system color names: face, shadow, hilight, 3dlight, frame, and text, and returns an RGB color value.

 

$width(text,font,size,bipt)

Returns width of text in pixels for the specified font.

 

Where bipt set the options for bold, italic, process control codes, and process tabs. Each of these can be followed by an N value of zero or one to indicate whether they are disabled or enabled respectively.

 

Note: If you use a negative number for the font size, it will match the size of fonts in the font dialog.

 

$window

Returns the name of the window in the leave menu event which was just left.