· 8 years ago · Dec 11, 2017, 11:40 AM
1
2
3Dialogs
4
5
6
7mIRC allows you to create custom Dialogs which can be used to request input from a user, or to perform many other useful tasks.
8
9
10
11There are two types of dialog; a modeless dialog, created with the /dialog command, and a modal dialog, created with the $dialog() identifier. Both are described below.
12
13
14
15The /dialog command
16
17The /dialog command allows you to create a modeless dialog with the -m switch. This type of dialog doesn't halt or return a value to the calling script, and the dialog can be displayed indefinitely and used for many purposes.
18
19
20
21 /dialog -mdtsonkcvie <name> [table] [x y w h] [text]
22
23
24
25 -m create a modeless dialog using 'table'
26
27 /dialog -m name table
28
29
30
31 -a used with -m, uses currently active window as the parent
32
33
34
35 -x close a dialog without triggering any events
36
37
38
39 -d open dialog on the desktop, used with -m
40
41
42
43 -h make dialog work with active server connection
44
45
46
47 -t set dialog title
48
49 /dialog -t name text
50
51
52
53 -s set dialog size/pos
54
55 /dialog -s name x y w h
56
57 -r centers dialog
58
59 -bp interprets size as dbu or pixels
60
61
62
63 -o set dialog ontop of all windows
64
65 -n unset ontop setting
66
67
68
69 -k click ok button
70
71 -c click cancel button
72
73
74
75 -v makes the dialog the active window
76
77
78
79 -ie minimize/restore the dialog if created on the desktop
80
81
82
83 -g renames existing dialog using <name> <newname>
84
85
86
87Where name is the name by which you'll refer to the dialog, and table is the dialog table name used to create dialog (see below).
88
89
90
91The $dialog() identifier
92
93Dialogs created with $dialog() are modal, ie. they halt the script until the dialog is closed, they return a value, and they don't allow access to other windows while the dialog is open. These types of dialogs should only be displayed for immediate user input. The $dialog() identifier works the same way as other identifiers:
94
95
96
97 %result = $dialog(name,table[,parent])
98
99
100
101Where name is the name by which you'll refer to the dialog, table is the dialog table name used to create dialog (see below), and parent is the parent window of the dialog, this can be a window name, or -1 = Desktop window, -2 = Main mIRC window, -3 = Currently active window, -4 = Currently active dialog, if no dialog is open, defaults to -3 behaviour.
102
103
104
105Note: This type of dialog cannot be called from a remote script event.
106
107
108
109You can also use the $dialog(name/N) identifier to list any open dialogs, where N returns the Nth open dialog. If N is zero, the total number of open dialogs is returned.
110
111
112
113$dialog() also supports these properties:
114
115
116
117x,y,w,h returns the size and position of the dialog
118
119cw,ch returns width and height of client area of dialog
120
121title returns the title of the dialog
122
123modal returns $true if the dialog is modal, otherwise $false
124
125table returns the dialog table that the dialog is using
126
127ok returns the id of the Ok button if you specified one
128
129cancel returns the id of the Cancel button if you specified one
130
131result returns the id of the Result button if you specified one
132
133focus returns id of control that currently has focus
134
135tab returns id of tab that is currently displayed
136
137active returns $true if dialog is the active window, otherwise $false
138
139hwnd returns dialog window handle
140
141
142
143The dialog table
144
145You can use the dialog prefix to create a dialog table called name in a script using this format:
146
147
148
149dialog [-l] name {
150
151 title "text"
152
153 icon filename, index
154
155 size x y w h
156
157 option type (dbu, pixels, notheme)
158
159
160
161 text "text", id, x y w h, style (right, center, nowrap)
162
163 edit "text", id, x y w h, style (right, center, multi, pass, read, return, hsbar, vsbar, autohs, autovs, limit N, rich)
164
165 button "text", id, x y w h, style (default, ok, cancel, flat, multi)
166
167 check "text", id, x y w h, style (left, push, 3state)
168
169 radio "text", id, x y w h, style (left, push)
170
171 box "text", id, x y w h, style
172
173 scroll "text", id, x y w h, style (top left bottom right horizontal range N N)
174
175
176
177 list id, x y w h, style (sort, extsel, multsel, size, vsbar, hsbar, check, radio)
178
179 combo id, x y w h, style (sort, edit, drop, size, vsbar, hsbar)
180
181
182
183 icon id, x y w h, filename, index, style (noborder top left bottom right small large actual)
184
185
186
187 link "text", id, x y w h
188
189
190
191 tab "text", id, x y w h
192
193 tab "text", id
194
195
196
197 menu "text", menuid [, menuid]
198
199 item "text", id [, menuid]
200
201 item break, id [, menuid]
202
203}
204
205
206
207The -l switch makes a dialog table local, so that it can only be accessed by other scripts in the same file.
208
209
210
211Where "text" is the default text for a control, id is a number that uniquely identifies a control, x y w h are the position and size of the control, and style consists of a combination of the words in brackets.
212
213
214
215Other Styles
216
217In addition to the styles shown in brackets for each type of control, you can also specify these styles:
218
219
220
221disable disables the control
222
223hide hides the control
224
225group start of a group
226
227result identifies the control whose value will be used as the return value to the calling script when the user presses the ok button
228
229
230
231Variables
232
233If you specify a %variable name in a dialog item definition, the %variable will be set with the contents of that item when the dialog is closed.
234
235
236
237edit "", 2, 10 10 100 20, autohs %result
238
239
240
241Tab control
242
243The first tab definition specifies the size of the tab control, and any following tab definitions add tabs to it. You can associate controls with a specific tab by using the tab style followed by the id value for a tab, as shown in the example below.
244
245
246
247dialog test {
248
249 title "mIRC"
250
251 size -1 -1 110 100
252
253 option dbu
254
255
256
257 tab "m", 1, 5 5 100 90
258
259 tab "I", 2
260
261 tab "R", 3
262
263 tab "C", 4
264
265
266
267 button "m is for ... ;)", 11, 30 50 50 24, ok tab 1
268
269 button "I is for Internet", 12, 30 50 50 24, tab 2
270
271 button "R is for Relay", 13, 30 50 50 24, tab 3
272
273 button "C is for Chat", 14, 30 50 50 24, tab 4
274
275}
276
277
278
279You can use /did -fu to set the focus on a specific tab, and /did -vh to show/hide the entire tab control.
280
281
282
283Menus
284
285You can add menus and submenus to custom dialogs using the menu and item prefixes:
286
287
288
289dialog name {
290
291 menu "text", <menuid> [, menuid]
292
293 item "text", <id> [, menuid]
294
295 item break, <id> [, menuid]
296
297}
298
299
300
301If you don't specify a menuid for an item, it will use the last menuid that was created/used in a previous menu/item.
302
303
304
305For example, the following menu definition reproduces the File menu of the mIRC Editor dialog:
306
307
308
309dialog test {
310
311 title "mIRC"
312
313 size -1 -1 110 100
314
315 option dbu
316
317
318
319 menu "&File", 60
320
321 item "&New", 70
322
323
324
325 menu "&Load", 80, 60
326
327 item "&Script", 90
328
329 item break, 100
330
331 item "&Users", 110
332
333 item "&Variables", 120
334
335
336
337 item "&Unload", 130, 60
338
339
340
341 item break, 140
342
343
344
345 item "&Save", 150
346
347 item "&Save As...", 160
348
349 item "Save &All", 170
350
351
352
353 item break, 180
354
355
356
357 item "Save && &exit", 190, ok
358
359 item "&Cancel", 200, cancel
360
361}
362
363
364
365You can use the /did command (described below) to enable/disable, check/uncheck, append, delete, insert, and overwrite a menu item.
366
367
368
369To add an item to a menu you can use: /did -a name <menuid> <newid> <text>.
370
371
372
373To insert an item you must use: /did -i name <id> <newid> <text> where <id> is the item before which you want to insert an item.
374
375
376
377Dbu vs. Pixels
378
379The dbu option makes mIRC use dialog base units when creating the dialog, this ensures that the dialog will look the same for all users under any size display, etc. Pixels is the default however to maintain compatibility with previous scripts.
380
381
382
383The identifiers $dbuw and $dbuh return the dbu per pixel width and height values for the current display. This may or may not be an integer value.
384
385
386
387Ok and Cancel buttons
388
389You can specify an ok and/or cancel button, and when a user clicks the ok or cancel buttons, the dialog is closed. You can prevent the dialog from closing if a user clicks the ok button by using /halt.
390
391
392
393Default position and size
394
395If you specify -1 for any of the x y w h values in the size setting for the dialog, a default setting is used. To make mIRC center the dialog in a window, specify x y as -1 -1. The size setting can be over-ridden in the init event (see below) by using /dialog -s name x y w h.
396
397
398
399The On Dialog event
400
401If a user changes the state of controls in the dialog, eg. clicks on a button, types text in an edit box, etc., this triggers the on dialog script event which allows you to monitor input from the user:
402
403
404
405on 1:dialog:name:event:id: {
406
407 echo $dname $devent $did
408
409}
410
411
412
413Where name identifies the dialog, id is the id number of the control triggering the event, and event can be:
414
415
416
417init just before a dialog is displayed, controls can be initialized in this event. id is zero.
418
419close when a dialog is closed.
420
421edit text in editbox or combo box changed.
422
423sclick single click in list/combo box, or check/uncheck of radio/check buttons, or click of a button.
424
425dclick double click in list/combo box.
426
427menu a menu item was selected.
428
429scroll scroll control position has changed.
430
431
432
433You can specify multiple ids by using commas and dashes, eg. 1-3,5,7,9,15-20.
434
435
436
437You can also detect mouse events that aren't associated with a specific control:
438
439
440
441mouse mouse moved
442
443sclick left button down
444
445uclick left button up
446
447dclick double click
448
449rclick right button click
450
451drop drop click
452
453
454
455You can use $mouse to retrieve the current mouse position.
456
457
458
459The /did command
460
461The /did command allows you to modify the values of controls in a dialog, eg. changing the text in an edit control, or setting focus to a button, or deleting lines in a listbox.
462
463
464
465 /did -ftebvhnmcukradiogjsl name id [n] [text | filename]
466
467
468
469 -f set focus on id
470
471 -t set id as default button
472
473
474
475 -e enable id
476
477 -b disable id
478
479 -v make id visible
480
481 -h hide id
482
483
484
485 -n enables editbox
486
487 -m disables editbox
488
489
490
491 -c check checkbox/radiobutton list/combo line
492
493 -u uncheck checkbox/radiobutton list/combo line
494
495 -k works with -cu, keeps other selections in a listbox
496
497
498
499 -s checks the checkbox of an item in a listcb control
500
501 -l unchecks the checkbox of an item in a listcb control
502
503
504
505 -r clear all text in id
506
507 -a add line of text to end
508
509 -d delete Nth line
510
511 -i insert text at Nth line
512
513 -o overwrite Nth line with text
514
515
516
517 -g set a new icon/bmp to an icon control
518
519 /did -g name id [n] filename
520
521
522
523 -z resets the width of horizontal scrollbar in listbox
524
525
526
527 -j resets the edited setting in an editbox
528
529
530
531Where name identifies the dialog and id is the id number of the control you want to modify.
532
533
534
535If you want to modify several controls at the same time, you can specify multiple id numbers separated by commas, eg. /did -b name 2,12-16,20 etc.
536
537
538
539You can select a range of text in an editbox using /did -c name id [n] [start [end]]. This selects line N in editbox, and sets selection to specified range of characters.
540
541
542
543You can mark a 3state checkbox as indeterminate by specifying both -cu switches.
544
545
546
547You can access the edit control in a combobox by using 0 as the N value.
548
549
550
551To change the range of a scrollbar control, you can use /did -z name id [min max].
552
553
554
555$did(name,id)
556
557You can get the settings and values of controls in a dialog by using the $did() dialog id identifier with the following formats and properties as appropriate to the control to which you are referring.
558
559
560
561$did(name,id)
562
563$did(name,id,N)
564
565
566
567If used in the on dialog event, name is optional.
568
569
570
571The following $did() properties are supported:
572
573
574
575text returns line or Nth line
576
577 $did(id) is same as $did(id).text
578
579len returns length of line or length of Nth line
580
581lines returns number of lines
582
583sel returns Line Number of Nth selected line
584
585 if N is 0, returns number of selected lines
586
587seltext returns selected text in an editbox or first selected item in a listbox
588
589selstart returns select start character in editbox line
590
591selend returns select end character in editbox line
592
593edited returns $true if text in editbox was changed
594
595state returns 0 = off, 1 = on, and 2 = indeterminate
596
597next returns id of next control in tab key order
598
599prev returns id of previous control in tab key order
600
601visible returns $true if the control is visible, otherwise $false
602
603enabled returns $true if the control is enabled, otherwise $false
604
605isid returns $true if id exists in the dialog, otherwise $false
606
607csel returns line number of Nth checked box in a listcb control
608
609 if N is 0, returns number of checked lines
610
611cstate returns 0 = off, 1 = on for item in a listcb control
612
613
614
615You can access the edit control in a combobox by using 0 as the N value.
616
617
618
619$didwm(name,id,wildtext,N)
620
621Returns the number of the line that matches wildtext, with the search starting at line N. N is optional.
622
623
624
625$didreg(name,id,regex,N)
626
627Returns the number of the line that matches the regular expression, with the search starting at line N. N is optional.
628
629
630
631$didtok(name,id,C)
632
633Returns a tokenized list of the items in a list/combo/edit box.
634
635
636
637You can use /didtok name id C text to add a tokenized list of items to a list/combo/edit box.