How to display emojis original colors?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kauan014
Posts: 55
Joined: 18 Feb 2021, 20:03

How to display emojis original colors?

18 May 2021, 11:43

Code: Select all

gui,add,text,x0 y0,โœ”โค๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ˜‚๐Ÿคฃ๐Ÿ˜Ž๐ŸŽ‰
gui,add,text,x0 y+10 cred,โœ”โค๐Ÿ˜๐Ÿ˜๐Ÿ˜๐Ÿ˜‚๐Ÿคฃ๐Ÿ˜Ž๐ŸŽ‰
gui,show,h150,
They are shown without color.
I can change the color using ccolor but i would like to show their original color, as it show here on the forum ^

image.png
image.png (12.32 KiB) Viewed 1135 times
User avatar
SirSocks
Posts: 360
Joined: 26 Oct 2018, 08:14

Re: How to display emojis original colors?

26 May 2021, 08:10

I second this post *Bump*

I attempted to use ActiveX to display the emojis, which doesn't work. ๐Ÿ˜ฃ

Code: Select all

html_text = <html><a>Here are some emojis. ๐Ÿ˜ƒ ๐Ÿ‘</a></html>
gui,add,ActiveX,w200 h100 vWB, shell explorer
wb.Navigate("about:blank")
wb.document.write(html_text)
gui,show,
return

GuiClose:
ExitApp
Image
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: How to display emojis original colors?

11 Sep 2021, 19:58

I third this post bump

If anyone found a solution please post
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: How to display emojis original colors?

12 Sep 2021, 00:56

Related to this I found the other day an example inside a different type of project, GridGUI by @Capn Odin, an example (Example Unicode.ahk) that used emojis.

The relevant line could be summarized to this:

Code: Select all

Gui, Add, ActiveX, w800 h100, % "about:<!DOCTYPE HTML><head><meta charset=""UTF-8""></head><html><body style=""{margin:0;background-color:#F0F0F0;}""><p style=""font-size:50px;font-family:segoe ui emoji;"">" "๐Ÿฆง๐Ÿถ๐Ÿ•๐Ÿฆฎ๐Ÿ•โ€๐Ÿฆบ๐Ÿฉ๐Ÿบ๐ŸฆŠ๐Ÿฆ๐Ÿฑ๐Ÿˆ๐Ÿˆโ€โฌ›๐Ÿฆ๐Ÿฏ๐Ÿ…๐Ÿ†๐Ÿด๐ŸŽ๐Ÿฆ„" "</p></body></html>"
Gui, Show
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: How to display emojis original colors?

12 Sep 2021, 02:31

safetycar wrote: โ†‘
12 Sep 2021, 00:56
Related to this I found the other day an example inside a different type of project, GridGUI by @Capn Odin, an example (Example Unicode.ahk) that used emojis.

The relevant line could be summarized to this:

Code: Select all

Gui, Add, ActiveX, w800 h100, % "about:<!DOCTYPE HTML><head><meta charset=""UTF-8""></head><html><body style=""{margin:0;background-color:#F0F0F0;}""><p style=""font-size:50px;font-family:segoe ui emoji;"">" "๐Ÿฆง๐Ÿถ๐Ÿ•๐Ÿฆฎ๐Ÿ•โ€๐Ÿฆบ๐Ÿฉ๐Ÿบ๐ŸฆŠ๐Ÿฆ๐Ÿฑ๐Ÿˆ๐Ÿˆโ€โฌ›๐Ÿฆ๐Ÿฏ๐Ÿ…๐Ÿ†๐Ÿด๐ŸŽ๐Ÿฆ„" "</p></body></html>"
Gui, Show
thank you, that is very helpful. I wonder if someone has code to use emojis in text controls so then you could easily update them with GuiControl
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: How to display emojis original colors?

12 Sep 2021, 06:59

