For example, when triggering `::/test::abc...xyzABC...XYZ`, I want the cursor to move automatically between z and A so that I can continue inserting content such as `123...789`.
The workaround is like `:X:/test::Send('abc...xyzABC...XYZ{Left 26}')`, but I think `::/test::abc...xyz|ABC...XYZ` where `|` indicates the cursor location would be much more convenient.
Designate `|` to the cursor location when implementing hotstring auto-replacement.
Re: Designate `|` to the cursor location when implementing hotstring auto-replacement.
In the meantime (and probably always since I doubt your request will get implemented in AHK), you can use this function that will move the cursor to the (first) pipe character:
Code: Select all
#Requires AutoHotkey v2.0
:X:/test::SendCursorPos 'abcdefghijklmnopqrstuvwxyz|ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SendCursorPos(s) {
SendText StrReplace(s, "|",,,, 1)
Send "{Left " (StrLen(s) - InStr(s, "|")) "}"
}
Re: Designate `|` to the cursor location when implementing hotstring auto-replacement.
Yes, there are several ways to achieve this goal, but I think adding syntax sugar would be awesome since it is a very common use case.
When using hotstring just to insert some text, there will always be a fixed part and another variable part that needs to be filled in after auto-replacement, like 'Hello, ___. Nice to meet you...'
A simple `::/test::Hello, |. Nice to meet you...` is quite handy to use.
When using hotstring just to insert some text, there will always be a fixed part and another variable part that needs to be filled in after auto-replacement, like 'Hello, ___. Nice to meet you...'
A simple `::/test::Hello, |. Nice to meet you...` is quite handy to use.
Re: Designate `|` to the cursor location when implementing hotstring auto-replacement.
Yes, but what you showed requires you counting characters. What I showed is almost the same is what you’re asking for. Yes, it would be a little cleaner if built into the language. I suggested something close to it thinking you might appreciate it since the change likely won’t happen soon, if at all. Feel free to ignore it, of course.
Re: Designate `|` to the cursor location when implementing hotstring auto-replacement.
Thank you for your advice. Actually, I have already used a similar method you suggested. The example I provided was just a simplified version so that anyone can easily understand what I want to do.
My intention was to highlight that automatic replacement is one of the most commonly utilized basic features in AHK, and this syntax sugar is particularly user-friendly for anyone, especially those who have little or even zero knowledge of programming.
My intention was to highlight that automatic replacement is one of the most commonly utilized basic features in AHK, and this syntax sugar is particularly user-friendly for anyone, especially those who have little or even zero knowledge of programming.
Who is online
Users browsing this forum: No registered users and 23 guests