[RESOLVED] Creating hotstring for "let <...> know", etc.
#1
Posted 05 May 2012 - 01:19 AM
Does anybody know how to create a hotstring for "let <pronoun> know", and similar phrases?
It is obvious that the most efficient way is:
-You enter the hotsting (for example: "lk") and press the Space key. The hotsring immediately expands into: "let <cursor> know" (NOTE:after expansion, the cursor is automatically located between "let" and "know").
-You type in the appropriate pronoun (for example: "him") and press the Space key again. The cursor jumps to the end of the "know".
As a result, you get "let him know<cursor>".
Any input on the topic will be greatly appreciated.
#2
Posted 05 May 2012 - 03:48 AM
::lk::
Send, let know
Send, {Left 5}
WaitPronoun = 1
return
#If WaitPronoun = 1
:B0:me::
:B0:you::
:B0:him::
:B0:her::
:B0:us::
:B0:them::
Send, {Backspace}{Right 5}{Space}
WaitPronoun = 0
return
#3
Posted 05 May 2012 - 02:35 PM
If you, for example, want to type "let John know" the hotstring does not help, as it programmed for SPECIFIED pronouns only. Could you please change your code so that hotstring would expand regardless of pronoun's content (actually, it could be pronoun; name; etc)?
And, if you do that, the hotstring coding will be much faster, because the code writer will not have to list in the code all possible versions of the insert!
#4
Posted 05 May 2012 - 03:20 PM
You're right, I hadn't thought about it. See if this one works for you:There is one serious shortcoming in this version of the code...
If you, for example, want to type "let John know" the hotstring does not help, as it programmed for SPECIFIED pronouns only. Could you please change your code so that hotstring would expand regardless of pronoun's content (actually, it could be pronoun; name; etc)?
And, if you do that, the hotstring coding will be much faster, because the code writer will not have to list in the code all possible versions of the insert!
::lk::
Send, let know
Send, {Left 5}
WaitPronoun = 1
return
#If WaitPronoun = 1
Space::
Send, {Right 5}{Space}
WaitPronoun = 0
returnIn case you would want to type more words, for example "let my father know" you'd have to change 'Space' to some other key of your choice, like Enter or Tab.
#5
Posted 05 May 2012 - 04:47 PM
::gab::
Send, give a break
Send , {ctrl down}{Left}{Left}{ctrl up}{Left}
WaitPronoun = 1
return
#If WaitPronoun = 1
Space::
Send, {End}{Space}
WaitPronoun = 0
returnAnd, I noticed another problem. Your code works just for one hotstring.When I try to enter another hotstring, using your code as a basis, I get the following message:
Error at line 347
Line Text: Space
Error: Duplicate hotkey.
How can we overcome this problem?
Very likely that people (including myself) will use your piece of code for many different expressions.
Any ideas?
#6
Posted 06 May 2012 - 04:42 PM
#NoEnv
SendMode Input
SetKeyDelay -1
[color=#00BF00]; Hotstrings Definition Section:
; Enter your hotstrings here in the same format.
; Enter the replace string after 'string = '
; Use Double Space to mark where the cursor should stop.[/color]
[color=#FF0000]::lk::
string = let know
gosub, SendString
return
::gab::
string = give a break
gosub, SendString
return[/color]
[color=#00BF00]; END OF DEFINITION SECTION![/color]
SendString:
StringLen, count, string [color=#00BF00]; Counts characters in replace string.[/color]
StringGetPos, pos, string, %A_Space%%A_Space% [color=#00BF00]; Finds marked position (Double Space).[/color]
Send, %string%
pos := count -1 -pos
Send, {Left %pos%} [color=#00BF00]; Jumps to maked position.[/color]
KeyWait, Space
KeyWait, Space, D [color=#00BF00]; Waits for Space to be pressed.
; Change the above to another key (i.e. Tab or Enter) if you need.[/color]
Send, {BS}{Right %pos%}{Space} [color=#00BF00]; Automatically returns the cursor to the end of the string.[/color]
return
Now you can enter as many hotstrings as you want within the definition section. They must be in the same format and you need to mark the position for the variable word with a double space. The script will do the rest.I also entered some parameters to make it faster. How is it now?
#7
Posted 06 May 2012 - 05:49 PM
Now, the script functions perfectly.
I am sure, it will save a lot of time to a lot of people who uses hotstrings.
#8
Posted 07 May 2012 - 08:33 PM
And if anyone wants to save time creating long macro scripts, take a look at my Macro Creator. It records keyboard and mouse inputs, easily creates many AHK commands and you can play it directly from the program or save an script with a hotkey or hotstring. It's also indicated to people who are not very familliar with scripts but wants to create macros and hotkeys.




