Search code examples
macosapplescriptvoiceover

Enabling VoiceOver in macOS Sierra using AppleScript is not working


I am trying to enable VoiceOver in macOS Sierra using AppleScript. I don't see any error, it is just not getting opened.

Here is the script I am using, which has worked well on all other version of macOS I have tried it on.

tell application id "com.apple.systemevents" to key code 96 using command down

Solution

  • The following example AppleScript code is coded to assume that VoiceOver has never been turned on and that one does not want to see the standard dialog box that shows the first time VoiceOver is turned on, or again thereafter.

    Note that this makes use of the single line of code presented in the other answer, which I do not consider a complete answer, however, without it the other option is UI Scripting.

    Example AppleScript code:

    try
        set doNotShowSplashScreen to (do shell script "defaults read com.apple.VoiceOverTraining doNotShowSplashScreen") as integer as boolean
    on error
        set doNotShowSplashScreen to false
    end try
    if doNotShowSplashScreen then
        do shell script "/System/Library/CoreServices/VoiceOver.app/Contents/MacOS/VoiceOverStarter"
    else
        do shell script "defaults write com.apple.VoiceOverTraining doNotShowSplashScreen -bool true && /System/Library/CoreServices/VoiceOver.app/Contents/MacOS/VoiceOverStarter"
    end if
    

    Notes:

    Tested and works under macOS Sierra.