public void SendKeys(string keys) { if (Window.GetForegroundWindow() != this.handle) { Activate(); Sleep(200); } System.Windows.Forms.SendKeys.SendWait(keys); }
public void SendKeystrokes(string keys) { if (Window.GetForegroundWindow() != this.handle && Window.GetLastActivePopup(Window.GetForegroundWindow()) != this.handle) { Activate(); Sleep(1000); } Debug.WriteLine("Sending keys: " + keys); System.Windows.Forms.SendKeys.SendWait(keys); this.WaitForIdle(100); // wait for it to behandled by the app }