[program-l] Telling a C# implementation of SayTools to in fact UseSAPI

  • From: "Jacob Kruger" <jacobk@xxxxxxxxxxxx>
  • To: "Program-l" <program-l@xxxxxxxxxxxxx>
  • Date: Tue, 3 Mar 2009 15:36:11 +0200

Hi there

While now again looking into WPF etc., I have put together a small class to render a better description caption for various objects etc. from within the WPF applications, and it makes use of what they call event bubbling so that I just added an event handler for GotFocus to the window class, and in that event code I send e.OriginalSource to the other class that I then included in the application, and this gets specifically sent to a method called SayObject, wherein I'm in fact doing a switch based on the Object.GetType.ToString() function to see what type of object it is, and then getting Jaws etc. to say extra info relating to it's content etc. etc.

The primary idea is that while I wouldn't want to get it to necessarily speak extra unless the user was actually running a screenreader, I was just wondering about in fact telling it to use SAPI as a backup in any case.

Basically, the small bit of code from within Jamal's example code for making it say something looks like the following:
Type t = Type.GetTypeFromProgID("Say.Tools");
object oST = Activator.CreateInstance(t);
string sText = "Hello world";
object[] aParams = {sText};
t.InvokeMember("Say", BindingFlags.InvokeMethod, null, oST, aParams);

I tried adding in the following 2 lines of code above the actual invokeMember above to tell it to in fact use SAPI as a backup, but it just generates errors relating to invalid execution or something (not at that machine right now):
object[] aParams1 = {1};
t.InvokeMember("UseSAPIAsBackup", BindingFlags.InvokeMethod, null, oST, aParams1);

Maybe I'm just not used enough to C# syntax, or something, but I have checked the cases of the methods/functions/variable names as much as I can, so not sure why it doesn't want to do this.

Since I'm also sort of busy migrating to C# from VB.Net, it would also be best for me to figure this one out now already though.

TIA

Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: