-
Notifications
You must be signed in to change notification settings - Fork 0
/
NvdaOutput.cs
82 lines (70 loc) · 2.23 KB
/
NvdaOutput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
namespace AccessibleOutput
{
using System;
using System.Runtime.InteropServices;
public class NvdaOutput : IAccessibleOutput
{
public NvdaOutput()
{
}
public bool IsAvailable()
{
if (Environment.Is64BitProcess)
{
return NativeMethods64.nvdaController_testIfRunning() == 0;
}
else
{
return NativeMethods32.nvdaController_testIfRunning() == 0;
}
}
public void Speak(string text)
{
this.Speak(text, false);
}
public void Speak(string text, bool interrupt)
{
if (interrupt)
{
this.StopSpeaking();
}
if (Environment.Is64BitProcess)
{
NativeMethods64.nvdaController_speakText(text);
}
else
{
NativeMethods32.nvdaController_speakText(text);
}
}
public void StopSpeaking()
{
if (Environment.Is64BitProcess)
{
NativeMethods64.nvdaController_cancelSpeech();
}
else
{
NativeMethods32.nvdaController_cancelSpeech();
}
}
internal static class NativeMethods32
{
[DllImport("nvdaControllerClient32.dll")]
internal static extern int nvdaController_testIfRunning();
[DllImport("nvdaControllerClient32.dll", CharSet = CharSet.Auto)]
internal static extern int nvdaController_speakText(string text);
[DllImport("nvdaControllerClient32.dll")]
internal static extern int nvdaController_cancelSpeech();
}
internal static class NativeMethods64
{
[DllImport("nvdaControllerClient64.dll")]
internal static extern int nvdaController_testIfRunning();
[DllImport("nvdaControllerClient64.dll", CharSet = CharSet.Auto)]
internal static extern int nvdaController_speakText(string text);
[DllImport("nvdaControllerClient64.dll")]
internal static extern int nvdaController_cancelSpeech();
}
}
}