is in anyway possible to make a hotstring with a userinput, but with one word only?
anything like this
Code: Select all
::t (userinput(one word))::test hi
Code: Select all
::t (userinput(one word))::test hi
Code: Select all
hotstrings("([a-z0-9]{3,6}_\s)","label")
return
label:
send % "You entered " $1
return
Code: Select all
:B0*:t ::
input, var, V, {space}{enter}
len := StrLen(var) + 3
Sendinput {BS %len%}hello %var%, nice to meet you{!}
return
Thank you! This is what I'm searching forgregster wrote: ↑14 May 2021, 18:48Another approach, which will take the word (a name in this case) and use it in the replacement string:Typing t gregster (followed by a Space or Enter) will yield hello gregster, nice to meet you!.Code: Select all
:B0*:t :: input, var, V, {space}{enter} len := StrLen(var) + 3 Sendinput {BS %len%}hello %var%, nice to meet you{!} return
Code: Select all
:B0*:wt ::
:B0*:t ::
input, var, V, {space}{enter}
len := (StrLen(A_thishotkey) = 8) ? StrLen(var) + 4 : StrLen(var) + 3 ; calculation could be generalized for more variants
Sendinput {BS %len%}hello %var%, nice to meet you{!}
return
yea this would work, but i want the key W just not to be registered as first key. Now its completly disabledgregster wrote: ↑15 May 2021, 06:42Not sure, if I understand completely, but you can stack different hotstring variants:But obviously, w needs to be typed out first - since AHK can't tell the future...Code: Select all
:B0*:wt :: :B0*:t :: input, var, V, {space}{enter} len := (StrLen(A_thishotkey) = 8) ? StrLen(var) + 4 : StrLen(var) + 3 ; calculation could be generalized for more variants Sendinput {BS %len%}hello %var%, nice to meet you{!} return
(or should the character w only be typed out after typing tspace and otherwise always be suppressed ? of course, that could be done
One approach:)Spoiler
But if the hotstring should generally work in words, the ? option can help. (By default, hotstrings work only if they are at the start of a new word.)
For more complex or flexible situations, the Regex approach - mentioned by flyingDman above - might be better suited, or other clever solutions...
original post has been modified
ah sorry i understand.gregster wrote: ↑16 May 2021, 11:09What is your exact definition of a 'first key' ?
In which cases do you want to actually use the w key as itself, sending w ? Examples?
It sounds like you won't use it for words, but for a game ? Or, do you simply never use words like we, would, world, will and so on?
It could make sense to separate different scenarios by some criterion (tbd): In-game use vs. input-capable edit field/chat, or similar.