This script will change ur shortcut text to something u've defined, that too in real time right when u're typing... works in any application.
This script utilises the input cmd, and is much easier to understand than the earlier complex script (which i've moved to the bottom).
The added benefit is that you'll have an option of using a 'prefix' character for triggers which are more common words and not using it for others.
typing
btw anywhere will change it to
by the way
and prefixing
mail with
` will change it to
mymail@server.com
(without quotes)
keep this in triggers.ini
Code:
[Triggers]
`mail=mymail@server.com
btw=by the way
otoh=on the other hand
plz=please
(mind that no empty lines should be present and 'trigger=some text' should not have extra spaces like 'trigger = some text', around the equals sign)
this is the script
Code:
SetTimer, AutoReplace, on
SetBatchLines, 10ms
;_______Building shortcut text list
Trigger0 = 1
Loop, Read, %a_scriptdir%\Triggers.ini
{
IfEqual, A_Index, 1, Continue
StringGetPos, EqPos, A_LoopReadLine, =
StringLeft, CT, A_LoopReadLine, %EqPos%
Trigger%A_Index% = %CT%
Triggers = %Triggers%`,%CT%
Trigger0 ++
}
;___________________________________________
;___________________________________________
;_____Shortcut text_________________________
AutoReplace:
SetTimer, AutoReplace, off
SetKeyDelay, -1
;more specific trigger texts can be added here:
Input, UserInput, *V, {ESC}{ENTER}, %Triggers%
Loop, %Trigger0%
{
IfEqual, A_Index, 1, Continue
StringTrimRight, CT, Trigger%A_Index%, 0
IfInString, UserInput, %CT%
{
StringLen, Tlen, CT
IniRead, ToSend, %a_scriptdir%\Triggers.ini, Triggers, %CT%
StringReplace, ToSend, ToSend, <s>, %a_space%, A
IfNotEqual, ToSend, ERROR, Send, {BS %Tlen%}%ToSend%
Break
}
}
SetTimer, AutoReplace, on
Return