使用autohotkey自动加入行
将文本复制到剪贴板并粘贴到Word中时,Adobe Acrobat中的长段落会导致换行。使用autohotkey自动加入行
为了解决这个问题,我手动将复制的文本粘贴到记事本++>选择全部> ctrl + J(连接线)>全选>复制......然后将其粘贴到我的Word文档中。
我想使用autohotkey自动化这个连接线,因为我有大量的文件要通过。我似乎无法在网上找到任何直接在autohotkey脚本中处理这个问题的例子。
Ex。
Data structures with labeled axes supporting automatic or explicit data alignment.
This prevents common errors resulting from misaligned data and working with
differently-indexed data coming from different sources.
在记事本++
Data structures with labeled axes supporting automatic or explicit data alignment. This prevents common errors resulting from misaligned data and working with differently-indexed data coming from different sources.
手动加入后试试这个:
#Persistent
return
OnClipboardChange:
If WinActive("ahk_exe AcroRd32.exe")
{
clipboard =
Send, {Ctrl down}c{Ctrl up}{Esc}
ClipWait
clip := RegExReplace(clipboard, "(\S.*?)\R(.*?\S)", "$1 $2") ; strip line breaks and replace them with spaces
clipboard = %clip%
StringReplace clipboard, clipboard, % " ", % " ", A ; replace double spaces with single spaces
ClipWait
ControlClick, x0 y0, A
}
return
编辑
或者这样:
#Persistent
return
OnClipboardChange:
If WinActive("ahk_class AcrobatSDIWindow")
{
clipboard := ""
Send, {Ctrl down}c{Ctrl up}{Esc}
ClipWait
clip := RegExReplace(clipboard, "(\S.*?)\R(.*?\S)", "$1 $2") ; strip line breaks and replace them with spaces
StringReplace clip, clip, % " ", % " ", A ; replace double spaces with single spaces
clipboard := ""
clipboard = %clip%
ClipWait 2
If !(ErrorLevel)
{
ToolTip, lines joined
Sleep 500
ToolTip
}
}
return
我切换了 “ahk_exe AcroRd32.exe” 到 “ahk_class AcrobatSDIWindow” 和它的工作。唯一的是当我复制剪贴板。它将acrobat的光标从文本切换到平移(手形)。不知道为什么会发生。另外,如果我复制并快速移动到记事本(剪贴板处理完成之前),则不会发生连接线。我会看看我能弄清楚什么。谢谢! – Karun
试试我编辑的答案。 @ ahkcoder的代码也适用于我。 [This](https://autohotkey.com/download/)是最新的AHK版本。 – user3419297
这工作:
#Persistent
OnClipboardChange("ClipChanged")
return
ClipChanged() {
If (WinActive("ahk_exe AcroRd32.exe")) {
For e, v in StrSplit(clipboard, "`n", "`r")
x .= v " "
clipboard := trim(x)
}
}
看起来它缺少一个OnClipboardChange函数。这是一个默认功能。也许我正在使用过时的AHK – Karun
这是最新版本的AHK,几个早期版本。 – errorseven
找到答案在这里:https://superuser.com/a/1109920/235752 – JinSnow