Store a RTF File on the Clipboard Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
LeonSalters
Posts: 3
Joined: 09 Jul 2019, 02:48

Store a RTF File on the Clipboard

17 Apr 2020, 15:36

I want to read a RTF file and store the contents of the file on the clipboard, in this way I can select a file from a list of files, copy it to the clipboard and than paste in into a RTF processing application. In this way I can manage a lot of signatures that I can use in Outlook or any other RTF processor.

I use the following code but that does not work

FileRead, RtfFile, S:\Mail\Signatures\NLExtended.rtf
ClipBoard := RtfFile
if ErrorLevel
{
MsgBox, FileRead Error...
}

cfFormat := DllCall("RegisterClipboardFormat","Str","CF_RTF")

But the format on the clipboard is not RTF. Can someone please help me?
Thanks in advance
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Store a RTF File on the Clipboard

17 Apr 2020, 15:45

FileRead, RtfFile, *c S:\Mail\Signatures\NLExtended.rtf
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
LeonSalters
Posts: 3
Joined: 09 Jul 2019, 02:48

Re: Store a RTF File on the Clipboard

17 Apr 2020, 15:57

Hi Bnoli,

Thanks for your swift answer but using the code below ends up with a complete empty clipboard (using ClipSpy)

FileRead, RtfFile, *c S:\Mail\Signatures\NLExtended.rtf
ClipBoard := RtfFile
if ErrorLevel
{
MsgBox, FileRead Error...
}

cfFormat := DllCall("RegisterClipboardFormat","Str","CF_RTF")
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Store a RTF File on the Clipboard

17 Apr 2020, 16:09

Erm, please use code-tags to support your supporters: [code][/code] :thumbup:
... and now let's wait for the Dll-guys (& dolls) for further advice. :)
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
list
Posts: 222
Joined: 26 Mar 2014, 14:03
Contact:

Re: Store a RTF File on the Clipboard  Topic is solved

18 Apr 2020, 04:24

I would suggest WinClip() - see method 4 listed here https://www.autohotkey.com/boards/viewtopic.php?f=7&t=8977
COM would also be an option if you're working with Word files for example.

Finally, if you know HTML or Markdown or use RTF you can also use lintalist :)
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=3378
(it uses WinClip as well)
LeonSalters
Posts: 3
Joined: 09 Jul 2019, 02:48

Re: Store a RTF File on the Clipboard

18 Apr 2020, 14:36

Thanks List for pointing me to the correct age. I downloaded WinClip and changed it like this:

#Include Winclip\WinClipAPI.ahk
#Include Winclip\WinClip.ahk
wc := new WinClip

WinGetActiveTitle , MyActiveWinTitle

....

WinClip.Clear()
rtf := FileOpen("S:\Mail\Signatures\NLExtended.rtf", "r").read()
WinClip.SetRTF(rtf)
WinActivate , %MyActiveWinTitle%
WinClip.Paste()

And it works like a charm... Big thanks...
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Store a RTF File on the Clipboard

18 Apr 2020, 15:23

BNOLI wrote:
17 Apr 2020, 15:45
FileRead, RtfFile, *c S:\Mail\Signatures\NLExtended.rtf
what is the *c for?

Just reading the forum and never saw this
BNOLI
Posts: 548
Joined: 23 Mar 2020, 03:55

Re: Store a RTF File on the Clipboard

18 Apr 2020, 15:29

:arrow: FileRead click :idea:
Last edited by BNOLI on 18 Apr 2020, 15:31, edited 2 times in total.
Remember to use [code]CODE[/code]-tags for your multi-line scripts. Stay safe, stay inside, and remember washing your hands for 20 sec !
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Store a RTF File on the Clipboard

18 Apr 2020, 15:30

BNOLI wrote:
18 Apr 2020, 15:29
:arrow: FileRead click :idea:
Thank you

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: DevWithCoffee, Rohwedder, Sarhad and 133 guests