How to correct DOuble CApitalization, allow TrIPPLE capitalization.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Vladimir
Posts: 16
Joined: 27 Nov 2019, 23:12

How to correct DOuble CApitalization, allow TrIPPLE capitalization.

29 Nov 2019, 17:36

This is a code for DUal CApitalization correction.

Code: Select all

; Removes DOuble CApitalization - adjust timer to improve precision
;keys = ``1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
keys = qwertyuiopasdfghjklzxcvbnm
Loop Parse, keys
   HotKey ~+%A_LoopField%, Hoty

Hoty:
   StringMid c0, A_PriorHotKey,2, 1
   StringMid c1, A_ThisHotKey, 3, 1
   If (c0 = "+" and A_TimeSincePriorHotkey < 250)
      Send {BS}%c1%
Return
This is a code for DUal CApitalization correction.

I believe that this code could work much better if it would consider that if I keep holding the shift key, after seeing a correction made, I am probably typing a short abbreviation in ALL CAPS.
How can I change this code so it would correct dual capitalization, yet if I type in a word, and it comes out like ThIS, the lowercase h needs to be replaced with the upper case?

Thank you.
fwejifjjwk2
Posts: 89
Joined: 10 Aug 2019, 01:49

Re: How to correct DOuble CApitalization, allow TrIPPLE capitalization.

29 Nov 2019, 23:01

After finish all article use Regular replace?
Vladimir
Posts: 16
Joined: 27 Nov 2019, 23:12

Re: How to correct DOuble CApitalization, allow TrIPPLE capitalization.

07 Dec 2019, 09:52

I can use replace, however
I am trying to understand the confusing syntax of AutoHotKey with this example.
There are so many standard functions that use such inconsistent syntax that sometimes I cannot read the code.
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: How to correct DOuble CApitalization, allow TrIPPLE capitalization.

07 Dec 2019, 20:11

See the comment after each line below for a description of what it does:

Code: Select all

keys = qwertyuiopasdfghjklzxcvbnm ; adds all 26 letters to a string
Loop Parse, keys ; loops through each letter one at a time
   HotKey ~+%A_LoopField%, Hoty ; creates a hotkey of the shifted version (+) of each letter; the ~ allows the key to be sent through as it is typed

Hoty: ; this is the label that is invoked by each of the 26 hotkeys
   StringMid c0, A_PriorHotKey,2, 1 ; isolates the 2nd character of the previous hotkey and assigns it to variable c0 so it can be checked to see if it is + (meaning shifted)
   StringMid c1, A_ThisHotKey, 3, 1 ; isolates the 3rd character of the current hotkey and assigns it to variable c1 so it can be sent without being shifted if desired
   If (c0 = "+" and A_TimeSincePriorHotkey < 250) ; checks to see if the prior hotkey was shifted and if it occured within the last 250 msec (0.25 seconds)
      Send {BS}%c1% ; if the above is true, then backspace over the last character sent and re-send it in its non-shifted form
Return ; return from the hotkey subroutine

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], haomingchen1998, MrDoge and 237 guests