= Controller Client enhancement by NVDAJP =
Download nvdajp-client-130223.zip
* http://en.sourceforge.jp/ticket/download.php?group_id=4221&tid=29342&file_id=4890
== isSpeakng ==
if speech engine is speaking, nvdaController_isSpeaking() returns True.
{{{
# coding: utf-8
import time
import ctypes
DLLPATH = '../newclient/nvdaHelper/build/x86/client/nvdaControllerClient32.dll'
clientLib=ctypes.windll.LoadLibrary(DLLPATH)
res=clientLib.nvdaController_testIfRunning()
if res!=0:
errorMessage=str(ctypes.WinError(res))
ctypes.windll.user32.MessageBoxW(0,u"Error: %s"%errorMessage,u"Error communicating with NVDA",0)
exit(1)
clientLib.nvdaController_speakText(
u"This is test case.\n \
The case nvdaController_isSpeaking beep out when speaking with nvda! \
")
while True:
time.sleep(0.5)
ctypes.windll.user32.MessageBeep(0)
if not clientLib.nvdaController_isSpeaking():
break
ctypes.windll.user32.MessageBeep(1)
clientLib.nvdaController_cancelSpeech()
clientLib.nvdaController_speakText(u"Finished!")
}}}
== getPitch, setPitch ==
Pitch can be manipulated by nvdaController_getPitch() and nvdaController_setPitch() methods.
{{{
# coding: utf-8
import time
import ctypes
DLLPATH = '../newclient/nvdaHelper/build/x86/client/nvdaControllerClient32.dll'
clientLib=ctypes.windll.LoadLibrary(DLLPATH)
res=clientLib.nvdaController_testIfRunning()
if res!=0:
errorMessage=str(ctypes.WinError(res))
ctypes.windll.user32.MessageBoxW(0,u"Error: %s"%errorMessage,u"Error communicating with NVDA",0)
exit(1)
oldPitch = clientLib.nvdaController_getPitch()
clientLib.nvdaController_speakText("current pitch is %s . now changes pitch"%oldPitch)
time.sleep(5)
clientLib.nvdaController_setPitch(oldPitch-50)
newPitch = clientLib.nvdaController_getPitch()
clientLib.nvdaController_speakText("pitch changed to %s"%newPitch)
time.sleep(5)
clientLib.nvdaController_setPitch(oldPitch+50)
newPitch = clientLib.nvdaController_getPitch()
clientLib.nvdaController_speakText("pitch changed to %s"%newPitch)
time.sleep(5)
clientLib.nvdaController_setPitch(oldPitch)
clientLib.nvdaController_speakText("pitch reverted to %s"%oldPitch)
}}}
== getRate, setRate ==
Rate (speed) can be manipulated by nvdaController_getRate() and nvdaController_setRate() methods.
{{{
# coding: utf-8
import time
import ctypes
DLLPATH = '../newclient/nvdaHelper/build/x86/client/nvdaControllerClient32.dll'
clientLib=ctypes.windll.LoadLibrary(DLLPATH)
res=clientLib.nvdaController_testIfRunning()
if res!=0:
errorMessage=str(ctypes.WinError(res))
ctypes.windll.user32.MessageBoxW(0,u"Error: %s"%errorMessage,u"Error communicating with NVDA",0)
exit(1)
oldRate = clientLib.nvdaController_getRate()
clientLib.nvdaController_speakText("Rate is %s . now changes"%oldRate)
time.sleep(5)
clientLib.nvdaController_setRate(oldRate-50)
newRate = clientLib.nvdaController_getRate()
clientLib.nvdaController_speakText("Rate changed to %s"%newRate)
time.sleep(5)
clientLib.nvdaController_setRate(oldRate+50)
newRate = clientLib.nvdaController_getRate()
clientLib.nvdaController_speakText("Rate changed to %s"%newRate)
time.sleep(5)
clientLib.nvdaController_setRate(oldRate)
clientLib.nvdaController_speakText("Rate reverted to %s"%oldRate)
}}}
== speakSpelling ==
Text can be announced using character descriptions via nvdaController_speakSpelling() method.
{{{
import time
import ctypes
DLLPATH = '../newClient/nvdaHelper/build/x86/client/nvdaControllerClient32.dll'
clientLib=ctypes.windll.LoadLibrary(DLLPATH)
res=clientLib.nvdaController_testIfRunning()
if res!=0:
errorMessage=str(ctypes.WinError(res))
ctypes.windll.user32.MessageBoxW(0,u"Error: %s"%errorMessage,u"Error communicating with NVDA",0)
for count in xrange(4):
clientLib.nvdaController_speakSpelling(u"カタカナ ひらがな")
time.sleep(5)
}}}
== setAppSleepMode ==
The method nvdaController_setAppSleepMode was introduced since 2014.1jp.
It controls whether NVDA should sleep or not when the application is activated.
{{{
# coding: utf-8
from __future__ import unicode_literals
import time
from ctypes import *
import wx
DLLPATH = r'..\client\nvdaControllerClient32.dll'
clientLib = windll.LoadLibrary(DLLPATH)
def nvdaRunning():
if clientLib:
res = clientLib.nvdaController_testIfRunning()
if res == 0:
return True
return False
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="TestApp", size=(300,200))
self.tc = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)
self.tc.Value = "hello\nline2\nline3\n"
self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
self.speakItem = self.fileMenu.Append(-1, '&Speak')
self.Bind(wx.EVT_MENU, self.OnSpeak, self.speakItem)
self.sleepItem = self.fileMenu.Append(-1, 'Sleep O&n')
self.Bind(wx.EVT_MENU, self.OnSleep, self.sleepItem)
self.wakeupItem = self.fileMenu.Append(-1, 'Sleep O&ff')
self.Bind(wx.EVT_MENU, self.OnWakeup, self.wakeupItem)
self.quitItem = self.fileMenu.Append(-1, '&Quit')
self.Bind(wx.EVT_MENU, self.OnQuit, self.quitItem)
self.menubar.Append(self.fileMenu, '&File')
self.SetMenuBar(self.menubar)
self.Centre()
self.Show(True)
def OnSpeak(self, event):
if nvdaRunning():
res = clientLib.nvdaController_speakText(self.tc.Value)
def OnSleep(self, event):
if nvdaRunning():
res = clientLib.nvdaController_setAppSleepMode(1)
print "setAppSleepMode(1):%d" % res
def OnWakeup(self, event):
if nvdaRunning():
res = clientLib.nvdaController_setAppSleepMode(0)
print "setAppSleepMode(0):%d" % res
def OnQuit(self, event):
self.Close()
app = wx.App(False)
frame = MyFrame()
frame.Show()
app.MainLoop()
}}}