Text 在自动热键中快速发送长文本

Text 在自动热键中快速发送长文本,text,autohotkey,Text,Autohotkey,我一直在想如何更快地插入/扩展长文本。我目前使用的击键方法非常耗时,因此我宁愿避免使用 现在我正在使用以下方法: ::abc::all bad cats 或对于较长的文本: ::li:: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.

我一直在想如何更快地插入/扩展长文本。我目前使用的击键方法非常耗时,因此我宁愿避免使用

现在我正在使用以下方法:

::abc::all bad cats
或对于较长的文本:

::li::
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
然而,第二种方法有点慢

对于如何避免这种缓慢扩展的方法,有什么建议吗?也许通过使用剪贴板从AHK脚本复制和粘贴

::li::  
text =
(
Line1
Line2
...
)
; IfWinActive, ahk_group textEditors ; create a group in the auto execute section
SendInput, %text%                      ;  SendInput is faster and more reliable
return

试试这个:

::li::
ClipSaved := ClipboardAll ; save the entire clipboard to the variable ClipSaved
clipboard := ""           ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
clipboard =               ; copy this text:
(
Lorem ipsum dolor ...
line2
..
)
ClipWait, 2              ; wait max. 2 seconds for the clipboard to contain data. 
if (!ErrorLevel)         ; If NOT ErrorLevel, ClipWait found data on the clipboard
    Send, ^v             ; paste the text
Sleep, 300
clipboard := ClipSaved   ; restore original clipboard
ClipSaved =              ; Free the memory in case the clipboard was very large.
return

使用自动热键脚本语言快速发送长文本的另一种方法是

如果您先将所有文本放入Windows注册表内存。

然后,您可以使用[Registry Ram Memory Speed]将其读取到[Clipboard Memory]并将其粘贴完成

您可以尝试以下代码:

例1.ahk:

; [^ = Ctrl] [+ = Shift] [! = Alt] [# = Win]
#SingleInstance Force

;Variant 1
;put any clipboard text into variable a1
;send ^c
;a1=%clipboard%

;Variant 2
;or put any Variable to variable a1
;a1 := "Any Text"

;Variant 3
;or put any File text to variable a1
FileRead, a1, C:\My File1.txt
FileRead, a2, C:\My File2.txt

;Write the variable's To Registry - KeyHintText,value1 to value2
RegWrite, REG_SZ, HKEY_CURRENT_USER, software\KeyHintText,value1,%a1%
RegWrite, REG_SZ, HKEY_CURRENT_USER, software\KeyHintText,value2,%a2%

:*:abc:: 
clipboard := a1
send ^v
return

:*:def:: 
clipboard := a2
send ^v
return
注意-:*:abc::=(您可以不带空格地键入abc)-::abc::=(您可以带空格地键入abc)

如果使用Windows注册表,则优点是:

1-如果注册表中的Value1文本已更改,则使用相同的热键:*:abc::

:*:abc:: 
RegRead, clipboard, HKEY_CURRENT_USER,software\KeyHintText,value1
send ^v
return
2-如果重新启动计算机,所有文本将自动保存到Ram内存中

然后只能使用此代码

例2.ahk

; [^ = Ctrl] [+ = Shift] [! = Alt] [# = Win]
#SingleInstance Force

;read the Variable's From Windows Registry
RegRead, a1, HKEY_CURRENT_USER,software\KeyHintText,value1 
RegRead, a2, HKEY_CURRENT_USER,software\KeyHintText,value2

:*:abc:: 
clipboard := a1
send ^v
return

:*:def:: 
clipboard := a2
send ^v
return

提示:我将其与软件一起使用,然后您可以在Windows桌面上制作一组可单击的图片(工具栏),您可以将abc文本替换为图片,如果您用鼠标或触摸设备按下这些图片,它将执行(本机)自动热键命令代码

非常感谢!但不知何故,我似乎并没有比我以前使用的标准方法更快。我是否需要对agh脚本进行任何调整?是否有理由将
ClipWait
注释掉?表示它提高了脚本的可靠性。有没有理由不将其标记为正确答案?这是一个多么彻底、写得多么好的回答啊。这涵盖了如此多的场景,并为新用户(甚至中等用户)提供了大量有用的信息+1当然可以编辑:如果您是这样回答的,欢迎您访问Reddit.com上的/r/AutoHotkey subreddit。我们一直在寻找新的、消息灵通的、积极的贡献者来帮助群众。
; [^ = Ctrl] [+ = Shift] [! = Alt] [# = Win]
#SingleInstance Force

;read the Variable's From Windows Registry
RegRead, a1, HKEY_CURRENT_USER,software\KeyHintText,value1 
RegRead, a2, HKEY_CURRENT_USER,software\KeyHintText,value2

:*:abc:: 
clipboard := a1
send ^v
return

:*:def:: 
clipboard := a2
send ^v
return