Example #1
0
 /// <summary>
 /// set a window into the front
 /// </summary>
 /// <param name="WindowName"></param>
 /// <returns></returns>
 public static Boolean SetFrontWindow(String WindowName)
 {
     return(NativeMethods.SetForegroundWindow(FindWindowByWindowTitle(WindowName)));
 }
Example #2
0
 /// <summary>
 /// types a key or o sequence of keys to an application (by set the application to foreground)
 /// </summary>
 /// <example>
 /// <code>
 /// IntPtr hWnd = something;
 /// Keyboard.Type("{ENTER}",hWnd); // click the enter button
 /// Keyboard.Type("ENTER",hWnd);   // types "E","N","T","E","R"
 /// // or send it to a specific window
 /// </code>
 /// </example>
 /// <remarks>
 /// http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx
 /// </remarks>
 /// <param name="Sequence">Sequence to type</param>
 /// <param name="hWnd">target application</param>
 /// <returns></returns>
 public static void Type(String Sequence, IntPtr hWnd)
 {
     NativeMethods.SetForegroundWindow((IntPtr)hWnd);
     SendKeys.SendWait(Sequence.Trim());
     SendKeys.Flush();
 }