Hi,
I am new to AHK and using v1.1.30.00.
I managed to define a few hotstrings but they all have the problem that the ending character is eaten on execution:
::btw:: Send by the way
If I type, say, "btw." I get "by the way" instead of "by the way." (with the period). Even if I
:O0:btw:: Send by the way
I don't ghet what I want. Or when I use
#Hotstring O0
which should really help. What am I newbie doing wrong?
Thanks, Mixx
Hotstring ending character Topic is solved
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: Hotstring ending character Topic is solved
You could use this
Code: Select all
string := "by the way."
::btw:: Send %string%
Re: Hotstring ending character
Thanks, I thought of that. The major issue being that you need a separate definition for each ending character.
There must be a better way. Besides, the O0 option doesn't work. And it should be the default, if I read the manual correctly.
Is this a bug, then?
There must be a better way. Besides, the O0 option doesn't work. And it should be the default, if I read the manual correctly.
Is this a bug, then?
- Masonjar13
- Posts: 1555
- Joined: 20 Jul 2014, 10:16
- Location: Не Россия
- Contact:
Re: Hotstring ending character
By default, the ending character is included with the hotkey. That is, if you exclude send. ::btw::by the way works as you want.
Re: Hotstring ending character
what is the actual full script ure using? because i can tell u, it for sure isnt ::btw:: Send by the way. That would produce the literal Send by the way(yes, with the space in front), and not execute the send command.
If u want it to, use the X hotstring flag: :X:btw::Send by the way. ::btw::by the way should also work as expected.
The endchar getting swallowed might be the result of your editor, as the hotstrings do some backspacing. Test it in plain notepad.
If u want it to, use the X hotstring flag: :X:btw::Send by the way. ::btw::by the way should also work as expected.
The endchar getting swallowed might be the result of your editor, as the hotstrings do some backspacing. Test it in plain notepad.
Re: Hotstring ending character
Thank you ver much, sorted. I am learning AHK and for some reason I thought I always need a "Send". These hotstrings work now.
But this one doesn't:
in the sense that this one does swallow the ending character.
Please help me out with this one and I can do 80% of what I wanted from AHK.
Thanks, Mixx
But this one doesn't:
Code: Select all
::#d::
Send %A_YYYY%-%A_MM%-%A_DD%
return
Please help me out with this one and I can do 80% of what I wanted from AHK.
Thanks, Mixx
Re: Hotstring ending character
Code: Select all
:XB0:#d::sendText(A_YYYY "-" A_MM "-" A_DD) ; X - call function, B0 - turn off backspacing
sendText(str) {
hsLen := StrLen(RegExReplace(A_ThisHotkey, ":[^:]*:|(.*)", "$1")) ; returns StrLen of hotstring that triggered it, ie StrLen("#d") in ":XB0:#d"
SendInput % Format("{Left}{BS {1:}}{2:}{Right}", hsLen, str) ; manual backspace the correct number of chars, keep the end char and finally jump over it
}
Re: Hotstring ending character
You need to see the difference between auto-replacing hotstrings and non-auto-replacing hotstrings. The first do keep the end character and look like the single line hotstrings with just replacement text. The latter are the ones with an x option or spanning multiple lines to execute some script (like Send or anything else), and don't output anything by default other than the backspaces to remove the triggering string. Luckily there's the A_EndChar variable that contains the actual end char used to complete the hotstring.Mixx wrote:this one doesn't in the sense that this one does swallow the ending character.
E.g: :X:#d::Send %A_YYYY%-%A_MM%-%A_DD%%A_EndChar%
Re: Hotstring ending character
Thanks a million, Nextron, that gets me going for now!
Thanks, Mixx
PS: From the perspective of a noob, AHK seems to be very tricky. I know, it is powerful, too.
Thanks, Mixx
PS: From the perspective of a noob, AHK seems to be very tricky. I know, it is powerful, too.
Who is online
Users browsing this forum: No registered users and 87 guests