F1::MsgBox % 剪贴板缓存 :=ClipCopy()
F2::ClipPaste(剪贴板缓存)

ClipCopy(piMode := 0) {
  clpBackup := ClipboardAll
  Clipboard=
  if (piMode == 1)
    sCopyKey := "vk58sc02D" ; Cut = x
   else
    sCopyKey := "vk43sc02E" ; Copy = c
  SendInput {Shift Down}{Shift Up}{Ctrl Down}{%sCopyKey% Down}
  ClipWait 1
  SendInput {%sCopyKey% Up}{Ctrl Up}
  sRet := Clipboard
  Clipboard := clpBackup
  return sRet
}

ClipPaste(ByRef psText) {
  if (psText != "") {
    clpBackup := ClipboardAll
    Clipboard := psText
    SendInput {Shift Down}{Shift Up}{Ctrl Down}{vk56sc02F Down}
    ; 等待剪贴板准备好
    iStartTime := A_TickCount
    While (DllCall("GetOpenClipboardWindow") && (A_TickCount-iStartTime<1400)) ; timeout = 1400ms
      Sleep 30
    SendInput {vk56sc02F Up}{Ctrl Up}
    Clipboard := clpBackup
  }
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。