I "discovered" a really easy way to send (paste) Unicode characters from your script. I don't think I've seen this suggested on the forum before, but it's so simple I'm not sure why not. It says right in the manual, that Transform, Unicode accepts literal UTF-8 strings, so all you have to do is save your script in that format and you can embed any character in your script in human-readable form.
Code:
;IMPORTANT, you must save this script as UTF-8 to make it work.
::!?::
::?!::
PutUni("‽")
Return
::neko::
PutUni("猫")
Return
:?:damn::
PutUni("✩☠#‼")
return
;Paste UTF8 string (Hex encoded or not) as unicode.
;If you don't use Hex encoding, you must save your script as UTF8
PutUni(DataIn)
{
SavedClip := ClipBoardAll
ClipBoard =
If RegExMatch(DataIn, "^[0-9a-fA-F]+$")
{
Loop % StrLen(DataIn) / 2
UTF8Code .= Chr("0x" . SubStr(DataIn, A_Index * 2 - 1, 2))
}
Else
UTF8Code := DataIn
Transform, ClipBoard, Unicode, %UTF8Code%
Send ^v
Sleep 100 ;Generous, less wait or none will often work.
ClipBoard := SavedClip
return
}
There is one little catch though. If you save your script in UTF-8,
all special characters need to be passed through this function. You can't do something like this anymore:
Code:
::(r)::®
You'd have to do this:
Code:
::(r)::
PutUni("®")
Return
See also:
AutoHotkey_L version.