public static WinHandle SendKey(this WinHandle win, char c) { if (NtApi.GetForegroundWindow() != win.Handle) { NtApi.SetForegroundWindow(win.Handle); } WinSendKeys.SendWait(c.ToString()); return(win); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { if (!((sender as Image)?.Source is BitmapImage thumbImage)) { return; } var buf = Clipboard.GetDataObject(); var target = GetBitmapImage(thumbImage.UriSource.LocalPath); Clipboard.SetImage(target); SendKeys.SendWait("^v"); Thread.Sleep(1000); if (buf != null) { Clipboard.SetDataObject(buf); } }
public static WinHandle SendKeys(this WinHandle win, string text, bool sendCharbyChar = false, int interval = 10) { if (sendCharbyChar) { foreach (var c in text) { Thread.Sleep(interval); win.SendKey(c); } } else { if (NtApi.GetForegroundWindow() != win.Handle) { NtApi.SetForegroundWindow(win.Handle); } WinSendKeys.SendWait(text); } return(win); }
public static void SendKeys(string key) { SendKeysClass.SendWait(key); }