I looking for any script to change font colors in Microsoft word

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
omar bishr
Posts: 92
Joined: 23 Nov 2020, 23:05

I looking for any script to change font colors in Microsoft word

Post by omar bishr » 26 Jan 2022, 12:34

I looking for any script to change font colors in Microsoft word C:\Program Files\Microsoft Office\Office16\WINWORD.EXE
like when i press ctrl+1
color is white
when i press ctrl+2
color is red
any one help pls
some thing like this i geuss
^1::
oWord := ComObjActive("Word.Application")
wdColorRed = 0
oWord.Selection.Font.Color := wdColorRed
return

^2::
oWord := ComObjActive("Word.Application")
wdColorBlack = 50
oWord.Selection.Font.Color := wdColorBlac
return
but this only 2 colors i want other colors like green

iPhilip
Posts: 820
Joined: 02 Oct 2013, 12:21

Re: I looking for any script to change font colors in Microsoft word

Post by iPhilip » 26 Jan 2022, 14:38

@omar bishr, see the code below:

Code: Select all

^1::
oWord := ComObjActive("Word.Application")
wdRed := 6  ; https://docs.microsoft.com/en-us/office/vba/api/word.wdcolorindex
oWord.Selection.Font.ColorIndex := wdRed
return
Does that address your questions?
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

omar bishr
Posts: 92
Joined: 23 Nov 2020, 23:05

Re: I looking for any script to change font colors in Microsoft word

Post by omar bishr » 26 Jan 2022, 16:35

ok i found a way to custom your keyboard shortcut from the software so i make it
shift + ctrl + w
its white color
shift + ctrl + r
its red color
and i maked this script

Code: Select all

#If GetKeyState("ScrollLock", "T") && WinActive("ahk_exe WINWORD.exe")
$r::
SoundBeep, 1500, 20
Send r{ctrl Down}{shift Down}
Sleep, 200
SoundBeep, 1000, 20
Send r{ctrl Up}{shift up}
Return
$w::
SoundBeep, 1500, 20
Send w{ctrl Down}{shift Down}
Sleep, 200
SoundBeep, 1000, 20
Send w{ctrl Up}{shift up}
Return
i wanted to if scroll lock on and i pressed r its change to red color with out write r in the word
can you edit this ?
Attachments
dc2c1979-a032-427f-989e-a4dbebbdd814.png
dc2c1979-a032-427f-989e-a4dbebbdd814.png (304.66 KiB) Viewed 364 times

iPhilip
Posts: 820
Joined: 02 Oct 2013, 12:21

Re: I looking for any script to change font colors in Microsoft word

Post by iPhilip » 26 Jan 2022, 17:45

Does this do what you are asking for?

Code: Select all

#If GetKeyState("ScrollLock", "P") && WinActive("ahk_exe WINWORD.exe")
r::ChangeColor(6)  ; wdRed = 6
w::ChangeColor(8)  ; wdWhite = 8
#If

ChangeColor(ColorIndex) {
   oWord := ComObjActive("Word.Application")
   oWord.Selection.Font.ColorIndex := ColorIndex
}
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Post Reply

Return to “Ask for Help (v1)”