#include-once ; From Nine ;~ Opt("MustDeclareVars", True) #include Global Const $CLSID_SpellCheckerFactory = "{7AB36653-1796-484B-BDFA-E74F1DB7C1DC}" Global Const $IID_ISpellCheckerFactory = "{8E018A9D-2415-4677-BF08-794EA61F94BB}" Global Const $tag_ISpellCheckerFactory = _ "get_SupportedLanguages hresult(ptr*);" & _ "IsSupported hresult(wstr;bool*);" & _ "CreateSpellChecker hresult(wstr;ptr*);" Global Const $IID_ISpellChecker = "{B6FD0B71-E2BC-4653-8D05-F197E412770B}" Global Const $tag_ISpellChecker = _ "get_LanguageTag hresult(wstr*);" & _ "Check hresult(wstr;ptr*);" & _ "Suggest hresult(wstr;ptr*);" & _ "Add hresult(wstr);" & _ "Ignore hresult(wstr);" Global Const $IID_IEnumSpellingError = "{803E3BD4-2828-4410-8290-418D1D73C762}" Global Const $tag_IEnumSpellingError = _ "Next hresult(ptr*);" If Not @Compiled And @ScriptName = "Spell Checking API.au3" Then _MSSpellCheckingAPI_Example() EndIf Func _MSSpellCheckingAPI_Example() ; initialize Spell Checking API ;~ Local $oSpell = _MSSpellCheckingAPI_CreateSpell("en-EN") ; English SetUp ;~ Local $oSpell = _MSSpellCheckingAPI_CreateSpell("fr-FR") ; French SetUp Local $oSpell = _MSSpellCheckingAPI_CreateSpell("pl-PL") ; Polish SetUp If @error Then Return SetError(@error, @extended, '') ; some words to check ;~ Local $aWord = ["Spell Checking", "Speell", "Checcking"] ; English words ;~ Local $aWord = ["Test", "EntĂȘtĂ©", "Pasd'allure"] ; French words Local $aWord = ["Sprawdzanie pisowni", "sprawdanie", "pissowni"] ; Polish words Local $bResult = False For $sWord In $aWord $bResult = _MSSpellCheckingAPI_Check($oSpell, $sWord) MsgBox((($bResult) ? ($MB_OK) : ($MB_ICONWARNING)), ($bResult ? "Correct" : "Error"), $sWord) Next EndFunc ;==>_MSSpellCheckingAPI_Example Func _MSSpellCheckingAPI_CreateSpell($tag_language = "en-EN") Local $oFactory = ObjCreateInterface($CLSID_SpellCheckerFactory, $IID_ISpellCheckerFactory, $tag_ISpellCheckerFactory) If Not IsObj($oFactory) Then If Not @Compiled Then ConsoleWrite("! Err : oFactory" & @CRLF) Return SetError(1) EndIf Local $pSpellChecker $oFactory.CreateSpellChecker($tag_language, $pSpellChecker) Local $oSpell = ObjCreateInterface($pSpellChecker, $IID_ISpellChecker, $tag_ISpellChecker) If Not IsObj($oSpell) Then If Not @Compiled Then ConsoleWrite("! Err : oSpell" & @CRLF) Return SetError(2) EndIf Return $oSpell EndFunc ;==>_MSSpellCheckingAPI_CreateSpell Func _MSSpellCheckingAPI_Check(ByRef $oSpell, $sWord) Local $pErrors, $oErrors, $iHresult $oSpell.Check($sWord, $pErrors) $oErrors = ObjCreateInterface($pErrors, $IID_IEnumSpellingError, $tag_IEnumSpellingError) If Not IsObj($oErrors) Then If Not @Compiled Then ConsoleWrite("! Err : oErrors" & @CRLF) Return SetError(3, 0, False) EndIf $iHresult = $oErrors.Next($pErrors) Return $iHresult ? True : False EndFunc ;==>_MSSpellCheckingAPI_Check Func _MSSpellCheckingAPI_CheckWord($sWord) Local Static $oSpell = _MSSpellCheckingAPI_CreateSpell("pl-PL") ; Polish SetUp Local $bResult = _MSSpellCheckingAPI_Check($oSpell, $sWord) Return SetError(@error, @extended, $bResult) EndFunc ;==>_MSSpellCheckingAPI_CheckWord