I copied the script below from the forum, but I don’t remember, who posted it. I apologize to the author, but I changed the script name, the comments, etc., to my taste, and I don’t have the original. (This is the version I use.) The basic idea remained: the user is asked for a shorthand for the marked text, which is used to form a HotString command, appended to the script, which is then reloaded. It even has an error check, for malformed HotsStrings your default editor is called with the script already loaded, so you can edit it. It handles special characters and multi-line replacement texts well.
Code:
#h:: ; Win+H hotkey; The marked text as HotString is appended to this script, reloaded
AutoTrim Off ; Retain any leading and trailing whitespace on the clipboard.
ClipboardOld = %ClipboardAll%
ClipBoard = ; Clear to be able to see a change
Send ^c
ClipWait 1
; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring
; The same for other characters that might be a problem in raw mode
StringReplace Hotstring, Clipboard, ``, ````, All ; Do this replacement first to avoid interfering with the others below.
StringReplace Hotstring, Hotstring, `r`n, ``r, All ; Using `r works better than `n in MS Word, etc.
StringReplace Hotstring, Hotstring, `n, ``r, All
StringReplace Hotstring, Hotstring, %A_Tab%, ``t, All
StringReplace Hotstring, Hotstring, `;, ```;, All
Clipboard = %ClipboardOld% ; Restore previous contents of clipboard.
SetTimer, MoveCaret, 10 ; Move the InputBox's caret to a friendly position
; Show the InputBox, providing the default hotstring
InputBox Hotstring, New Hotstring, Type your abreviation at the insertion point.`nYou can also edit the replacement text.`n`nExample entry: :R:btw`::by the way,,,,,,,, :R:`::%Hotstring%
IfNotEqual ErrorLevel,0,Return ; The user pressed Esc or clicked Cancel.
IfInString Hotstring, :R`:::
{
MsgBox You didn't provide an abbreviation. The hotstring has not been added.
return
}
FileAppend, `n%Hotstring%, %A_ScriptFullPath% ; Add the hotstring, reload the script
Reload
Sleep 1000 ; Error brings you here, otherwise Reload closes this instance during the Sleep
MsgBox 4,, The hotstring just added is improperly formatted.`nWould you like to open the script for editing?`nThe bad hotstring is at the bottom of the script.
IfMsgBox Yes, Edit
return
MoveCaret: ; Another thread to move the caret
IfWinNotActive, New Hotstring
return
Send {Home}{Right 3} ; Insertion point -> where to type the abbreviation.
SetTimer, MoveCaret, Off ; Runs only once
return
It is not a compiled script, though. Your posting did not say it was a requirement. Is your point that a dumb user can handle separate lines better than ::Abbreviation::ReplacementString combinations? Or, you don’t want to install AHK in the user’s computer? It is there hidden in the compiled script, anyway. But your script does provide some HotString functionality from a compiled script.