Code: Select all
; This script will automatically capitalise the first character of a new sentence.
; Original script was by someone called "Laszlo" but was posted by "Benirons".
; Source: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=21858 (Second entry, poster name guest3456.)
#SingleInstance force
#NoEnv
Process Priority,,High
SetBatchLines -1
Menu, Tray, Icon, AutoCaps.ico
; Specify what programs the script will be active in.
GroupAdd, AutoCaps, ahk_exe firefox.exe
GroupAdd, AutoCaps, ahk_exe betterbird.exe
GroupAdd, AutoCaps, ahk_exe thunderbird.exe
GroupAdd, AutoCaps, ahk_exe treepadbiz.exe
; GroupAdd, AutoCaps, ahk_exe soffice.bin
; GroupAdd, AutoCaps, ahk_exe winword.exe
GroupAdd, AutoCaps, ahk_exe notepad.exe
GroupAdd, AutoCaps, ahk_exe wordpad.exe
GroupAdd, AutoCaps, ahk_exe stickies.exe
GroupAdd, AutoCaps, ahk_exe FSCapture.exe
#IfWinActive ahk_group AutoCaps
; Note: The #IfWinActive instruction also sets a context for all the code that follows.
; To terminate that context need to use #IfWinActive without parameters.
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 =
(This has me baffled as I have used the GroupAdd feature in another script and it works as expected: Programs not included in the GroupAdd definitions don't have the script running in them, which is what I want to achieve for the above script.)