Auto-replace and capitalization

Report problems with documented functionality
Posts: 1
Joined: 26 Apr 2017, 15:36

Auto-replace and capitalization

26 Apr 2017, 15:56

As a writer, I use the auto-replace capabilities of AHK all the time, and 99.5% of the time it works great. Entries such as ::teh::the work perfectly. The problem comes with words that are to be automatically capitalized. For example, ::amy::Amy. There are two ways an entry like that can go wrong:
1. if the word is at the beginning of a sentence in a program that automatically caps the first letter of a sentence.
2. if I out of habit capitalize the first letter myself anywhere in a sentence.
In both of these cases, the output is "AAmy."

Other proper nouns, depending on the structure in the auto-replace file, might duplicate more letters. For example, ::marj::Marjorie will result in "MarjoMarjorie" if I uppercase the "M" as I type.

I am using the latest version of AHK on a Win 10 machine.

User avatar
Posts: 4466
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Auto-replace and capitalization

26 Apr 2017, 23:22

I'm not sure if AHK can detect the first case ( I would just disable it and use AHK to do that ) but I am pretty sure that there are some flags for Hotstrings that can help you.
Recommends AHK Studio
Posts: 10
Joined: 26 Apr 2017, 14:50

Re: Auto-replace and capitalization

29 Apr 2020, 21:22

Try PhraseExpress. It's a better front end if you're only using AHK for autoreplace.
Posts: 6962
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Auto-replace and capitalization

03 May 2020, 21:38

Hotstrings work by watching keyboard input. They are designed to work in the broadest range of programs possible, and they necessarily know nothing about whatever program you are using. Only a few basic assumptions are made: Backspace deletes the last character; pressing a navigation key (arrows, Home, PgUp, etc.) is assumed to invalidate AutoHotkey's estimate of what is to the left of the caret. Once the trigger string is detected, Backspace is sent for each character to be deleted, then the replacement is sent; therefore, AutoHotkey must correctly guess the number of Backspaces needed.

I assume "a program that automatically caps the first letter of a sentence" is referring to Microsoft Word or something similar. IIRC, after Word performs auto-correction, pressing Backspace acts as undo; the word reverts to what was actually typed, instead of deleting the last character. It is not feasible for AutoHotkey to detect this kind of interference. You need an auto-replace system that integrates with the program you are using, or to turn off the program's own auto-replace system, or to disable any problematic hotstrings while that program is active (e.g. with #IfWinNotActive).

I see no reason for "Amy" to be replaced with "AAmy" in the case where you actually type "Amy", and I cannot reproduce it. However, that could be solved by using the case-sensitive option.

Code: Select all

#Hotstring C  ; Applies to all hotstrings until #Hotstring C0 is used.
; OR

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 8 guests