| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Reads out loud the selected text.
Set the GPII_ACTIVE_WINDOW environment variable to the handle of the window which contains the selected text. The selected text on the window will be read, and the application will terminate.
The text is read from the window by copying it from clipboard (CTRL + C keypress is simulated).
However, by the time the button is clicked, the button's parent window is activated and the keypress is sent there. To work around this, the active window is monitored and the keypress is sent to the last active window.
Take SelectionReader.cs, and use it like this:
Initialisation:
// Begin monitoring the active window.
WindowInteropHelper nativeWindow = new WindowInteropHelper(this);
HwndSource hwndSource = HwndSource.FromHwnd(nativeWindow.Handle);
SelectionReader selectionReader = new SelectionReader(nativeWindow.Handle);
hwndSource.AddHook(selectionReader.WindowProc);Invocation:
// Get the selected text
string text = await selectionReader.GetSelectedText(activeWindow);
// Speak it
SpeechSynthesizer speech = new SpeechSynthesizer();
speech.SetOutputToDefaultAudioDevice();
speech.SpeakAsync(text);If the application already knows the active window, set the GPII_ACTIVE_WINDOW to the window handle and start this process.
| Back | FazBrowse Home | New Git URL |