-
Webseiten Hosting/Server Referenzen Kontakt/Impressum

How to paste/insert a large amount of text with AutoHotKey (AHK)

<< Back to overview / Zurück zur Übersicht

If you want to use AutoHotKey's Hotstring-feature with a long text, you have to wait a long time until the text is transfered/inserted.
The problem is: There is a delay between every keystrocke. This delay depends on your system. On my machine the delay is ~75ms (-> not more than 13 keystrockes per second can be sent). You can imagine the delay with a long text.
But you can use the clipboard to prevent any delay. Have a look at this code:
:O:\dinit::
ClipSaved := ClipboardAll
Clipboard =
(
/`/ === Default init ===
define(FATAL,E_USER_ERROR);define(ERROR,E_USER_WARNING);define(WARNING,E_USER_NOTICE);
function hsc($str) { return(htmlspecialchars($str)); }
/`/ ====================
)
Send ^v
sleep 100
Clipboard := ClipSaved
ClipSaved =
return
The action is triggered when you enter "\dinit". The steps are:
  • Save the current clipboard
  • Assign a new text to the clipboard
  • Send a CTRL-V to the application (paste clipboard)
  • Sleep for 100ms because of the keystrocke delay (this is important!)
  • Restore the old clipboard state
If you wonder why I used "/`/" instead of the normal two slashes: AHK somehow ignores two slashes, so I escaped the second character.
Copyright by Tobias Wiersch, 3D4X
Without any warranty - use this information at your own risk.
Tags: autohotkey AHK clipboard long large text block textblock hotstring delay paste copy restore



Seite zuletzt geändert am: 23.01.2019