AHKStudent wrote: โ†‘
12 Sep 2021, 02:31
I wonder if someone has code to use emojis in text controls so then you could easily update them with GuiControl
You could just use a png set of them.
Combine them in a strip, save the strip in B64 and include a function in your script to separate the strip into its parts for easy display.
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: How to display emojis original colors?

12 Sep 2021, 22:59

Hellbent wrote: โ†‘
12 Sep 2021, 06:59
AHKStudent wrote: โ†‘
12 Sep 2021, 02:31
I wonder if someone has code to use emojis in text controls so then you could easily update them with GuiControl
You could just use a png set of them.
Combine them in a strip, save the strip in B64 and include a function in your script to separate the strip into its parts for easy display.
very helpful tip, thanks
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: How to display emojis original colors?

13 Sep 2021, 04:22

best start learning DirectWrite
image.png
image.png (210 KiB) Viewed 893 times

Code: Select all

#Requires AutoHotkey v1.1.33+
#NoEnv
#SingleInstance Force
#Warn All
SetBatchLines -1

w := h := 450
Gui New, +AlwaysOnTop +HwndhwndGui
Gui Show, w%w% h%h% NoActivate, % A_AhkVersion ": get some emoji going"

GuiClose() {
	ExitApp
}

d2d1 := DllCall("LoadLibrary", "Str", "d2d1.dll", "Ptr")
dwrite := DllCall("LoadLibrary", "Str", "dwrite.dll", "Ptr")
ole32 := DllCall("LoadLibrary", "Str", "ole32.dll", "Ptr")

VarSetCapacity(IID_ID2D1Factory, 16)
DllCall("ole32\CLSIDFromString", "Str", "{06152247-6f50-465a-9245-118bfd3b6007}", "Ptr", &IID_ID2D1Factory)

; HRESULT D2D1CreateFactory(
;   D2D1_FACTORY_TYPE          factoryType,
;   REFIID                     riid,
;   const D2D1_FACTORY_OPTIONS *pFactoryOptions,
;   void                       **ppIFactory
; );
DllCall("d2d1\D2D1CreateFactory"
	, "Int", 0 ; D2D1_FACTORY_TYPE_SINGLE_THREADED
	, "Ptr", &IID_ID2D1Factory
	, "Ptr", 0 ; D2D1_FACTORY_OPTIONS
	, "Ptr*", pID2D1Factory := 0)

; ID2D1Factory : public IUnknown
;  0: QueryInterface
;  1: AddRef
;  2: Release
;  3: ReloadSystemMetrics
;  4: GetDesktopDpi
;  5: CreateRectangleGeometry
;  6: CreateRoundedRectangleGeometry
;  7: CreateEllipseGeometry
;  8: CreateGeometryGroup
;  9: CreateTransformedGeometry
; 10: CreatePathGeometry
; 11: CreateStrokeStyle
; 12: CreateDrawingStateBlock
; 13: CreateWicBitmapRenderTarget
; 14: CreateHwndRenderTarget
; 15: CreateDxgiSurfaceRenderTarget
; 16: CreateDCRenderTarget

; typedef struct D2D1_RENDER_TARGET_PROPERTIES {
;   D2D1_RENDER_TARGET_TYPE  type;
;   D2D1_PIXEL_FORMAT        pixelFormat;
;   FLOAT                    dpiX;
;   FLOAT                    dpiY;
;   D2D1_RENDER_TARGET_USAGE usage;
;   D2D1_FEATURE_LEVEL       minLevel;
; } D2D1_RENDER_TARGET_PROPERTIES;
VarSetCapacity(renderTargetProperties, 28, 0) ; zero initialize -> all defaults

