2017-04-02 25 views
0

將文本複製到剪貼板並粘貼到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. 
+0

找到答案在這裏:https://superuser.com/a/1109920/235752 – JinSnow

回答

1

手動加入後試試這個:

#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 
+0

我切換了 「ahk_exe AcroRd32.exe」 到 「ahk_class AcrobatSDIWindow」 和它的工作。唯一的是當我複製剪貼板。它將acrobat的光標從文本切換到平移(手形)。不知道爲什麼會發生。另外,如果我複製並快速移動到記事本(剪貼板處理完成之前),則不會發生連接線。我會看看我能弄清楚什麼。謝謝! – Karun

+0

試試我編輯的答案。 @ ahkcoder的代碼也適用於我。 [This](https://autohotkey.com/download/)是最新的AHK版本。 – user3419297

1

這工作:

#Persistent 
OnClipboardChange("ClipChanged") 
return 

ClipChanged() { 

    If (WinActive("ahk_exe AcroRd32.exe")) { 
     For e, v in StrSplit(clipboard, "`n", "`r") 
      x .= v " " 
     clipboard := trim(x) 
    } 
} 
+0

看起來它缺少一個OnClipboardChange函數。這是一個默認功能。也許我正在使用過時的AHK – Karun

+0

這是最新版本的AHK,幾個早期版本。 – errorseven