Autohotkey SendRaw 添加 EOL

Autohotkey SendRaw adding EOL

AutoHotkey 脚本将剪贴板内容粘贴为纯文本(使用 windows+v),但它会在每一行插入额外的 EOL 字符。

我的脚本是:

#v::
  SendRaw %clipboard%
Return

我复制了如下内容:

  1: bolded line
  2: italicized line2
  3. normal line

并期待它粘贴:

  1: bolded line
  2: italicized line2
  3. normal line

但我得到:

  1: bolded line

  2: italicized line2

  3. normal line

请注意:此问题出现在 Windows 7 和 10 的 AuthoHotkey v1.1.24.04

  • 在Windows中,EOL字符通常是CRLF,即两个字符:CR(回车return,Chr(13))和LF(换行,Chr(10))。
  • SendRaw 将这些解释为需要发送到 window 或控件的两个回车键。
  • 解决方法是使用以下代码:

-

#v::
vText := Clipboard
StringReplace, vText, vText, `r`n, `n, All
SendRaw %vText%
Return