; typedef struct D2D1_HWND_RENDER_TARGET_PROPERTIES {
;   HWND                 hwnd;
;   D2D1_SIZE_U          pixelSize;
;   D2D1_PRESENT_OPTIONS presentOptions;
; } D2D1_HWND_RENDER_TARGET_PROPERTIES;
VarSetCapacity(hwndRenderTargetProperties, (A_PtrSize = 4) ? 16 : 24)
NumPut(hwndGui, hwndRenderTargetProperties, 0, "Ptr")
NumPut(w, hwndRenderTargetProperties, A_PtrSize, "UInt")
NumPut(h, hwndRenderTargetProperties, A_PtrSize + 4, "UInt")
NumPut(0, hwndRenderTargetProperties, A_PtrSize + 8, "UInt") ; D2D1_PRESENT_OPTIONS_NONE

; HRESULT CreateHwndRenderTarget(
;   const D2D1_RENDER_TARGET_PROPERTIES &      renderTargetProperties,
;   const D2D1_HWND_RENDER_TARGET_PROPERTIES & hwndRenderTargetProperties,
;   ID2D1HwndRenderTarget                      **hwndRenderTarget
; );
; 14: CreateHwndRenderTarget
DllCall(vtbl(14, pID2D1Factory), "Ptr", pID2D1Factory
	, "Ptr", &renderTargetProperties
	, "Ptr", &hwndRenderTargetProperties
	, "Ptr*", pHwndRenderTarget := 0)

vtbl(methodIndex, rawComPtr) {
	return NumGet(NumGet(rawComPtr+0, "Ptr") + A_PtrSize * methodIndex, "Ptr")
}

; ID2D1RenderTarget : public ID2D1Resource : public IUnknown
;  0: QueryInterface
;  1: AddRef
;  2: Release
;  3: GetFactory
;  4: CreateBitmap
;  5: CreateBitmapFromWicBitmap
;  6: CreateSharedBitmap
;  7: CreateBitmapBrush
;  8: CreateSolidColorBrush
;  9: CreateGradientStopCollection
; 10: CreateLinearGradientBrush
; 11: CreateRadialGradientBrush
; 12: CreateCompatibleRenderTarget
; 13: CreateLayer
; 14: CreateMesh
; 15: DrawLine
; 16: DrawRectangle
; 17: FillRectangle
; 18: DrawRoundedRectangle
; 19: FillRoundedRectangle
; 20: DrawEllipse
; 21: FillEllipse
; 22: DrawGeometry
; 23: FillGeometry
; 24: FillMesh
; 25: FillOpacityMask
; 26: DrawBitmap
; 27: DrawText
; 28: DrawTextLayout
; 29: DrawGlyphRun
; 30: SetTransform
; 31: GetTransform
; 32: SetAntialiasMode
; 33: GetAntialiasMode
; 34: SetTextAntialiasMode
; 35: GetTextAntialiasMode
; 36: SetTextRenderingParams
; 37: GetTextRenderingParams
; 38: SetTags
; 39: GetTags
; 40: PushLayer
; 41: PopLayer
; 42: Flush
; 43: SaveDrawingState
; 44: RestoreDrawingState
; 45: PushAxisAlignedClip
; 46: PopAxisAlignedClip
; 47: Clear
; 48: BeginDraw
; 49: EndDraw
; 50: GetPixelFormat
; 51: SetDpi
; 52: GetDpi
; 53: GetSize
; 54: GetPixelSize
; 55: GetMaximumBitmapSize
; 56: IsSupported

; struct D3DCOLORVALUE {
;   FLOAT r;
;   FLOAT g;
;   FLOAT b;
;   FLOAT a;
; };
VarSetCapacity(fontBrushColor, 16) ; black
NumPut(0, fontBrushColor, 0, "Float")
NumPut(0, fontBrushColor, 4, "Float")
NumPut(0, fontBrushColor, 8, "Float")
NumPut(1, fontBrushColor, 12, "Float")

; HRESULT CreateSolidColorBrush(
;   const D2D1_COLOR_F &          color,
;   const D2D1_BRUSH_PROPERTIES & brushProperties,
;   ID2D1SolidColorBrush          **solidColorBrush
; );
; 8: CreateSolidColorBrush
DllCall(vtbl(8, pHwndRenderTarget), "Ptr", pHwndRenderTarget
	, "Ptr", &fontBrushColor
	, "Ptr", 0 ; default brush properties
	, "Ptr*", pBrush := 0)

