-------------------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2017/01/22 14:05 +1100
# dMod: 2017/01/21 21:34 -0600
# Appl: macOS System
# Task: Toggle learned-status of a given word in the Apple system dictionary.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Toggle, @Learned-Status, @Word, @System, @Spelling, @Dictionary
-------------------------------------------------------------------------------------------
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit" -- for NSSpellChecker
use scripting additions
-------------------------------------------------------------------------------------------
set theWord to "goofilicious"
set theChecker to current application's NSSpellChecker's sharedSpellChecker()
set knewIt to theChecker's hasLearnedWord:theWord
if knewIt = false then
theChecker's learnWord:theWord
else
theChecker's unlearnWord:theWord
end if
set knowsItNow to theChecker's hasLearnedWord:theWord
return {knewIt, knowsItNow}
-------------------------------------------------------------------------------------------
Add a word:
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2017/01/22 14:05 +1100
# dMod: 2017/01/21 21:34 -0600
# Appl: macOS System
# Task: Add a Word to the macOS System Spelling Dictionary.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Add, @Word, @macOS, @System, @Spelling, @Dictionary
-------------------------------------------------------------------------------------------
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit" -- for NSSpellChecker
use scripting additions
-------------------------------------------------------------------------------------------
set theWord to "goofilicious"
set theChecker to current application's NSSpellChecker's sharedSpellChecker()
set knewIt to theChecker's hasLearnedWord:theWord
if knewIt = false then
theChecker's learnWord:theWord
set knowsItNow to theChecker's hasLearnedWord:theWord
return {knewIt, knowsItNow}
end if
-------------------------------------------------------------------------------------------
Remove a word:
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2017/01/22 14:05 +1100
# dMod: 2017/01/21 21:34 -0600
# Appl: macOS System
# Task: Remove a Word from the macOS System Spelling Dictionary.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Remove, @Word, @macOS, @System, @Spelling, @Dictionary
-------------------------------------------------------------------------------------------
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit" -- for NSSpellChecker
use scripting additions
-------------------------------------------------------------------------------------------
set theWord to "goofilicious"
set theChecker to current application's NSSpellChecker's sharedSpellChecker()
set knewIt to theChecker's hasLearnedWord:theWord
if knewIt = true then
theChecker's unlearnWord:theWord
set knowsItNow to theChecker's hasLearnedWord:theWord
return {knewIt, knowsItNow}
end if
-------------------------------------------------------------------------------------------