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.
terp
Auto-replace and capitalization
Re: Auto-replace and capitalization
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
Re: Auto-replace and capitalization
Try PhraseExpress. It's a better front end if you're only using AHK for autoreplace.
Re: Auto-replace and capitalization
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.
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.
::amy::Amy
; OR
:C:amy::Amy
Who is online
Users browsing this forum: No registered users and 31 guests