The NVDA Controller Client API allows external applications to communicate with NVDA, enabling them to:
Speak text programmatically
Display braille messages
Cancel speech
Check if NVDA is running
Speak SSML (Speech Synthesis Markup Language)
The API is implemented as a DLL (Dynamic Link Library) that can be called from any programming language that supports loading and calling functions from DLLs.
The Controller Client API is primarily designed for applications that want to provide their own accessibility layer or need to communicate information directly to NVDA users.
NVDA runs on the lock screen and secure screens. Before providing information to users via the Controller Client API, check if Windows is locked or on a secure screen to prevent leaking secure data.
Applications should implement security checks:
import ctypes# Check if on secure desktopdef is_secure_desktop(): # Implementation depends on your security requirements # Check for locked workstation or secure screen pass# Only speak if not on secure desktopif not is_secure_desktop(): clientLib.nvdaController_speakText("Sensitive information")
0 on success, 1717 if not supported, other non-zero on failure
Available in NVDA 2024.1 and later
ssml = """<speak> This is one sentence. <mark name="test" /> <prosody pitch="200%">This sentence is pronounced with higher pitch.</prosody> <break time="1000ms" /> This is after a one second pause.</speak>"""clientLib.nvdaController_speakSsml(ssml, -1, 0, False)
import ctypesimport time# Load the libraryclientLib = ctypes.windll.LoadLibrary("./nvdaControllerClient.dll")# Test if NVDA is runningres = clientLib.nvdaController_testIfRunning()if res != 0: errorMessage = str(ctypes.WinError(res)) print(f"Error: {errorMessage}") exit(1)# Speak and braille messagesclientLib.nvdaController_speakText("Application started successfully")clientLib.nvdaController_brailleMessage("Ready")# Cancel speech if neededtime.sleep(2)clientLib.nvdaController_cancelSpeech()
using System;using System.Runtime.InteropServices;using System.Threading;class Program{ [DllImport("nvdaControllerClient.dll")] static extern int nvdaController_testIfRunning(); [DllImport("nvdaControllerClient.dll")] static extern int nvdaController_speakText([MarshalAs(UnmanagedType.LPWStr)] string text); [DllImport("nvdaControllerClient.dll")] static extern int nvdaController_brailleMessage([MarshalAs(UnmanagedType.LPWStr)] string message); [DllImport("nvdaControllerClient.dll")] static extern int nvdaController_cancelSpeech(); static void Main(string[] args) { // Test if NVDA is running int res = nvdaController_testIfRunning(); if (res != 0) { Console.WriteLine("NVDA is not running"); return; } // Speak and braille nvdaController_speakText("Hello from C# application!"); nvdaController_brailleMessage("C# App"); Thread.Sleep(2000); nvdaController_cancelSpeech(); }}
All functions return 0 on success and a non-zero Windows error code on failure. Common error codes:
Error Code
Meaning
0
Success
1717
RPC_S_UNKNOWN_IF - Function not supported in this NVDA version
Other
Standard Windows error codes (use WinError or equivalent to decode)
Always check the return value of controller client functions and handle errors gracefully. NVDA might not be running, or the user might have disabled it temporarily.