I'm new to the forum, love using AHK and I usually find solutions by searching the forum. Not this sadly, so I would like to ask for help!
I'm using F4 to insert a block of text from a file, which works great:
Code: Select all
F4::
n++
FileRead, clipboard, unformatted-text.txt
Send ^v
Return
How could this be done?
I thought this should work but it is flawed:
Code: Select all
F4::
ClipSaved := Clipboard ; saving current clipboard
Clipboard = "" ; emptying clipboard
n++
FileRead, clipboard, unformatted-text.txt ; putting contents of .txt file in clipboard
ClipWait ; waiting for the clipboard to be ready - this may be unnecessary, or may be illogically placed
Send ^v ; paste
Clipboard := ClipSaved ; putting original ciplboard contents back
Return
My other ideas include:
- Using Send / SendInput {Raw} would not involve the clipboard, but it is much slower than this method: Each character is typed in separately and this is a larger block of text, so it's not really useful for this purpose.
- I thought about using another .txt file as a temporary place to save the clipboard contents. But how can I empty the file at the end of the script, after the contents are back on clipboard? Otherwise the contents of the file will start to pile up.
Can you more experienced gurus help me solve this?
I don't have any coding experience so I'm having a hard tome understanding the manual.
Thanks a lot in advance!