;Это всего лиш тист
Global $WordObjErr
Global $ReadLangVal = "Rus"
Switch $ReadLangVal
Case "Eng"
$LangVal = "1033"
Case "Rus"
$LangVal = "1049"
Case "Ukr"
$LangVal = "1058"
Case "Bel"
$LangVal = "1059"
EndSwitch
$OldClip = ClipGet()
ClipPut("")
Send("^{INSERT}")
Sleep(500)
$ClipContent = ClipGet()
If $ClipContent <> "" Then
$BeginSpace = _StringGetSpace($ClipContent, 1)
$EndSpace = _StringGetSpace($ClipContent, -1)
TrayTip('Running SpellCheck for', StringLeft($ClipContent, 30) & "...", 5)
_SpellCheckProc($LangVal)
If Not @error Then
$sResults = StringStripWS(ClipGet(), 3)
If $sResults <> StringStripWS($ClipContent, 3) Then
$sResults = $BeginSpace & $sResults & $EndSpace
ClipPut($sResults)
Send("+{INSERT}")
TrayTip('SpellCheck', 'Text updated.', 4)
Else
TrayTip('SpellCheck', 'Text ok, no updates.', 4)
EndIf
Else
MsgBox(16, "ERROR", "There was an error to create Word Object" & @LF & @LF & "OK ---> EXIT")
EndIf
Sleep(2000) ;Just wait to show the results
Else
MsgBox(48, "Error", "There is no text Selected", 3)
EndIf
ClipPut($OldClip)
Func _SpellCheckProc($Language)
Local $Code = ""
$Code &= 'On error resume next' & @CRLF
$Code &= 'CheckSpell()' & @CRLF
$Code &= 'Function CheckSpell()' & @CRLF
$Code &= ' Set Word = CreateObject("word.Application")' & @CRLF
$Code &= ' Word.WindowState = 2' & @CRLF
$Code &= ' Word.Visible = False' & @CRLF
$Code &= ' Set Doc = Word.Documents.Add( , , 1, True)' & @CRLF
$Code &= ' Word.Selection.Paste' & @CRLF
$Code &= ' If err = 0 Then' & @CRLF
$Code &= ' Word.Selection.LanguageID = ' & $Language & @CRLF
$Code &= ' Set Range = Word.ActiveDocument.Range(0, Word.Selection.End)' & @CRLF
$Code &= ' If Not Word.CheckSpelling(Range) Or Not Word.CheckGrammar(Range) Then' & @CRLF
$Code &= ' If Err.Number = 0 Then' & @CRLF
$Code &= ' Doc.CheckGrammar' & @CRLF
$Code &= ' Else' & @CRLF
$Code &= ' Doc.CheckSpelling' & @CRLF
$Code &= ' End If' & @CRLF
$Code &= ' End If' & @CRLF
$Code &= ' Word.Selection.WholeStory' & @CRLF
$Code &= ' Word.Selection.Copy' & @CRLF
$Code &= ' End If' & @CRLF
$Code &= ' Doc.Close False' & @CRLF
$Code &= ' Word.Application.Quit True' & @CRLF
$Code &= 'End Function' & @CRLF
$WordObjErr = ObjEvent("AutoIt.Error", "_SpellCheckErrFunc")
Local $VbsObj = ObjCreate("ScriptControl")
If @error Then Return SetError(1, 0, -1)
$VbsObj.Language = "vbscript"
$VbsObj.AddCode($Code)
EndFunc ;==>_SpellCheckProc
Func _StringGetSpace($sString, $iBeginEnd=1)
Local $TrimSpace = StringStripWS($sString, 1)
Local $RetSpace = StringLeft($sString, StringLen($sString) - StringLen($TrimSpace))
If $iBeginEnd = -1 Then
$TrimSpace = StringStripWS($sString, 2)
$RetSpace = StringRight($sString, StringLen($sString) - StringLen($TrimSpace))
EndIf
Return $RetSpace
EndFunc ;==>__StringGetSpace
Func _SpellCheckErrFunc()
MsgBox(262144+48, "_SpellCheckErrFunc", _
"There was an error to handle Word COM Object." & @LF & @LF & _
"Error description: " & $WordObjErr.Description)
EndFunc ;==>_SpellCheckErrFunc