Create formatted text into clipboard

Get help with using AutoHotkey and its commands and hotkeys
johro23
Posts: 9
Joined: 18 Dec 2018, 09:22

Create formatted text into clipboard

05 Feb 2019, 07:36

Hi!

I want to put some text in a variable, including formatting stuff, like bold text, sometimes TAB- and ENTER-characters and more, then type it with Ctrl+v, but so far I came up with nothing. The best result so far was this one:

Code: Select all

SendViaClipboard(Text) {
	ClipSaved:=ClipboardAll
	Clipboard:=Text
	SendInput, ^v
	Sleep, 200
	Clipboard:=ClipSaved
	ClipSaved:=""
}

::test::
Text:="This is `bbold`b`nXYZ"
SendViaClipboard(Text)
Return
Wanted result:
This is bold
XYZ
Real result (run in MS Outlook):
This is □bold□
XYZ
So obviously the newline thing works, but how to make some of the text bold? I run the Swedish versions of Word, Outlook and more, they use Ctrl+f for bold ("fet" in Swedish) and Ctrl+k for italics ("kursiv"), while other programs use Ctrl+b and Ctrl+i respectively.

Suggestions? Is this even possible in this case?
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Create formatted text into clipboard

05 Feb 2019, 08:12

I like the style 'Ctrl Fet'

I do not know. In my opinion it looks impossible.
Maybe, your goal could be accomplished what you wanted way, If you are lucky enough to meet very knowledgeable people.

I'd rather recommend to use COM way.
That is the standard way to handle MS Office(Word/Outlook) in AutoHotkey
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Create formatted text into clipboard

05 Feb 2019, 08:13

what is your way , for "Find and Replace" ? (Ctrl + f in southern land).
johro23
Posts: 9
Joined: 18 Dec 2018, 09:22

Re: Create formatted text into clipboard

05 Feb 2019, 09:27

IMEime wrote:
05 Feb 2019, 08:13
what is your way , for "Find and Replace" ? (Ctrl + f in southern land).
Ctrl+b, so they just switched Ctrl+b and Ctrl+f. "Find and replace" is "Sök och ersätt" in Swedish, but Ctrl+s was taken ("Spara" in Swedish, means Save), so Ctrl+b it was (since it was no longer used for "Bold").

What do you mean when you say "COM way"?
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Create formatted text into clipboard

05 Feb 2019, 10:00

thanks nice tip, you guys have hard time over there.

this link is pretty old, but pretty good until today
https://autohotkey.com/board/topic/56987-com-object-reference-autohotkey-v11/

especially, MS Word
https://autohotkey.com/board/topic/5698 ... ntry373523

AND, you can find hundreds other nice posts, after you have familiar with above contents.
It is a kind of ny värld.
johro23
Posts: 9
Joined: 18 Dec 2018, 09:22

Re: Create formatted text into clipboard

06 Feb 2019, 10:11

Thanks, both of you. I'll have a closer look as soon as possible.

Return to “Ask For Help”

Who is online

Users browsing this forum: DRocks, flyingDman, Google [Bot], luchvk and 57 guests