It is a simple state machine, monitoring key presses. If ever a mouse key or special keyboard key is pressed, like {Up}, {RShift} or {F1} we get to the initial state, waiting for a safe sign of a sentence ending. If a sentence terminator is entered (.?!), we move to state 1 (forgetting everything beforehand). If a white space character is entered, it is ignored, unless we are in state 1, when we proceed to state 2. Letters (converted to upper case) are replaced in the text only if we are in state 2. At other than whitespace characters and terminators (like letters) we move back to the initial state, waiting for the end of another sentence.
#SingleInstance force #NoEnv Process Priority,,High SetBatchLines -1 Loop { Input key, I L1 V, ( Join {ScrollLock}{CapsLock}{NumLock}{Esc}{BS}{PrintScreen}{Pause}{LControl}{RControl} {LAlt}{RAlt}{LShift}{RShift}{LWin}{RWin}{F1}{F2}{F3}{F4}{F5}{F6}{F7}{F8}{F9}{F10}{F11}{F12} {Left}{Right}{Up}{Down}{Home}{End}{PgUp}{PgDn}{Del}{Ins} ) If StrLen(ErrorLevel) > 3 ; NewInput, EndKey state = Else If InStr(".!?",key) ; Sentence end state = 1 Else If InStr("`t `n",key) ; White space state += (state = 1) ; state1 -> state2 Else { StringUpper key, key If state = 2 ; End-Space*-Letter Send {BS}{%key%} ; Letter -> Upper case state = } } ~LButton:: ~RButton:: ~MButton:: ~WheelDown:: ~WheelUp:: ~XButton1:: ~XButton2::State =