Automatically capitalize first letter AHK v2 with InputHook

Post your working scripts, libraries and tools.
User avatar
xypha
Posts: 24
Joined: 24 Apr 2020, 04:14

Automatically capitalize first letter AHK v2 with InputHook

16 Dec 2023, 09:57

This code was modified from a script posted here by Xtra
Adapted to AutoHotkey v2 and improved to capitalize the first letter whether or not it is preceded by a space.

Code: Select all

#Requires AutoHotkey v2.0

~NumpadEnter::
~Enter::
~.::
~!::
~?::
{
char1 := InputHook("L1 V C"," {LShift}{RShift}", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z") ; captures 1st character, visible, case sensitive ; .abc → .Abc
char1.Start()
char1.Wait()
if (char1.EndReason = "Match") {
    send "{Backspace}+" char1.Input
    exit
}
char2 := InputHook("L1 V C"," {LShift}{RShift}", "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z") ; captures 2nd character, visible, case sensitive ; . abc → . Abc
char2.Start()
char2.Wait()
if (char2.EndReason = "Match")
    send "{Backspace}+" char2.Input
}
This code is old.
Updates will be posted here on GitHub.

Some AHK v1 auto-capitalisation scripts are good - such as the one by Xtra linked above and one from computoredge; some didn't work for me, like the one here that caused errors with tab and mouse click; and there are many others out there too. Try a few and see what works for you.

Return to “Scripts and Functions (v2)”

Who is online

Users browsing this forum: vmech and 46 guests