Formatting text in a hotstring replacement

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DaveT1
Posts: 225
Joined: 07 Oct 2014, 11:23

Formatting text in a hotstring replacement

19 Dec 2014, 10:11

Hi,

I'm still pretty new here, but have a problem which I'm wondering if can be done at all. I'd like to format the text in a hotstring replacement. Specifically, I have an email signoff which looks something like:

Best Regards
Name
t: +00 123 456 789; http://www.coname.com; e: blah@blah.com

ie., the contact details on the last line are a smaller font size than the preceding 2 lines. Thus far, my AUTOHOTKEY code looks like:

::ch1::
(
Best Regards
Name
t: +00 123 456 789; http://www.coname.com; e: blah@blah.com
)

I can make parts of the replacement text bold, but apart from that I can't see any way to do other formatting. Any pointers gratefully received.

Thanks.
Guest

Re: Formatting text in a hotstring replacement

19 Dec 2014, 10:35

You can't send "richt text" like that in a simple hotstring or hotkey. But you can do it if you use a two step method, read rich text into the clipboard and have it pasted.

1 - FileAppend (once) + FileRead in Binary mode
You can copy the text (manually, once) to your clipboard, use a simple script to
save ClipboardAll to a binary file using FileAppend - the * option http://ahkscript.org/docs/commands/FileAppend.htm and *c http://ahkscript.org/docs/commands/FileRead.htm

2 - You could use HTML or RTF if you use WinClip, see http://www.autohotkey.com/board/topic/7 ... ntry678987 for directions

3 - You can also read it from a Word or RTF file using COM (if you have MS Office) http://www.autohotkey.com/board/topic/5 ... otkey-v11/

I'd go for option 1 or 2.
DaveT1
Posts: 225
Joined: 07 Oct 2014, 11:23

Re: Formatting text in a hotstring replacement

19 Dec 2014, 11:48

Thanks Guest,

I thought it was not possible directly. But thanks for the alternative suggestion. I'll need a little time to digest and play with it. I'll post back with what I find.

Thanks again.
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Re: Formatting text in a hotstring replacement

22 Dec 2014, 01:43

If you use Send, you can use keyboard shortcuts to change the font size.

Code: Select all

::ch1::
Send,   ; Recommend using SendMode Input at the top of the script.
(
Best Regards
Name
^+{< 2}t: {+}00 123 456 789; http://www.coname.com; e: blah@blah.com
)
return
In this case, you need to wrap modifier symbols like + in braces to use them literally. ^+< shifts font size down once, so ^+{< 2} twice.
DaveT1
Posts: 225
Joined: 07 Oct 2014, 11:23

Re: Formatting text in a hotstring replacement

05 Jan 2015, 05:26

Hi,

Back after the break to report what I found.

Guest, I followed your suggested option 1. I guess that the formatting of the text is 'stored' externally in another file. So I found that the following worked to perform this:

Firstly, copy to the clipboard the formatted text. Then use the following script to write this out to an external file:

FileDelete, test5.txt
FileAppend, %ClipboardAll%, test5.txt

And then, at the time I need to write out this text, the following works:

::ch1::
Send, Best Regards, {Enter}{Enter}
Send, Name {Enter}
FileRead, Clipboard, *c test5.txt
Send, ^v
return

So I'm very happy with that. Many thanks for taking time to assist.

Lexikos, thanks also for the advice. I implemented your script, but found it did not alter the size of the text. Nor, in my mail program (Groupwise), could I find a key combo to alter only the size of the text. Probably I didn't understand enough to make this work. But thanks again for taking time to comment.
lexikos
Posts: 9621
Joined: 30 Sep 2013, 04:07
Contact:

Re: Formatting text in a hotstring replacement

05 Jan 2015, 06:28

I may have assumed you were using Word, but I don't remember. If manually pressing keys can't get you what you want, neither will sending keystrokes using Send.
DaveT1
Posts: 225
Joined: 07 Oct 2014, 11:23

Re: Formatting text in a hotstring replacement

05 Jan 2015, 06:31

Thanks lexikos. No probs, I seems to have got to where I need to be. Thanks to a very friendly community :-).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 142 guests