I'm not sure that there's a better solution than using {Left}. Instead of doing it manually, though, if you want to make it part of the hotstring, you could do:
Code: Select all
::text1::
text1 =
(
After ahk has inserted my replacement text, I want to start typing
__RIGHT HERE AT THIS POSITION__
and not at the end of the whole enchilada that follows here until the end of the replacement text.
)
ReplaceText(text1)
Return
ReplaceText(Text)
{
Delimiter := "__RIGHT HERE AT THIS POSITION__" ; Set the text to remove and insert at
cursorPosition := InStr(Text, Delimiter) ; Get the position of the text to remove and insert at
TextPart1 := SubStr(Text, 1, cursorPosition - 1) ; Get the text before the delimiter
TextPart2 := SubStr(Text, cursorPosition + StrLen(Delimiter)) ; Get the text after the delimiter
TextPart2Len := StrLen(TextPart2) ; Get the length of the text after the delimiter
SendInput, {Text}%TextPart1%%TextPart2% ; Send the text
SendInput, {Left %TextPart2Len%} ; Cursor left to the position where the delimiter was
}
I know that it can be simplified, but it may be clearer this way. Also, the ReplaceText function is just to make it more reusable if you have other hotstrings that you want to do this for. If not, you could move that function's lines into the hotstring, itself. Anyways, maybe that's not really what you're after, but it might give you an idea.