Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickly send long text in AutoHotkey

I've been trying to figure out how to insert/expand long text faster. The current keystroke method I'm using is quite time consuming and therefore something I would rather avoid.

Right now I am using the following method:

::abc::all bad cats

Or for longer text:

::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.

However the second method is a little slow.

Any suggestions for how I can avoid this slow expansion method? Perhaps by using the clipboard to copy and paste from the AHK script?

like image 373
Shezan Kazi Avatar asked Dec 10 '14 08:12

Shezan Kazi


People also ask

How do I send keystrokes in AutoHotkey?

Send +{TAB 4} ; Presses Shift-Tab 4 times. To hold down or release a key: Enclose in braces the name of the key followed by the word Down or Up. For example: Send {b down}{b up} Send {TAB down}{TAB up} Send {Up down} ; Press down the up-arrow key.

How do I autorun an AutoHotkey script?

There are several ways to make a script (or any program) launch automatically every time you start your PC. The easiest is to place a shortcut to the script in the Startup folder: Find the script file, select it, and press Ctrl + C . Press Win + R to open the Run dialog, then enter shell:startup and click OK or Enter .

Is AutoHotkey a scripting language?

AutoHotkey is a free and open-source custom scripting language for Microsoft Windows, initially aimed at providing easy keyboard shortcuts or hotkeys, fast macro-creation and software automation that allows users of most levels of computer skill to automate repetitive tasks in any Windows application.


1 Answers

Try this:

::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

https://autohotkey.com/docs/misc/Clipboard.htm

like image 173
user3419297 Avatar answered Sep 23 '22 06:09

user3419297