VarSetCapacity(IID_IDWriteFactory, 16)
DllCall("ole32\CLSIDFromString", "Str", "{b859ee5a-d838-4b5b-a2e8-1adc7d93db48}", "Ptr", &IID_IDWriteFactory)

; HRESULT DWriteCreateFactory(
;   DWRITE_FACTORY_TYPE factoryType,
;   REFIID              iid,
;   IUnknown            **factory
; );
DllCall("dwrite\DWriteCreateFactory"
	, "Int", 0 ; DWRITE_FACTORY_TYPE_SHARED
	, "Ptr", &IID_IDWriteFactory
	, "Ptr*", pIDWriteFactory := 0)

; IDWriteFactory : public IUnknown
;  3: GetSystemFontCollection
;  4: CreateCustomFontCollection
;  5: RegisterFontCollectionLoader
;  6: UnregisterFontCollectionLoader
;  7: CreateFontFileReference
;  8: CreateCustomFontFileReference
;  9: CreateFontFace
; 10: CreateRenderingParams
; 11: CreateMonitorRenderingParams
; 12: CreateCustomRenderingParams
; 13: RegisterFontFileLoader
; 14: UnregisterFontFileLoader
; 15: CreateTextFormat
; 16: CreateTypography
; 17: GetGdiInterop
; 18: CreateTextLayout
; 19: CreateGdiCompatibleTextLayout
; 20: CreateEllipsisTrimmingSign
; 21: CreateTextAnalyzer
; 22: CreateNumberSubstitution
; 23: CreateGlyphRunAnalysis

; HRESULT CreateTextFormat(
;   WCHAR const           *fontFamilyName,
;   IDWriteFontCollection *fontCollection,
;   DWRITE_FONT_WEIGHT    fontWeight,
;   DWRITE_FONT_STYLE     fontStyle,
;   DWRITE_FONT_STRETCH   fontStretch,
;   FLOAT                 fontSize,
;   WCHAR const           *localeName,
;   IDWriteTextFormat     **textFormat
; );
; 15: CreateTextFormat
DllCall(vtbl(15, pIDWriteFactory), "Ptr", pIDWriteFactory
	, "WStr", "Segoe UI Emoji"
	, "Ptr", 0 ; fontCollection
	, "Int", 400 ; DWRITE_FONT_WEIGHT_NORMAL
	, "Int", 0 ; DWRITE_FONT_STYLE_NORMAL
	, "Int", 5 ; DWRITE_FONT_STRETCH_NORMAL
	, "Float", 18 ; fontSize
	, "WStr", "" ; localeName
	, "Ptr*", pTextFormat := 0)

; void BeginDraw();
; 48: BeginDraw
DllCall(vtbl(48, pHwndRenderTarget), "Ptr", pHwndRenderTarget)

; struct D3DCOLORVALUE {
;   FLOAT r;
;   FLOAT g;
;   FLOAT b;
;   FLOAT a;
; };
VarSetCapacity(backgroundColor, 16) ; grey
NumPut(0.9, backgroundColor, 0, "Float")
NumPut(0.9, backgroundColor, 4, "Float")
NumPut(0.9, backgroundColor, 8, "Float")
NumPut(1.0, backgroundColor, 12, "Float")

; void Clear(
;   const D2D1_COLOR_F *clearColor
; );
; 47: Clear
DllCall(vtbl(47, pHwndRenderTarget), "Ptr", pHwndRenderTarget, "Ptr", &backgroundColor)

