I wrote a program which uses global hotkeys to store a dragged text by user and read the text when she/he presses crtl+shift+w. But the program doesn't work when the dragged text be inside of other applications such as firefox ,adobe reader and etc. here my code in the method of hooking the key(s):
void hook_KeyPressed(object sender, KeyPressedEventArgs e)
{
//System.Threading.Thread th;
string backup = Clipboard.GetText();
SpeechSynthesizer speaker = new SpeechSynthesizer();
speaker.SetOutputToDefaultAudioDevice();
string text = null;
SendKeys.SendWait("^{c}");
text = Clipboard.GetText();
//IDataObject format= Clipboard.GetDataObject();
// string[] str = format.GetFormats();
// MessageBox.Show(str[0]);
MessageBox.Show(text);
Clipboard.SetText(backup);
speaker.Speak(text);
}
what it does is that storing the clipboard's text to a string and sending crtl+c keys (to store (or grab) the dragged text) and storing the text in another string and then restoring the backup(ed) text to the clipboard.
Any ideas ? thanks.