smile happy laugh surprise lol
razz cool wink zzz neutral
silent eh sad cry col
oops confused anxious shock omg
vent mad angry evil twisted
100 clap heart eyes poop
thanks thumbup super bullseye thumbdown
santa angel skull ghost alien
Usage:
Save and run the script with AutoHotkey 1.1 (Unicode).
When in an input capable window, type hotstring ??? to trigger Emoji() which will display an UI.
Type a key phrase, for eg. smile or :). Note: You may also type in the uni-code 0x1F60A or 1F60A or 128522
Press Enter to confirm or Esc to cancel.
Emoticon would be pasted at the caret position of active window.
Note: Only limited testing was done.
You will see box character in MS Word. Select char and set font to "Segoe UI Symbol" (may be 36pt)
Works fine in text editors like notepad, metapad, PSPad, wordpad.
Works fine when composing mail in browsers.
Works fine in Facebook posts.
Works fine with AutoHotkey posts. (See preview above)
The script:
Code: Select all
#NoEnv ; Emoji script v0.21 by SKAN on D397/D39A
#Warn ; https://www.autohotkey.com/boards/viewtopic.php?t=80793
#SingleInstance, Force ; emoji list: https://unicode.org/emoji/charts/full-emoji-list.html
SetBatchLines, -1
Hotstring(":*X:???", "Emoji")
Return ; end of autoexecute section
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Emoji() {
Local
If !( Input := Emoji_InputHook(ID:=WinExist("A")) )
Return
Body := Format("<span style=""font-size:48px"">&#{:d};</span>", Input)
SetClipboardHTML(Body,, Chr(Input))
If WinActive("ahk_id" . ID)
SendInput ^v
Return
}
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Emoji_InputHook(hWnd) {
Local
Static hBM:=0
If !(hBM)
{
VarSetCapacity(BMBITS, 180*4, 240)
hBM:=DllCall("CreateBitmap", "Int",180,"Int",1,"Int",1, "Int",32,"Ptr",&BMBITS, "Ptr")
}
hMon := DllCall("MonitorFromWindow", "Ptr",hWnd, "Int",0x2, "Ptr") ; _DEFAULTTONEAREST
VarSetCapacity(MONITORINFO,40,0), NumPut(40, MONITORINFO,"Int")
DllCall("GetMonitorInfo", "Ptr",hMon, "Ptr",&MONITORINFO)
MX:=NumGet(MONITORINFO, 4, "Int"), MW:=NumGet(MONITORINFO, 12, "Int")-MX
MY:=NumGet(MONITORINFO, 8, "Int"), MH:=NumGet(MONITORINFO, 16, "Int")-MY
DetectHiddenWindows, % ("On", DHW:=A_DetectHiddenWindows)
SetWinDelay, % (0, SWD := A_WinDelay)
SetControlDelay, % (0. SCD := A_ControlDelay)
SplashImage, 10:HBITMAP:* %hBM%, ZY4 ZX12 ZH1 FM36 FS18 C11 CTF0F0F0 CW00AAAA B1 Hide
, % Chr(32),% Chr(191), Emoji, Segoe UI
WinWait, Emoji ahk_class AutoHotkey2
WinGetPos,,,WW, WH
WinMove,,, % MX+( (MW//2)-(WW//2) ), % MY+( (MH//2)-(WH//2) )
SplashImage, 10:Show
ControlSetText, Static2, % Input:=(Key:=(PreviousKey:=""))
ih := InputHook("M","{Escape}{Enter}{NumpadEnter}{``}")
ih.KeyOpt("{All}", "S")
ih.KeyOpt("{Space}{Tab}", "I")
ih.KeyOpt("{RShift}{LShift}", "-S")
ih.Start()
While (ih.InProgress && A_TimeIdle<180000)
{
Sleep 1
If ((Key:=ih.Input)=PreviousKey)
Continue
ControlSetText, Static2, % ( PreviousKey:=Key )
ControlSetText, Static1, % ( Key="" ? Chr(191) : Chr(Input:=Emoji_Code(Key)))
}
SplashImage, 10:OFF
SetControlDelay, %SCD%
SetWinDelay, %SWD%
DetectHiddenWindows, %DHW%
Return (ih.InProgress ? Round(ih.Stop()) : ih.EndKey="Escape" ? 0 : Input)
}
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Emoji_Code(Key) {
Switch (Key)
{
Case ":-)", ":)", ":-]", ":]", "=]", "=)", "smile" : Return 0x1F60A ; smile
Case ":‑D", ":D", "x‑D", "xD", "=D", "happy" : Return 0x1F604 ; happy
Case "laugh" : Return 0x1F601 ; laugh
Case ":0", ":-0", "surpr", "surprise" : Return 0x1F60D ; surprise
Case "lol", "laughing" : Return 0x1F602 ; lol
Case ":p", ":-p", ":b", ":-b", "=p", "razz" : Return 0x1F61C ; razz
Case "8)", "8-)", "cool" : Return 0x1F60E ; cool
Case ";‑)", ";)", "wink" : Return 0x1F609 ; wink
Case "zzz", "sleep" : Return 0x1F634 ; zzz
Case ":|", ":-|", "neut", "neutral" : Return 0x1F610 ; neutral
Case ";", ";-", ":", ":-", "silent" : Return 0x1F636 ; silent
Case "eh" : Return 0x1F612 ; eh
Case ":‑(", ":(", ":‑[", ":[", "sad" : Return 0x1F61E ; sad
Case ":'‑(", ":'(", "cry" : Return 0x1F622 ; cry
Case ":'‑(", ":'(", "col", "crying" : Return 0x1F62D ; crying
Case "oops", "embar", "embarassed" : Return 0x1F633 ; oops
Case "%)", "roll", "confused" : Return 0x1F635 ; confused
Case "anx", "anxious" : Return 0x1F630 ; anxious
Case ":O", ":-O", "shock" : Return 0x1F632 ; shock
Case "omg", "ohno" : Return 0x1F631 ; omg
Case "vent" : Return 0x1F624 ; vent
Case ":x", "mad" : Return 0x1F620 ; mad
Case "angry" : Return 0x1F621 ; angry
Case ">:-(", "evil" : Return 0x1F47F ; evil
Case ">:-)", "twisted" : Return 0x1F608 ; twisted
Case "100" : Return 0x1F4AF ; 100
Case "clap" : Return 0x1F44F ; clap
Case "<3", "heart" : Return 0x1F496 ; heart
Case "eyes" : Return 0x1F440 ; eyes
Case "poop" : Return 0x1F4A9 ; poop
Case "thx", "thanx", "thanks" : Return 0x1F64F ; thanks
Case "thumbup", "+1" : Return 0x1F44D ; thumbup
Case "super" : Return 0x1F44C ; super
Case "bullseye", "bulls" : Return 0x1F3AF ; bullseye
Case "thumbdown", "-1" : Return 0x1F44E ; thumbdown
Case "santa" : Return 0x1F385 ; santa
Case "angel" : Return 0x1F607 ; angel
Case "skull" : Return 0x1F480 ; skull
Case "ghost" : Return 0x1F47B ; ghost
Case "alien" : Return 0x1F47D ; alien
}
If Key is number
Return Format("0x{:05x}", Round(Key))
If Key is xdigit
Return Format("0x{:05X}", Round("0x" . LTrim(Key,"0x"))+0)
Return 0
}
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SetClipboardHTML(HtmlBody, HtmlHead:="", AltText:="") { ; v0.66 by SKAN on D393/D396
Local F, Html, pMem, Bytes, hMemHTM:=0, hMemTXT:=0, Res1:=1, Res2:=1 ; @ tiny.cc/t80706
Static CF_UNICODETEXT:=13, CFID:=DllCall("RegisterClipboardFormat", "Str","HTML Format")
If ! DllCall("OpenClipboard", "Ptr",A_ScriptHwnd)
Return 0
Else DllCall("EmptyClipboard")
If (HtmlBody!="")
{
Html := "Version:0.9`r`nStartHTML:00000000`r`nEndHTML:00000000`r`nStartFragment"
. ":00000000`r`nEndFragment:00000000`r`n<!DOCTYPE>`r`n<html>`r`n<head>`r`n"
. HtmlHead . "`r`n</head>`r`n<body>`r`n<!--StartFragment -->`r`n"
. HtmlBody . "`r`n<!--EndFragment -->`r`n</body>`r`n</html>"
Bytes := StrPut(Html, "utf-8")
hMemHTM := DllCall("GlobalAlloc", "Int",0x42, "Ptr",Bytes+4, "Ptr")
pMem := DllCall("GlobalLock", "Ptr",hMemHTM, "Ptr")
StrPut(Html, pMem, Bytes, "utf-8")
F := DllCall("Shlwapi.dll\StrStrA", "Ptr",pMem, "AStr","<html>", "Ptr") - pMem
StrPut(Format("{:08}", F), pMem+23, 8, "utf-8")
F := DllCall("Shlwapi.dll\StrStrA", "Ptr",pMem, "AStr","</html>", "Ptr") - pMem
StrPut(Format("{:08}", F), pMem+41, 8, "utf-8")
F := DllCall("Shlwapi.dll\StrStrA", "Ptr",pMem, "AStr","<!--StartFra", "Ptr") - pMem
StrPut(Format("{:08}", F), pMem+65, 8, "utf-8")
F := DllCall("Shlwapi.dll\StrStrA", "Ptr",pMem, "AStr","<!--EndFragm", "Ptr") - pMem
StrPut(Format("{:08}", F), pMem+87, 8, "utf-8")
DllCall("GlobalUnlock", "Ptr",hMemHTM)
Res1 := DllCall("SetClipboardData", "Int",CFID, "Ptr",hMemHTM)
}
If (AltText!="")
{
Bytes := StrPut(AltText, "utf-16")
hMemTXT := DllCall("GlobalAlloc", "Int",0x42, "Ptr",(Bytes*2)+8, "Ptr")
pMem := DllCall("GlobalLock", "Ptr",hMemTXT, "Ptr")
StrPut(AltText, pMem, Bytes, "utf-16")
DllCall("GlobalUnlock", "Ptr",hMemHTM)
Res2 := DllCall("SetClipboardData", "Int",CF_UNICODETEXT, "Ptr",hMemTXT)
}
DllCall("CloseClipboard")
hMemHTM := hMemHTM ? DllCall("GlobalFree", "Ptr",hMemHTM) : 0
hMemTXT := hMemTXT ? DllCall("GlobalFree", "Ptr",hMemTXT) : 0
Return (Res1 & Res2)
}
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -