mIRC Scripting
mIRC: Dialog Events
There is only one ON Dialog event. When you type into the edit box or click a button on the dialog you made you will trigger that event. This event allows you to monitor and process the user's inputs.
;commands here
}
Identifiers
-- $dname - Dialog Name
-- $devent - Object's Event
-- $did - Object's ID
Events
Events are the way you monitor changes to the dialog. If the user changes the text in an edit control, that change is the ‘edit’ event. Here is a list of events that are associated with the dialog.
The event is retrieved using the $devent identifier.
| Types Of Events | |
| Event | Occurs When... |
| init | Just before dialog is displayed (initialization code for objects should go here) |
| close | dialog is closed |
| edit | if text in the edit box or combo box was changed |
| sclick | single click in list/combo box, or check/uncheck of radio/check buttons, or click of a button |
| dclick | double click in list/combo box |
| menu | menu item is selected |
| scroll | scroll control position has changed |
Mouse Events
The mouse events are associated with different mouse status changes like mouse click and mouse drag.
The mouse event is retrieved using the $mouse identifier.
| Mouse
Events (Unassociated with any objects) |
|
| Event | Occurs When... |
| mouse | mouse moves |
| sclick | mouse left button down |
| uclick | mouse left button up |
| dclick | mouse double click |
| rclick | mouse right button click |
| drop | mouse drop click |
/did Command
The /did command lets you modify the different values and properties of the controls in the dialog on the fly.
-- name - is required, its the name of the dialog
-- id - is also required, its the id of the control
| Switches | |
| Switch | Explanation |
| -f | sets a specified control in focus |
| -t | sets a control as the default button |
| -e | enable a control |
| -b | disable a control |
| -v | makes the control visible |
| -h | hide the control |
| -n | enables editbox |
| -m | disables editbox |
| -c | check checkbox/radiobutton
list/combo line To Select A Range Of Text: /did -c name id [n] [start [end]] |
| -u | uncheck checkbox/radiobutton list/combo line |
| -k | in conjunction with -cu; keeps selection in listbox |
| -s | checks the checkbox of an item in a listcb control |
| -l | unchecks the checkbox of an item in a listcb control |
| -r | clears all the text in the control |
| -a | adds a line to the end of the text |
| -d | deletes the Nth line of text from a control |
| -i | inserts a text in the Nth line of the contorl |
| -o | overwrite the Nth line of the control |
| -g | changes the picture in the icon contorl |
| -z | resets the width of
horizontal scrollbar in listbox To Change Range: /did -z name id [min max] |
| -j | resets the edited setting in an editbox |
$did() identifier
The $did identifier is used to get the values or properties of a control using the following syntax:
* If used in the ON Dialog event, the name parameter is optional.
$did Properties |
|
| Property | Explanation |
| text | returns line or Nth line $did(id) == $did(id).text |
| len | returns length of line or length of Nth line |
| lines | returns number of lines |
| sel | returns Line Number of Nth selected line if N is 0, returns number of selected lines |
| seltext | returns selected text in an editbox or first selected item in a listbox |
| selstart | returns select start character in editbox line |
| selend | returns select end character in editbox line |
| edited | returns $true if text in editbox was changed |
| state | returns 0 = off, 1 = on, and 2 = indeterminate |
| next | returns id of next control in tab key order |
| prev | returns id of previous control in tab key order |
| visible | Boolean; returns $true if the control is visible, otherwise $false |
| enable | Boolean; returns $true if the control is enabled, otherwise $false |
| isid | Boolean; returns $true if id exists in the dialog, otherwise $false |
| csel | returns 0 = off, 1 = on for item in a listcb control |
Other Identifiers
; Returns the number of the line that matches wildtext.
; The N parameter is optional; N is used to indicate where to start the search.
$didreg(name,id,regex,N)
; Returns the number of the line that matches the regular expression.
; The N parameter is optional; N is used to indicate where to start the search.
$didtok(name,id,delimiter)
; Returns a tokenized list of the items in a list/combo/edit box.
/didtok name id delimiter text
; used to add a tokenized list of items to a list/combo/edit box.
Example:
Notepad clone;
/EZText to start
dialog -md EZText EZText
}
Dialog EZText {
title "Untitled - EZText"
size -1 -1 250 250
option dbu
menu "&File",1
item "&New",2
item "&Open...",3
item "&Save",4
item "Save &As...",5
item Break,6
item "Exit",7
menu "&Edit",8
item break,9
item break,10
item "Time/Date",11
edit "", 12, 2 1 246 230, autohs autovs multi return vsbar hsbar
box "", 13, 2 231 246 15
text "Example Of A 'NotePad' Clone", 14, 10 236 75 10
link "http://www.ZigWap.com/", 15, 90 236 100 10
}
on 1:dialog:EZText:menu:2:{
unset %EZTextFile
dialog -t EZText Untitled - EZText
did -r EZText 12
}
on 1:dialog:EZText:menu:3:{
set %EZTextFile " $+ $sfile($mircdir,Open,Open File) $+ "
did -r EZText 12
loadbuf -o EZText 12 %EZTextFile
dialog -t EZText $left($gettok(%EZTextFile,-1,92),$calc($len($gettok(%EZTextFile,-1,92)) -1)) - EZText
}
on 1:dialog:EZText:menu:4:{
if (!%EZTextFile) {
var %Notefilename " $+ $sfile($mircdir,Save As..,Save) $+ "
var %inc = 1
while (%inc <= $did(EZText,12).lines) {
write -l $+ %inc %Notefilename $did(EZText,12,%inc).text
inc %inc
}
set %EZTextFile %Notefilename
dialog -t EZText $left($gettok(%EZTextFile,-1,92),$calc($len($gettok(%EZTextFile,-1,92)) -1)) - EZText
}
else {
write -c %EZTextFile
var %inc = 1
while (%inc <= $did(EZText,12).lines) {
write -l $+ %inc %EZTextFile $did(EZText,12,%inc).text
inc %inc
}
}
}
on 1:dialog:EZText:menu:5: {
var %Notefilename " $+ $sfile($mircdir,Save As..,Save) $+ "
write -c %Notefilename
var %inc = 1
while (%inc <= $did(EZText,12).lines) {
write -l $+ %inc %Notefilename $did(EZText,12,%inc).text
inc %inc
}
set %EZTextFile %Notefilename
dialog -t EZText $left($gettok(%EZTextFile,-1,92),$calc($len($gettok(%EZTextFile,-1,92)) -1)) - EZText
}
on 1:dialog:EZText:menu:7:{
unset %EZTextFile
dialog -x EZText
}
on 1:dialog:EZText:close:*:{
unset %EZTextFile
}
on 1:dialog:EZText:menu:11:{
did -a EZText 12 $crlf $time(hh:nn:ss) $date
}

