Autohotkey ControlSend发送额外的换行符
我正在尝试用向记事本发送文本。但它会向记事本发送带有额外换行符的文本Autohotkey ControlSend发送额外的换行符,autohotkey,Autohotkey,我正在尝试用向记事本发送文本。但它会向记事本发送带有额外换行符的文本 append() { SetKeyDelay, 10, 10 ControlSend,Edit1,% Clipboard,ahk_exe notepad.exe } #If GetKeyState("Ctrl") && GetKeyState("Shift") ;Seçilileri dosyay kaydeder. { a & s:: sleep 30 Send, ^c sleep 30 Clipb
append()
{
SetKeyDelay, 10, 10
ControlSend,Edit1,% Clipboard,ahk_exe notepad.exe
}
#If GetKeyState("Ctrl") && GetKeyState("Shift") ;Seçilileri dosyay kaydeder.
{
a & s::
sleep 30
Send, ^c
sleep 30
Clipboard := "`n[source]`n----`n" . Clipboard . "`n---- `n`n"
sleep 30
append()
sleep 30
Return
}
它发送了以下信息:
> [source,java]
> ----
> SetKeydelay, 10, 10
>
> SetKeyDelay, 0, 10
>
> SetKeyDelay, 0, 10
> ----
与此相反:
> [source,java]
> ----
> SetKeydelay, 10, 10
> SetKeyDelay, 0, 10
> SetKeyDelay, 0, 10
> ----
试一试
还可以尝试:
append(){
SetKeyDelay, 10, 10
; Remove all blank lines from the text in a variable:
Loop
{
Clipboard := StrReplace(Clipboard, "`r`n`r`n", "`r`n", Count)
if Count = 0 ; No more replacements needed.
break
}
ControlSend,Edit1,% Clipboard,ahk_exe notepad.exe
}
另一种方法:
append(){
SetKeyDelay, 10, 10
Loop, parse, Clipboard, `n
ControlSend,Edit1,%A_LoopField%,ahk_exe notepad.exe
}
感谢您的回复,我已经尝试过了,但没有效果。我认为是ControlSend导致了这个问题。谢谢,但我仍然有同样的问题,我打赌是ControlSend导致了这个问题,因为我用msgbox打印了剪贴板,并且看到没有多余的行。你从哪里获得
[源代码,java]
?在您的代码中,我只看到[source]
。试着在你的问题中加入你复制的原文(一个例子)。非常感谢,你是一个救命恩人
append(){
SetKeyDelay, 10, 10
Loop, parse, Clipboard, `n
ControlSend,Edit1,%A_LoopField%,ahk_exe notepad.exe
}