-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.html
More file actions
521 lines (502 loc) · 18.5 KB
/
shell.html
File metadata and controls
521 lines (502 loc) · 18.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../../doc/style.css" />
<title>Shell</title>
</head>
<body>
<table bgcolor="#000000" width="100%" cellspacing="0" cellpadding="0" border="0" class="tmenu">
<tr>
<td><img src="../../doc/SciTEIco.png" height="64" width="64" alt="Scintilla icon" /></td>
<td width="100%"><font size="5">Shell - Lua library for SciTE</font></td>
</tr>
</table>
<table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0" class="tmenu">
<tr><td>
<a href="../../doc/SciTEDoc.html">Documentation</a>
<a href="../../doc/SciTEFAQ.html">FAQ</a>
<a href="../../doc/SciTERegEx.html">Regular Expressions</a>
<a href="../../doc/Scintilla/ScintillaDoc.html">Scintilla</a>
<a href="../../doc/SciTELua.html">LUA</a>
<a href="../../doc/SciTEDirector.html">SciTE Director</a>
<a href="../../doc/CommandValues.html">SciTE and Scintilla Commands</a>
<a href="../../doc/SciTE-Ru_Kernel.html">SciTE-Ru Kernel</a>
Shell
<a href="../Helper/SciTE.Helper.html">SciTE Helper</a>
<a href="../../doc/Scintilla/ScintillaHistory.html">History</a>
</td></tr>
</table>
<h3>Description</h3>
<p>External Lua library expanding opportunities SciTE Lua Scripting Extension.</p>
<h3>DLL loading</h3>
<p>Before use of library functions it require load:</p>
<div class="example">
package.cpath = props["SciteDefaultHome"].."\\tools\\LuaLib\\?.dll;"..package.cpath<br />
-- show all paths on which SciTE will search for our library<br />
print(package.cpath)<br />
-- library loading<br />
require 'shell'<br />
-- test dll<br />
if shell then<br />
table.foreach(shell, print)<br />
end
</div>
<h3>Functions</h3>
<table width="100%" cellpadding="1" cellspacing="0" border="1">
<tr><td>
<p class="head">
<dfn id="msgbox">msgbox (strMessageText, [strTitle], [intOptions])</dfn>
</p>
<p>
<b>Description:</b><br />
Showing text message with buttons.<br />
<br />
<b>Parameters:</b><br />
<dfn>strMessageText</dfn> - text message<br />
<dfn>strTitle</dfn> - title text of message<br />
<dfn>intOptions</dfn> - numerical expression representing the sum of values, listed in the table.
</p>
<table style="margin-left:8pt;margin-top:3pt">
<tr><th>Value</th><th>Description</th></tr>
<tr>
<td align="center">0</td>
<td>Display OK button only (default)</td>
</tr>
<tr>
<td align="center">1</td>
<td>Display OK and Cancel buttons</td>
</tr>
<tr>
<td align="center">2</td>
<td>Display Abort, Retry, and Ignore buttons</td>
</tr>
<tr>
<td align="center">3</td>
<td>Display Yes, No, and Cancel buttons</td>
</tr>
<tr>
<td align="center">4</td>
<td>Display Yes and No buttons</td>
</tr>
<tr>
<td align="center">5</td>
<td>Display Retry and Cancel buttons</td>
</tr>
<tr>
<td align="center">16</td>
<td>Display Critical Message icon</td>
</tr>
<tr>
<td align="center">32</td>
<td>Display Question Message icon</td>
</tr>
<tr>
<td align="center">48</td>
<td>Display Exclamation Message icon</td>
</tr>
<tr>
<td align="center">64</td>
<td>Display Information Message icon</td>
</tr>
<tr>
<td align="center">0</td>
<td>First button is the default</td>
</tr>
<tr>
<td align="center">256</td>
<td>Second button is the default</td>
</tr>
<tr>
<td align="center">512</td>
<td>Third button is the default</td>
</tr>
<tr>
<td align="center">768</td>
<td>Fourth button is the default</td>
</tr>
<tr>
<td align="center">0</td>
<td>Application modal. The user must respond to the message box before continuing work in the current application.</td>
</tr>
<tr>
<td align="center">4096</td>
<td>System modal. On Win16 systems, all applications are suspended until the user responds to the message box. On Win32 systems, this constant provides an application modal message box that always remains on top of any other programs you may have running.</td>
</tr>
</table>
<br />
<p>
<b>Return value:</b><br />
Returned code to identify which button a user has selected. Values are listed in the table:
</p>
<table style="margin-left:8pt;margin-top:3pt">
<tr><th>Value</th><th>Description</th></tr>
<tr>
<td align="center">1</td>
<td>OK button was clicked</td>
</tr>
<tr>
<td align="center">2</td>
<td>Cancel button was clicked</td>
</tr>
<tr>
<td align="center">3</td>
<td>Abort button was clicked</td>
</tr>
<tr>
<td align="center">4</td>
<td>Retry button was clicked</td>
</tr>
<tr>
<td align="center">5</td>
<td>Ignore button was clicked</td>
</tr>
<tr>
<td align="center">6</td>
<td>Yes button was clicked</td>
</tr>
<tr>
<td align="center">7</td>
<td>No button was clicked</td>
</tr>
</table>
<p><b>Example:</b></p>
<div class="example">
if shell.msgbox("You are sure?", "SciTE", 65) == 1 then<br />
print("Yes")<br />
end<br />
</div>
<p class="author">Authors: Midas, mimir</p>
</td></tr>
<tr><td>
<p class="head">
<dfn id="inputbox">inputbox(strCaptionText, strPrompt, strDefaultValue, funcCheckInput, intMinWidth)</dfn>
</p>
<p>
<b>Description:</b><br />
Display dialog box for input some text value.<br />
<br />
<b>Parameters:</b><br />
<dfn>strCaptionText</dfn> - the title for the dialog box. The default is <var>"InputBox"</var>.<br />
<dfn>strPrompt</dfn> - the message to be displayed above an edit field. The default is <var>"Enter"</var>.<br />
<dfn>strDefaultValue</dfn> - text to be displayed in the edit field. Defaults to <var>""</var> (the empty string).<br />
<dfn>funcCheckInput</dfn> - the input-checking function. It gets the text from the edit field together with the newly received char and must return either <var>true</var> (to accept this char) or <var>false</var> (to reject it). Default value is <var>nil</var> (it means no restrictions).<br />
<dfn>intMinWidth</dfn> - the minimal width of the edit field in average chars. The default is <var>20</var>. <b>Note</b>. The dialog box automatically changes its width to accommodate the widest field of the <var>strPrompt</var> and <var>strDefaultValue</var> ones if value proposed by the intMinWidth is not enough.<br />
<br />
<b>Return value:</b><br />
a string value which is entered by user. <var>nil</var> means that user input was cancelled.<br />
</p>
<p><b>Example:</b></p>
<div class="example">
print(shell.inputbox("Rename", "Enter new file name:", "filename.ext", function(name) return not name:match('[\\/:|*?"<>]') end))
</div>
<p class="author">Author: qVaclav</p>
</td></tr>
<tr><td>
<p class="head">
<dfn id="getfileattr">getfileattr (strFileName)</dfn>
</p>
<p>
<b>Description:</b><br />
Get file attributes.<br />
<br />
<b>Parameters:</b><br />
<dfn>strFileName</dfn> - filename<br />
<br />
<b>Return value:</b><br />
contains file attributes as number<br />
</p>
<p><b>Example:</b></p>
<div class="example">
local attr = shell.getfileattr("c:\\MSDOS.SYS")<br />
print(attr)
</div>
<p class="author">Authors: Midas, Dmitry Maslov</p>
</td></tr>
<tr><td>
<p class="head">
<dfn id="setfileattr">setfileattr (strFileName, intFileAttr)</dfn>
</p>
<p>
<b>Description:</b><br />
Set file attributes.<br />
<br />
<b>Parameters:</b><br />
<dfn>strFileName</dfn> - filename<br />
<dfn>iFileAttr</dfn> - file attributes as number<br />
<br />
<b>Return value:</b><br />
contains <var>true</var> (at successful end) or <var>false</var> (at failure)<br />
</p>
<p><b>Example:</b></p>
<div class="example">
local result = shell.setfileattr("c:\\MSDOS.SYS", 32)<br />
if result == true then<br />
print("File attributes are successfully established")<br />
else<br />
print("error")<br />
end
</div>
<p class="author">Authors: Midas, Dmitry Maslov</p>
</td></tr>
<tr><td>
<p class="head">
<dfn id="fileexists">fileexists (strFileName)</dfn>
</p>
<p>
<b>Description:</b><br />
Check exist file or folder with specified name.<br />
<br />
<b>Parameters:</b><br />
<dfn>strFileName</dfn> - filename or folder name<br />
<br />
<b>Return value:</b><br />
contains <var>true</var> if file (folder) exist or <var>false</var> otherwise<br />
</p>
<p><b>Example:</b></p>
<div class="example">
local result = shell.fileexists("c:\\MSDOS.SYS")<br />
if result then<br />
print("File exist")<br />
else<br />
print("File not found")<br />
end
</div>
<p class="author">Author: VladVRO</p>
</td></tr>
<tr><td>
<p class="head">
<dfn id="exec">exec (strCommand, [strOperation], [boolNoShow], [bWaitOnReturn])</dfn>
</p>
<p>
<b>Description:</b><br />
Run external programm or open file with associate application. Allows to execute files, documents and links and to open folders in Windows Explorer.<br />
<br />
<b>Parameters:</b><br />
<dfn>strCommand</dfn> - filename or folder with possible startup parameters. Can contain <span class="nobr">%environments_variable%</span><br />
<dfn>strOperation</dfn> - executed operation from listed in the table:<br />
</p>
<table style="margin-left:8pt;margin-top:3pt">
<tr><th>Operation</th><th>Description</th></tr>
<tr>
<td align="center">open</td>
<td>Open. strCommand - filename or folder name (default)</td>
</tr>
<tr>
<td align="center">edit</td>
<td>Edit. Opens a file for editing. strCommand should be the document.</td>
</tr>
<tr>
<td align="center">print</td>
<td>Print. strCommand should be the document.</td>
</tr>
<tr>
<td align="center">explore</td>
<td>Opens a folder in Explorer window (with two panels). strCommand - file or folder</td>
</tr>
<tr>
<td align="center">select</td>
<td>Opens a folder in Explorer window and chooses the specified folder or a file. strCommand - file or folder</td>
</tr>
<tr>
<td align="center">find</td>
<td>Showing a dialog box "File Search". strCommand should specify a folder path from which search will begin</td>
</tr>
<tr>
<td align="center">properties</td>
<td>Showing file|folder "Properties" window. strCommand - file or folder</td>
</tr>
<tr>
<td align="center">other</td>
<td>Other operation available in context menu of a file. For example "Play" operation available for media files.</td>
</tr>
</table>
<p>
<dfn>boolNoShow</dfn> - <var>true</var> | <var>false</var> (default) - silent or show a window of the started program<br />
<dfn>bWaitOnReturn</dfn> - <var>true</var> | <var>false</var> (default) - boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script
<br />
<br />
<b>Return value:</b><br />
The first contains<br />
- at successful end: <var>true</var> or (if function has been started with parameter <var>bWaitOnReturn = true</var>), exit code of process<br />
- at failure: <var>false</var><br />
The second value contains error/success message of operation;<br />
or contains the output text of the console application (if execute console applications with parameters <var>boolNoShow = true</var> and <var>bWaitOnReturn = true</var>)
</p>
<p><b>Example:</b></p>
<div class="example">
-- run application<br />
shell.exec("clipbrd.exe")<br />
shell.exec("CMD /c IPCONFIG /all > out.txt", nil, true, false)<br />
<br />
-- show result of console application<br />
print( shell.exec("CMD /c DIR", nil, true, true) )<br />
print( shell.exec("cscript /nologo %WINDIR%\\system32\\eventquery.vbs /?", nil, true, true) )<br />
<br />
-- analysis of the exit code of process<br />
if shell.exec("ping -n 1 localhost", nil, true, true) == 0 then<br />
print("Network works") else print("Network does not work")<br />
end<br />
<br />
-- open folder<br />
shell.exec("%TEMP%")<br />
shell.exec("%USERPROFILE%", "find")<br />
shell.exec("%WINDIR%\\regedit.exe", "explore")<br />
shell.exec("%ProgramFiles%", "properties")<br />
shell.exec("%ComSpec%", "select")<br />
<br />
-- open URL link<br />
shell.exec("http://scite-ru.org/")<br />
<br />
-- send e-mail<br />
shell.exec("mailto:support@gmail.com")<br />
<br />
-- open file (with associate application)<br />
shell.exec("%WINDIR%\\WindowsUpdate.log")<br />
<br />
-- print file<br />
shell.exec("%WINDIR%\\win.ini", "print")<br />
<br />
-- edit file<br />
shell.exec("%WINDIR%\\winnt.bmp", "edit")
</div>
<p class="author">Authors: Dmitry Maslov</p>
</td></tr>
<tr><td>
<p class="head">
<dfn id="findfiles">findfiles (strFindMask)</dfn>
</p>
<p>
<b>Description:</b><br />
Searches for files and folders with mask and returned result as the table.<br />
<br />
<b>Parameters:</b><br />
<dfn>strFindMask</dfn> - file or folder name, or mask with wildcard symbol, which replaces one or several symbols: (<var>?</var>) can present any single symbol; (<var>*</var>) it is used for present of any symbol or group of symbols.<br />
<br />
<b>Return value:</b><br />
Returns the list of the found files and folders as the numbered table (numbering begins with <var>1</var>), where<br />
each element is structure containing:
</p>
<table style="margin-left:8pt;margin-top:3pt;margin-bottom:3pt">
<tr><th>Value</th><th>Description</th></tr>
<tr>
<td align="left">name</td>
<td>name of a folder or file</td>
</tr>
<tr>
<td align="left">isdirectory</td>
<td>attribute a file it or a folder (<var>true</var> if a folder, <var>false</var> if a file)</td>
</tr>
<tr>
<td align="left">attributes</td>
<td>attributes (see lower)</td>
</tr>
<tr>
<td align="left">size</td>
<td>size of a file in bytes</td>
</tr>
</table>
<p>
Attributes are submitted as number which can be a combination of the following values:
</p>
<table style="margin-left:8pt;margin-top:3pt;margin-right:8pt">
<tr><th>Value</th><th>Description</th></tr>
<tr>
<td>0x00000001</td>
<td>A file or directory that is read-only. For a file, applications can read the file but cannot write to it or delete it. For a directory, applications cannot delete it, but applications can create and delete files from that directory.</td>
</tr>
<tr>
<td>0x00000002</td>
<td>A file or directory that is hidden. Files and directories marked with this attribute do not appear in an ordinary directory listing.</td>
</tr>
<tr>
<td>0x00000004</td>
<td>A file or directory that the operating system uses a part of or uses exclusively.</td>
</tr>
<tr>
<td>0x00000010</td>
<td>This item is a directory.</td>
</tr>
<tr>
<td>0x00000020</td>
<td>A file or directory that needs to be archived. Applications use this attribute to mark files for backup or removal.</td>
</tr>
<tr>
<td>0x00000080</td>
<td>A file or directory that does not have other attributes set.</td>
</tr>
<tr>
<td>0x00000100</td>
<td>A file that is being used for temporary storage. The operating system may choose to store this file's data in memory rather than on mass storage, writing the data to mass storage only if data remains in the file when the file is closed.</td>
</tr>
<tr>
<td>0x00000200</td>
<td>A file that is a sparse file.</td>
</tr>
<tr>
<td>0x00000400</td>
<td>A file or directory that has an associated reparse point.</td>
</tr>
<tr>
<td>0x00000800</td>
<td>A file or directory that is compressed. For a file, all of the data in the file is compressed. For a directory, compression is the default for newly created files and subdirectories.</td>
</tr>
<tr>
<td>0x00001000</td>
<td>The data in this file is not available immediately. This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is hierarchical storage management software.</td>
</tr>
<tr>
<td>0x00002000</td>
<td>A file or directory that is not indexed by the content indexing service.</td>
</tr>
<tr>
<td>0x00004000</td>
<td>A file or directory that is encrypted. For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.</td>
</tr>
<tr>
<td>0x00010000</td>
<td>This file virtual.</td>
</tr>
</table>
<p>
At failure return <var>nil</var>
</p>
<p><b>Example:</b></p>
<div class="example">
local t = shell.findfiles("C:\\*")<br />
if t then<br />
table.sort(t,<br />
function(v1,v2)<br />
if v1.isdirectory ~= v2.isdirectory then<br />
return v1.isdirectory<br />
else<br />
return v1.name:lower() < v2.name:lower()<br />
end<br />
end<br />
)<br />
table.foreachi(t,<br />
function(i,v)<br />
if v.isdirectory then<br />
print(string.format("D%5x %s", v.attributes, v.name))<br />
else<br />
print(string.format(" %5x %-30s", v.attributes, v.name), v.size)<br />
end<br />
end<br />
)<br />
else<br />
print("not found")<br />
end<br />
</div>
<p class="author">Author: VladVRO</p>
</td></tr>
</table>
<h3>Download</h3>
<p><u>Current version Shell</u>: <var>1.2</var><br /></p>
<p>
<a href="http://scite-ru.googlecode.com/svn/trunk/pack/tools/LuaLib/shell.dll">shell.dll</a><br />
<a href="http://scite-ru.googlecode.com/svn/trunk/lualib/shell/">Source code</a>
</p>
</body>
</html>