1

I have gotten into voice-recognition in C# forms and i wan wondering how i can have it set up so when i say "focus Google chrome" it will bring the focus to chrome and when i say something like "focus note pad" it focuses on that. Any one got some ideas?

something like

private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
    if(e.Result.Text == "focus google chrome")
    {
         focusSet(chrome.exe)
    }
}

Yes i know i made up the focusSet().

Flat Eric
  • 7,971
  • 9
  • 36
  • 45
user3448117
  • 85
  • 1
  • 6

1 Answers1

2

You'll need to pinvoke the Win32 API. See this thread for better descriptions: Win32: Bring a window to top

See this site for details on the C# implementation: http://www.pinvoke.net/default.aspx/user32/setforegroundwindow.html

Community
  • 1
  • 1
whoisj
  • 398
  • 1
  • 2
  • 10
  • for the FindWindow i'm getting an error of "FindWindow does not exist in this context" – user3448117 Jun 10 '14 at 07:36
  • @user3448117 the string you Find with needs to match the title of the window. Given that browser window titles are often controlled by the HTML TITLE tag, you're likely better of starting with EnumWindows and find the Chrome one. – whoisj Jun 10 '14 at 20:05