Font color

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MachteldV
Posts: 11
Joined: 01 Jul 2018, 05:43

Font color

24 May 2019, 03:17

When using a hotkey to type a text, for example an e-mail, is there a code to change the fontcolor?
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Font color

24 May 2019, 03:42

Depends entirely on whether you can control your e-mail client in any way (has nothing to do with AHK)
MachteldV
Posts: 11
Joined: 01 Jul 2018, 05:43

Re: Font color

24 May 2019, 03:51

What do you mean (sorry, im dutch). I make hotkeys for emails. My colleques open a e-mail in Outlook en type a shortcut for the type of hotkey they want to use. Then the autohotkey writes the e-mail. Question is if it's possible to change the font color of a word or sentence in that text.
AviationGuy
Posts: 188
Joined: 17 Jan 2019, 10:13

Re: Font color

24 May 2019, 04:13

Als je het font van een email wilt aanpassen moet je zorgen dat je AHK script dezelfde acties uitvoert als de persoon dat zal doen.

Code: Select all

^1::				; hotkey
send ^n			; open new mail
send {tab 3}		; go to mail textbox
send !o			; alt+o, open menu shortcut
send fc			; select textcolor
MouseClick on color	; je kan hier met ImageSearch je gewenste kleur zoeken en erop klikken
send % clipboard	; paste text
return			
Waarschijnlijk kan het ook met behulp van allemaal ingewikkelde functies en commands maar op dat level zit ik nog niet :)
Hoop dat het lukt!
MachteldV
Posts: 11
Joined: 01 Jul 2018, 05:43

Re: Font color

24 May 2019, 04:22

Dank voor je reactie (lekker makkelijk in het nederlands :) ), maar hoe ga ik deze code toevoegen in de hotkey tekst? Deze begint bij mij met SendInput en daarna komt de tekst van de mail. Ik gebruik bijvoorbeeld wel {ctrl down}{ctrl up} voor sneltoetsen, maar wat moet ik dan precies gebruiken als ik van een deel van de tekst de tekstkleur zou willen wijzigen...?
AviationGuy
Posts: 188
Joined: 17 Jan 2019, 10:13

Re: Font color

24 May 2019, 04:38

Wel he! :)
De code die ik stuurde kan je in Notepad++ plakken, of welke editor dan ook, en wanneer je deze runt, dmv ctrl+1 (en mail actief is, Outlook in dit geval) wordt het script geactiveerd.

Send % Clipboard plakt de tekst die je in je clipboard heb gezet dmv ctrl+c/x.

De kleur van specifieke delen van de tekst aanpassen is echter vrij ingewikkeld.
Dan zal je moeten kijken naar een combi van InStr en Substr of naar RegEx. Dit ligt er ook aan of je continu hetzelfde deel wilt aanpassen in de tekst of dat dit verschilt.
Als je standaard dezelfde zin wilt aanpassen kan je ook kijken naar ImageSearch om die zin te zoeken en deze te selecteren om vervolgens het font aan te passen.

Dus, wat is het precies dat je wilt?
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Font color

24 May 2019, 04:47

Inderdaad handig, maar ik denk dat de rest van de leden en misschien de beheerders dit niet zo 'handig' vinden. :)

*Translation: Indeed handy you guys can talk Dutch amongst eachother, but I doubt the other members and admins think it convenient :lol: :lol:
MachteldV
Posts: 11
Joined: 01 Jul 2018, 05:43

Re: Font color

24 May 2019, 05:01

'Thanks for your reply, but i'm afraid this is going to be too difficult for me.. I was hoping for an option simular to the one for making the font bold for example, like {ctrl down}b{ctrl up}. A code where i can put in fontcolor like 0/0/153 or #000099. But there is no shortcut in windows for changing fontcolor, so i think what i want is not possible...
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Font color

24 May 2019, 05:10

(Det är bra om konversationen sker på forumets språk - Engelska :D )
As i said in Swedish - the language of this forum is English.
However, the manual is available in German .: Deutsche Hilfedateien

Do not know if there is any AHK forum with German as a language.
(I hope you respect this message)
AviationGuy
Posts: 188
Joined: 17 Jan 2019, 10:13

Re: Font color

24 May 2019, 05:17

Haha, you are probably right WotD

@MachteldV
Oke, I think I understand what you want a bit more clear rn.
While it isn't pretty, you could try something like this.

Code: Select all

; make selected red
^1::
send !o
send fc
send {down 7}{left 4}{enter}
return

; make selected black
^2::
send !o
send fc
send {enter}
return
Again, this is in Outlook tho, you'll need to lookup the shortcuts for selecting color in other programs.

EDIT:
@Albireo, haha although it looks a bit the same, we are from The Netherlands, not Germany ;)
Last edited by AviationGuy on 24 May 2019, 05:24, edited 1 time in total.
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Font color

24 May 2019, 05:21

You probably get better result using COM, but that's way to complicated for me personally, but there are some
very talented users in here who might be able to assist.

@albirio, we are Dutch (The Netherlands) no German :lol:
MachteldV
Posts: 11
Joined: 01 Jul 2018, 05:43

Re: Font color

24 May 2019, 05:32

hmm.. that's way too complicated i'm afraid. And we have to make te hotkey today. I think we go to plan B or C. But thanks for all your input and help! :thumbup:
User avatar
WalkerOfTheDay
Posts: 710
Joined: 24 Mar 2016, 03:01

Re: Font color

24 May 2019, 06:22

Did you try AviationGuy's script ? It works for me.
Albireo
Posts: 1748
Joined: 16 Oct 2013, 13:53

Re: Font color

24 May 2019, 06:43

Try and change the heading to font color Outlook then I think you get more answers? (I do not use outlook)

Maybe this links will help you?
Automating an HTML Outlook email with AutoHotKey
Changing font type, color, size with 1 set of code across all MS Office programs
How do I create an autohotkey script to change font color in oneNote? (Does OneNote work on same way as Outlook?)
Keyboard Shortcut to Change Font Ink Color?

Have not tested any of the tips above.
I do not know if Outlook can handles control sequences in the text (something like ctrl+#0xff0000 + Some text ... )
or maybe HTML-code can work?

But this is a Outlook issue - Is it possible to change color on characters in Outlook? How? (the only way?)
When you have an answer to these questions, I believe that AHK can fulfill your desire.
(Maybe there is someone in the forum who reads your question, already has the solution - But the title of this thread would be clearer?)
MannyKSoSo
Posts: 440
Joined: 28 Apr 2018, 21:59

Re: Font color

24 May 2019, 14:33

When creating an email you can indeed use basic html codes like the font color, but you would have to do something like this to get it to work the way your want.

Code: Select all

m := ComObjActive("Outlook.Application").CreateItem(0)
m.Subject := "Outlook Automation"
m.To := "[email protected];"
m.CC := ""
m.HTMLBody := "<font color="red">I am red text</font>"
m.Display
;m.Send
return
This will create a new email and when it displays the information it should be in red text. You could create a custom editor and send it automatically through outlook, but I know this isn't exactly what you wanted. But if you can use autohotkey to change stuff in word it shouldn't have a problem doing it in outlook, especially since they use word as the basis of the formatting (since 2007).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 385 guests