-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpellCheck.hta
108 lines (85 loc) · 3.37 KB
/
SpellCheck.hta
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
<html>
<head>
<title>Spell Check via ASpell</title>
<HTA:APPLICATION
APPLICATIONNAME="Spell Check"
SCROLL="no"
>
</head>
<script language="VBScript">
Sub Window_OnLoad
'Change WindowSize
Self.ResizeTo 300,280
End Sub
Sub Reset
Location.Reload(true)
End Sub
Sub Check
strInput = input.value
if strInput = "" then Exit Sub 'exit if Null input
'______________Run ASpell_______
set objShell = createobject("wscript.shell") 'create the shell object
strAspell = """c:\program files\aspell\bin\aspell.exe"" -a" 'path to run Aspell in Ispell pipe mode
'msgbox strAspell
strCall = "echo " & strInput & " | " & strAspell 'this string sends the input word to Aspell
set objAspell = objShell.exec ("%ComSpec% /c" & strCall) 'create the Aspell object
strCorrList = "" 'clear and declare the Correction List
do until objAspell.stdout.AtEndOfStream
strLine = objAspell.stdout.readline 'place first line returned into variable
if instr(strLine,":") <> 0 then 'if the line contains a colon...
'Note: Aspell returned list of corrections appear to the right of the colon
strCorrList = strLine
Else If instr(strLine,"*") <> 0 then strCorrList = strLine 'if the line contains an astris
End If
Loop
'______________Format & Return list____
ClearListBox 'clear contents of listbox
'if astris was returned then input was correct, send input back as correction
If strCorrList = "*" then
Set objOption = Document.createElement("OPTION")
objOption.Text = strInput
objOption.Value = strInput
Corrections.Add(objOption)
exit sub
end if
'...otherwise do the following:
strCorrList = Right(strCorrList, Len(strCorrList)-instr(strCorrList,":") ) 'return any characters to the right of colon
arrCorrList = strCorrList 'copy list to array variant
arrCorrList = Split(arrCorrList,",") 'creates array of values by splitting at comma
For each correction in arrCorrList
arrCorrList(i) = trim(correction) 'remove spaces on either side of text
'place corrections in listbox
Set objOption = Document.createElement("OPTION")
objOption.Text = correction
objOption.Value = correction
Corrections.Add(objOption)
Next
End Sub
Sub CopyToClipboard
strCopy = Corrections.Value
strCopy = Trim(strCopy) & " "
document.parentwindow.clipboardData.SetData "text", strCopy
End Sub
Sub ClearListbox
Corrections.disabled = false
listboxDescription.innerHTML = ""
For Each objOption in Corrections.Options
objOption.RemoveNode
Next
End Sub
Sub About
msgbox "Frontend for Aspell - A free and open source spell checker" & vbcrlf &_
"visit http://aspell.net for more info." & vbcrlf &_
vbcrlf & "github.com/davenport651" & vbtab &_
"4/24/2008",,"Spell Check via Aspell, Version 2"
End Sub
</script>
<body style="font-family: Arial,Helvetica,sans-serif">
<p>Text to check: <input type="text" name="input" title="Type a word to be spell checked."></p>
<p>Corrected to: <span id="listboxDescription"><small>Corrections will appear below</small></span><br>
<blockquote><p><select width=50 size="5" name="Corrections" onChange="CopyToClipboard" disabled="disabled" title="Click a word to copy it to clipboard"></select></p></blockquote>
</p>
<p><button onclick="Reset">Reset</button>   <button onclick="Check">Check Spelling</button>
  <button onclick="About">About</button></p>
</body>
</html>