text := "๐ŸŒ‚๐ŸŒƒ๐ŸŒ„๐ŸŒ…๐ŸŒ†๐ŸŒ‡๐ŸŒˆ๐ŸŒ‰๐ŸŒŠ๐ŸŒ‹๐ŸŒ๐ŸŒŽ๐ŸŒ๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•๐ŸŒ–๐ŸŒ—๐ŸŒ˜๐ŸŒ๐ŸŒž๐ŸŒฑ๐ŸŒฒ๐ŸŒณ๐ŸŒด๐ŸŒท๐ŸŒน๐ŸŒป๐ŸŒฝ๐ŸŒพ๐Ÿ…๐Ÿ†๐Ÿ‡๐Ÿˆ๐Ÿ‰๐ŸŒ๐Ÿ๐ŸŽ๐Ÿ๐Ÿ๐Ÿ‘๐Ÿ’๐Ÿ“๐Ÿ”๐Ÿ•๐Ÿ–๐Ÿ—๐Ÿ˜๐Ÿ›๐Ÿœ๐Ÿ๐ŸŸ๐Ÿ ๐Ÿก๐Ÿข๐Ÿฃ๐Ÿค๐Ÿฅ๐Ÿฆ๐Ÿง๐Ÿจ๐Ÿฉ๐Ÿช๐Ÿซ๐Ÿฌ๐Ÿญ๐Ÿฎ๐Ÿฏ๐Ÿฐ๐Ÿฑ๐Ÿฒ๐Ÿณ๐Ÿต๐Ÿน๐Ÿบ๐Ÿป๐Ÿผ๐ŸŽ‚๐ŸŽƒ๐ŸŽ„๐ŸŽ…๐ŸŽ†๐ŸŽ‡๐ŸŽ‰๐ŸŽŠ๐ŸŽ‹๐ŸŽŒ๐ŸŽ๐ŸŽŽ๐ŸŽ๐ŸŽ‘๐ŸŽ“๐ŸŽ ๐ŸŽก๐ŸŽข๐ŸŽฃ๐ŸŽค๐ŸŽฆ๐ŸŽจ๐ŸŽฏ๐ŸŽฐ๐ŸŽฑ๐ŸŽณ๐ŸŽด๐ŸŽป๐ŸŽผ๐ŸŽพ๐ŸŽฟ๐Ÿ€๐Ÿ๐Ÿ‚๐Ÿ„๐Ÿ‡๐ŸŠ๐Ÿก๐Ÿค๐Ÿฆ๐Ÿง๐Ÿฉ๐Ÿซ๐Ÿฌ๐ŸŒ๐Ÿ“๐Ÿ๐Ÿ ๐Ÿก๐Ÿข๐Ÿฃ๐Ÿณ๐Ÿต๐Ÿถ๐Ÿธ๐Ÿน๐Ÿ‘†๐Ÿ‘‡๐Ÿ‘ˆ๐Ÿ‘‰๐Ÿ‘Š๐Ÿ‘’๐Ÿ‘”๐Ÿ‘›๐Ÿ‘๐Ÿ‘ฆ๐Ÿ‘ง๐Ÿ‘จ๐Ÿ‘ฉ๐Ÿ‘ฎ๐Ÿ‘ฏ๐Ÿ‘ฐ๐Ÿ‘ฑ๐Ÿ‘ฒ๐Ÿ‘ณ๐Ÿ‘ด๐Ÿ‘ต๐Ÿ‘ถ๐Ÿ‘ท๐Ÿ‘ธ๐Ÿ‘น๐Ÿ‘บ๐Ÿ‘ผ๐Ÿ‘พ๐Ÿ’‚๐Ÿ’„๐Ÿ’…๐Ÿ’†๐Ÿ’‡๐Ÿ’ˆ๐Ÿ’‰๐Ÿ’Š๐Ÿ’‹๐Ÿ’Œ๐Ÿ’๐Ÿ’‘๐Ÿ’’๐Ÿ’˜๐Ÿ’๐Ÿ’Ÿ๐Ÿ’จ๐Ÿ’ฉ๐Ÿ’ฑ๐Ÿ’น๐Ÿ’บ๐Ÿ’พ๐Ÿ“ˆ๐Ÿ“‰๐Ÿ“Š๐Ÿ“Œ๐Ÿ“๐Ÿ“‘๐Ÿ““๐Ÿ“”๐Ÿ“›๐Ÿ“๐Ÿ“Ÿ๐Ÿ“ฃ๐Ÿ“ต๐Ÿ”ž๐Ÿ”ซ๐Ÿ˜๐Ÿ˜‚๐Ÿ˜ƒ๐Ÿ˜„๐Ÿ˜…๐Ÿ˜†๐Ÿ˜‡๐Ÿ˜ˆ๐Ÿ˜‰๐Ÿ˜Š๐Ÿ˜‹๐Ÿ˜Œ๐Ÿ˜๐Ÿ˜Ž๐Ÿ˜๐Ÿ˜๐Ÿ˜’๐Ÿ˜“๐Ÿ˜”๐Ÿ˜–๐Ÿ˜˜๐Ÿ˜š๐Ÿ˜œ๐Ÿ˜๐Ÿ˜ž๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ข๐Ÿ˜ฃ๐Ÿ˜ค๐Ÿ˜ฅ๐Ÿ˜จ๐Ÿ˜ฉ๐Ÿ˜ช๐Ÿ˜ซ๐Ÿ˜ญ๐Ÿ˜ฐ๐Ÿ˜ฑ๐Ÿ˜ฒ๐Ÿ˜ณ๐Ÿ˜ต๐Ÿ˜ถ๐Ÿ˜ท๐Ÿ™…๐Ÿ™†๐Ÿ™‡๐Ÿ™ˆ๐Ÿ™‰๐Ÿ™Š๐Ÿ™‹๐Ÿ™Œ๐Ÿ™๐Ÿ™Ž๐Ÿ™๐Ÿš€๐Ÿšƒ๐Ÿš„๐Ÿš…๐Ÿš†๐Ÿšˆ๐Ÿš‰๐ŸšŠ๐Ÿš‹๐ŸšŒ๐Ÿš๐ŸšŽ๐Ÿš๐Ÿš"

