/// <summary> /// 单个粘贴 /// </summary> /// <param name="clip"></param> private void SinglePaste(ClipModel clip) { //设置剪切板前取消监听 WinAPIHelper.RemoveClipboardFormatListener(wpfHwnd); clipService.SetValueToClipboard(clip); //Thread.Sleep(100); SendPasteKey(); //设置剪切板后恢复监听 WinAPIHelper.AddClipboardFormatListener(wpfHwnd); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { webView1?.Dispose(); if (wpfHwnd == IntPtr.Zero) { WinAPIHelper.RemoveClipboardFormatListener(wpfHwnd); HotKeyManager.UnregisterHotKey(wpfHwnd, hotkeyAtom); HotKeyManager.GlobalDeleteAtom(hotkeyAtomStr); } }
/// <summary> /// 批量粘贴,由于循环太快、发送粘贴按键消息太慢,故延时 /// </summary> /// <param name="needPause"></param> private void BatchPaste(List <ClipModel> clipList) { //设置剪切板前取消监听 WinAPIHelper.RemoveClipboardFormatListener(wpfHwnd); for (int i = 0; i < clipList.Count; i++) { ClipModel clip = clipList[i]; if (i != clipList.Count - 1 && !clip.ClipValue.Contains("\n")) { clip.ClipValue += "\n"; } clipService.SetValueToClipboard(clip); SendPasteKey(); Thread.Sleep(50); } //设置剪切板后恢复监听 WinAPIHelper.AddClipboardFormatListener(wpfHwnd); }