1
'==============================================================
2 ' AutoSaveText Script
3
4 ' ͨ����ݼ����ô˽ű������Զ�����ѡ�е��ı���ָ���ļ�
5
6 '
-- by lifesinger April 19th,
2006
7
'==============================================================
8 Option
Explicit
9 Dim
Appending, LineSeparator, strTime, SaveFilePath, AutoOpen
10
11
12 '------------- ����������������Ը�����Ҫ����
------------->
13 Appending = True
14 ' True -- append to the end of the
file �������ӵ��ļ�ĩβ
15 ' False -- overwrite previous contents ��ͷд��������ԭ������
16
17 strTime = FormatDateTime(Date, 1)
& FormatDateTime(Now,
3)
18 ' ʱ���ʽ ȡ 1, 3 ʱ����ʽΪ
2006��4��19��18:38:02
19 LineSeparator = "-------------
���������� "
& strTime & "
���� --------------"
20 ' ��֮ǰ���ݵķָ���
21
22 SaveFilePath = "AutoSaveText.txt"
23 ' �������ݵ��ļ�·���������Ǿ���·�������·��
24
25 AutoOpen = True
26 ' True -- �����ݱ��浽�ļ�����Ĭ�ϱ༭�����ļ�
27 ' False -- ���������ݣ������ļ�
28
29 '------------------------- ���ý���
-------------------------<
30
31
32
33 '>-------- ע�⣺�������VBS���벻Ҫ������Ĵ���
-----------<
34
35 Dim
ScriptPath, fso, f, oShell, oIE, strText, strLine, i
36 Const
ForReading = 1, ForWriting = 2, ForAppending = 8
37 ScriptPath = Left(WScript.ScriptFullName,
(Len(WScript.ScriptFullName)
- Len(WScript.ScriptName)))
38
39 Set fso
= CreateObject("Scripting.FileSystemObject")
40 Set
oShell=WScript.CreateObject("WScript.Shell")
41
42 '��ѡ�е����ݸ��Ƶ�������
43 oShell.SendKeys "(^c)"
44 Set oIE
= CreateObject("InternetExplorer.Application")
45 oIE.Navigate("about:blank")
46 strText =
oIE.document.parentwindow.clipboardData.getData("text")
47 oIE.Quit
48
49
50 '������д���ļ�, ����ΪUnicode
51 If
Appending Then
52
Set f =
fso.OpenTextFile(SaveFilePath, ForAppending, True,
-1)
53 Else
54
Set f =
fso.OpenTextFile(SaveFilePath, ForWriting, True,
-1)
55 End
If
56
57 If(Len(strText)
> 0) Then
58
f.WriteLine
59
f.WriteLine
60
f.WriteLine LineSeparator
61
f.WriteLine
62
strLine = Split(strText,
vbCrLf)
63
For i =
0 to
Ubound(strLine)
64
f.Write CStr(strLine(i))
& vbCrLf
65
Next
66 Else
67
f.Write ""
68 End
If
69
70 f.Close
71
72
73 '��Ĭ�ϱ༭�����ļ�
74 If
AutoOpen Then
75
oShell.Run SaveFilePath, 5, false
76 End
If
77
78 Set
oShell = Nothing
79 WScript.Quit
80
81 '>--------------------------- SCRIPT
END ---------------------------<