; typedef struct D2D_RECT_F {
;   FLOAT left;
;   FLOAT top;
;   FLOAT right;
;   FLOAT bottom;
; } D2D_RECT_F;
VarSetCapacity(layoutRect, 16)
NumPut(0, layoutRect, 0, "Float")
NumPut(0, layoutRect, 4, "Float")
NumPut(w, layoutRect, 8, "Float")
NumPut(h, layoutRect, 12, "Float")

; void DrawText(
;   const WCHAR            *string,
;   UINT32                 stringLength,
;   IDWriteTextFormat      *textFormat,
;   const D2D1_RECT_F      *layoutRect,
;   ID2D1Brush             *defaultFillBrush,
;   D2D1_DRAW_TEXT_OPTIONS options,
;   DWRITE_MEASURING_MODE  measuringMode
; );
; 27: DrawText
DllCall(vtbl(27, pHwndRenderTarget), "Ptr", pHwndRenderTarget
	, "Str", text
	, "UInt", StrLen(text)
	, "Ptr", pTextFormat
	, "Ptr", &layoutRect
	, "Ptr", pBrush
	, "Int", 0x00000004 ; D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT
	, "Int", 0) ; DWRITE_MEASURING_MODE_NATURAL

; HRESULT EndDraw(
;   D2D1_TAG *tag1,
;   D2D1_TAG *tag2
; );
; 49: EndDraw
DllCall(vtbl(49, pHwndRenderTarget), "Ptr", pHwndRenderTarget
	, "Ptr*", pTag1 := 0
	, "Ptr*", pTag2 := 0)

ObjRelease(pTextFormat)
ObjRelease(pIDWriteFactory)
ObjRelease(pBrush)
ObjRelease(pHwndRenderTarget)
ObjRelease(pID2D1Factory)

Return to โ€œAsk for Help (v1)โ€

Who is online

Users browsing this forum: Descolada, hiahkforum, jchestnut, mcd, Sem552, ShatterCoder and 110 guests