-
Posts
7,428 -
Joined
-
Last visited
-
Days Won
93
UEZ last won the day on January 15
UEZ had the most liked content!
About UEZ

- Birthday 12/03/2007
Profile Information
-
Member Title
Never say never
-
Location
Germany
-
Interests
Computer, watching movies, football (soccer), being lazy :-)
UEZ's Achievements
-
argumentum reacted to a post in a topic:
SampleControls.au3 in Dark Mode
-
WildByDesign reacted to a post in a topic:
SampleControls.au3 in Dark Mode
-
Added "About" menu entry in Sysmenu (left upper corner in the GUI) and in "Menu One". Check out _WM_MENUCOMMAND function. See first post.
-
wakillon reacted to a post in a topic:
AutoIt Snippets
-
ioa747 reacted to a post in a topic:
AutoIt Snippets
-
mLipok reacted to a post in a topic:
AutoIt Snippets
-
argumentum reacted to a post in a topic:
AutoIt Snippets
-
Not that I know of.
-
What you see is GDI+ bitmaps which can be used in picture controls when converted to GDI bitmap format. Picture control is clickable. In D2D you can perform Hit Testing on a Text Layout using HitTestPoint. I never used it. You can refer to https://unicode.org/emoji/charts/full-emoji-list.html. Depending on your Windows version you can use them.
-
mLipok reacted to a post in a topic:
AutoIt Snippets
-
Convert Emojis to GDI+ using Direct2D / DWrite. ;Coded by UEZ build 2026-01-10 ;Direct2D code by Eukalyptus / trancexx #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> If @OSBuild < 9600 Then Exit MsgBox($MB_ICONERROR, "ERROR", "Windows 8.1 or higher required!", 30) Global Const $WICERR_NOOBJ = 0x800710D8 Global Const $sGUID_WICPixelFormat32bppPBGRA = "{6fddc324-4e03-4bfe-b185-3d77768dc910}" Global Const $sCLSID_WICImagingFactory = "{cacaf262-9370-4615-a13b-9f5539da4c0a}" Global Const $sIID_IWICImagingFactory = "{ec5ec8a9-c395-4314-9c77-54d7a935ff70}" Global Const $sIID_IWICBitmap = "{00000121-a8f2-4877-ba0a-fd2b6645fb94}" Global Const $tagIWICBitmapSource = "GetSize hresult(uint*;uint*);" & "GetPixelFormat hresult(struct*);" & "GetResolution hresult(double*;double*);" & "CopyPalette hresult(struct*);" & "CopyPixels hresult(struct*;uint;uint;struct*);" Global Const $tagIWICImagingFactory = "CreateDecoderFromFilename hresult(wstr;struct*;uint;uint;ptr*);" & "CreateDecoderFromStream hresult(struct*;struct*;uint;ptr*);" & "CreateDecoderFromFileHandle hresult(handle;struct*;uint;ptr*);" & "CreateComponentInfo hresult(struct*;ptr*);" & "CreateDecoder hresult(struct*;struct*;ptr*);" & "CreateEncoder hresult(struct*;struct*;ptr*);" & "CreatePalette hresult(ptr*);" & "CreateFormatConverter hresult(ptr*);" & "CreateBitmapScaler hresult(ptr*);" & "CreateBitmapClipper hresult(ptr*);" & "CreateBitmapFlipRotator hresult(ptr*);" & "CreateStream hresult(ptr*);" & "CreateColorContext hresult(ptr*);" & "CreateColorTransformer hresult(ptr*);" & "CreateBitmap hresult(uint;uint;struct*;uint;ptr*);" & "CreateBitmapFromSource hresult(struct*;uint;ptr*);" & "CreateBitmapFromSourceRect hresult(struct*;uint;uint;uint;uint;ptr*);" & "CreateBitmapFromMemory hresult(uint;uint;struct*;uint;uint;struct*;ptr*);" & "CreateBitmapFromHBITMAP hresult(handle;handle;uint;ptr*);" & "CreateBitmapFromHICON hresult(handle;ptr*);" & "CreateComponentEnumerator hresult(uint;uint;ptr*);" & "CreateFastMetadataEncoderFromDecoder hresult(struct*;ptr*);" & "CreateFastMetadataEncoderFromFrameDecode hresult(struct*;ptr*);" & "CreateQueryWriter hresult(struct*;struct*;ptr*);" & "CreateQueryWriterFromReader hresult(struct*;struct*;ptr*);" Global Const $tagIWICBitmap = $tagIWICBitmapSource & "Lock hresult(struct*;uint;ptr*);" & "SetPalette hresult(struct*);" & "SetResolution hresult(double;double);" Global Const $DWRITEERR_NOOBJ = 0x800710D8 Global Const $sIID_IDWriteFactory = "{b859ee5a-d838-4b5b-a2e8-1adc7d93db48}" Global Const $sIID_IDWriteTextFormat = "{9c906818-31d7-4fd3-a151-7c5e225db55a}" Global Const $tagIDWriteFactory = "GetSystemFontCollection hresult(ptr*;bool);" & "CreateCustomFontCollection hresult(struct*;struct*;uint;ptr*);" & "RegisterFontCollectionLoader hresult(struct*);" & "UnregisterFontCollectionLoader hresult(struct*);" & "CreateFontFileReference hresult(wstr;struct*;ptr*);" & "CreateCustomFontFileReference hresult(struct*;uint;struct*;ptr*);" & "CreateFontFace hresult(uint;uint;struct*;uint;uint;ptr*);" & "CreateRenderingParams hresult(ptr*);" & "CreateMonitorRenderingParams hresult(handle;ptr*);" & "CreateCustomRenderingParams hresult(float;float;float;uint;uint;ptr*);" & "RegisterFontFileLoader hresult(struct*);" & "UnregisterFontFileLoader hresult(struct*);" & "CreateTextFormat hresult(wstr;struct*;uint;uint;uint;float;wstr;ptr*);" & "CreateTypography hresult(ptr*);" & "GetGdiInterop hresult(ptr*);" & "CreateTextLayout hresult(wstr;uint;struct*;float;float;ptr*);" & "CreateGdiCompatibleTextLayout hresult(wstr;uint;struct*;float;float;float;struct*;bool;ptr*);" & "CreateEllipsisTrimmingSign hresult(struct*;ptr*);" & "CreateTextAnalyzer hresult(ptr*);" & "CreateNumberSubstitution hresult(uint;wstr;bool;ptr*);" & "CreateGlyphRunAnalysis hresult(struct*;float;struct*;uint;uint;float;float;ptr*);" Global Const $tagIDWriteTextFormat = "SetTextAlignment hresult(uint);" & "SetParagraphAlignment hresult(uint);" & "SetWordWrapping hresult(uint);" & "SetReadingDirection hresult(uint);" & "SetFlowDirection hresult(uint);" & "SetIncrementalTabStop hresult(float);" & "SetTrimming hresult(struct*;ptr*);" & "SetLineSpacing hresult(uint;float;float);" & "GetTextAlignment uint();" & "GetParagraphAlignment uint();" & "GetWordWrapping uint();" & "GetReadingDirection uint();" & "GetFlowDirection uint();" & "GetIncrementalTabStop float();" & "GetTrimming hresult(struct*;ptr*);" & "GetLineSpacing hresult(uint*;float*float*);" & "GetFontCollection hresult(ptr*);" & "GetFontFamilyNameLength uint(wstr;uint);" & "GetFontFamilyName hresult();" & "GetFontWeight uint();" & "GetFontStyle uint();" & "GetFontStretch uint();" & "GetFontSize float();" & "GetLocaleNameLength uint();" & "GetLocaleName hresult(wstr;uint);" Global Const $D2DERR_NOOBJ = 0x800710D8 Global Const $D2DERR_UFAIL = 0x8000FFFF Global Const $tagD2D1_MATRIX_3X2_F = "struct; float M11; float M12; float M21; float M22; float M31; float M32; endstruct;" Global Const $tagD2D1_COLOR_F = "struct; float R; float G; float B; float A; endstruct;" Global Const $tagD2D1_RECT_F = "struct; float Left; float Top; float Right; float Bottom; endstruct;" Global Const $tagD2D1_BRUSH_PROPERTIES = "struct; float Opacity; float M11; float M12; float M21; float M22; float M31; float M32; endstruct;" Global Const $tagD2D1_RENDER_TARGET_PROPERTIES = "struct; uint Type; uint PixelFormat; uint AlphaMode; float DpiX; float DpiY; uint Usage; uint MinLevel; endstruct;" Global Const $sIID_ID2D1SolidColorBrush = "{2cd906a9-12e2-11dc-9fed-001143a055f9}" Global Const $sIID_ID2D1RenderTarget = "{2cd90694-12e2-11dc-9fed-001143a055f9}" Global Const $sIID_ID2D1Factory = "{06152247-6f50-465a-9245-118bfd3b6007}" Global Const $tagID2D1Resource = "GetFactory none(ptr*);" Global Const $tagID2D1Brush = $tagID2D1Resource & "SetOpacity none(float);" & "SetTransform none(struct*);" & "GetOpacity float();" & "GetTransform none(struct*);" Global Const $tagID2D1SolidColorBrush = $tagID2D1Brush & "SetColor none(struct*);" & "GetColor ptr(struct*);" Global Const $tagID2D1RenderTarget = $tagID2D1Resource & "CreateBitmap hresult(struct;struct*;uint;struct*;ptr*);" & "CreateBitmapFromWicBitmap hresult(struct*;struct*;ptr*);" & "CreateSharedBitmap hresult(struct*;struct*;struct*;ptr*);" & "CreateBitmapBrush hresult(struct*;struct*;struct*;ptr*);" & "CreateSolidColorBrush hresult(struct*;struct*;ptr*);" & "CreateGradientStopCollection hresult(struct*;uint;uint;uint;ptr*);" & "CreateLinearGradientBrush hresult(struct*;struct*;struct*;ptr*);" & "CreateRadialGradientBrush hresult(struct*;struct*;struct*;ptr*);" & "CreateCompatibleRenderTarget hresult(struct*;struct*;struct*;uint;ptr*);" & "CreateLayer hresult(struct*;ptr*);" & "CreateMesh hresult(ptr*);" & "DrawLine none(struct;struct;struct*;float;struct*);" & "DrawRectangle none(struct*;struct*;float;struct*);" & "FillRectangle none(struct*;struct*);" & "DrawRoundedRectangle none(struct*;struct*;float;struct*);" & "FillRoundedRectangle none(struct*;struct*);" & "DrawEllipse none(struct*;struct*;float;struct*);" & "FillEllipse none(struct*;struct*);" & "DrawGeometry none(struct*;struct*;float;struct*);" & "FillGeometry none(struct*;struct*;struct*);" & "FillMesh none(struct*;struct*);" & "FillOpacityMask none(struct*;struct*;uint;struct*;struct*);" & "DrawBitmap none(struct*;struct*;float;uint;struct*);" & "DrawText none(wstr;uint;struct*;struct*;struct*;uint;uint);" & "DrawTextLayout none(struct;struct*;struct*;uint);" & "DrawGlyphRun none(struct;struct*;struct*;uint);" & "SetTransform none(struct*);" & "GetTransform none(struct*);" & "SetAntialiasMode none(uint);" & "GetAntialiasMode uint();" & "SetTextAntialiasMode none(uint);" & "GetTextAntialiasMode uint();" & "SetTextRenderingParams none(struct*);" & "GetTextRenderingParams none(ptr*);" & "SetTags none(uint64;uint64);" & "GetTags none(uint64*;uint64*);" & "PushLayer none(struct*;struct*);" & "PopLayer none();" & "Flush hresult(uint64*;uint64*);" & "SaveDrawingState none(struct*);" & "RestoreDrawingState none(struct*);" & "PushAxisAlignedClip none(struct*;uint);" & "PopAxisAlignedClip none();" & "Clear none(struct*);" & "BeginDraw none();" & "EndDraw hresult(uint64*;uint64*);" & "GetPixelFormat ptr(struct*);" & "SetDpi none(float;float);" & "GetDpi none(float*;float*);" & "GetSize ptr(struct*);" & "GetPixelSize ptr(struct*);" & "GetMaximumBitmapSize uint();" & "IsSupported bool(struct*);" Global Const $tagID2D1Factory = "ReloadSystemMetrics hresult();" & "GetDesktopDpi none(float*;float*);" & "CreateRectangleGeometry hresult(struct*;ptr*);" & "CreateRoundedRectangleGeometry hresult(struct*;ptr*);" & "CreateEllipseGeometry hresult(struct*;ptr*);" & "CreateGeometryGroup hresult(uint;struct*;uint;ptr*);" & "CreateTransformedGeometry hresult(struct*;struct*;ptr*);" & "CreatePathGeometry hresult(ptr*);" & "CreateStrokeStyle hresult(struct*;struct*;uint;ptr*);" & "CreateDrawingStateBlock hresult(struct*;struct*;ptr*);" & "CreateWicBitmapRenderTarget hresult(struct*;struct*;ptr*);" & "CreateHwndRenderTarget hresult(struct*;struct*;ptr*);" & "CreateDxgiSurfaceRenderTarget hresult(struct*;struct*;ptr*);" & "CreateDCRenderTarget hresult(struct*;ptr*);" Global Const $D2D1_TEXT_ANTIALIAS_MODE_DEFAULT = 0 Global Const $D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE = 1 Global Const $D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE = 2 Global Const $D2D1_TEXT_ANTIALIAS_MODE_ALIASED = 3 Global Const $DWRITE_TEXT_ALIGNMENT_LEADING = 0 Global Const $DWRITE_TEXT_ALIGNMENT_TRAILING = 1 Global Const $DWRITE_TEXT_ALIGNMENT_CENTER = 2 Global Const $DWRITE_PARAGRAPH_ALIGNMENT_NEAR = 0 Global Const $DWRITE_PARAGRAPH_ALIGNMENT_FAR = 1 Global Const $DWRITE_PARAGRAPH_ALIGNMENT_CENTER = 2 Global Const $D2D1_ANTIALIAS_MODE_PER_PRIMITIVE = 0 Global Const $D2D1_ANTIALIAS_MODE_ALIASED = 1 Global Const $D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT = 4 Global Const $DWRITE_MEASURING_MODE_NATURAL = 0 Global Const $__g_hD2D1DLL = DllOpen("d2d1.dll") Global Const $__g_hDWriteDLL = DllOpen("dwrite.dll") Global $oD2DFactory = _D2D_Factory_Create() If Not IsObj($oD2DFactory) Then MsgBox(16, "Error", "Failed to create D2D Factory!") Exit EndIf Global $oWICFactory = _WIC_ImagingFactory_Create() If Not IsObj($oWICFactory) Then MsgBox(16, "Error", "Failed to create WIC Imaging Factory!") Exit EndIf Global $oDWriteFactory = _DWrite_Factory_Create() If Not IsObj($oDWriteFactory) Then MsgBox(16, "Error", "Failed to create DWrite Factory!") Exit EndIf _GDIPlus_Startup() Global $hGUI = GUICreate("DirectWrite Color Emoji -> GDI+ Bitmap", 600, 280) GUISetBkColor(0xF5F5F5) Global $hEmoji1 = D2D1_RenderEmojiToGDIpBitmap($oD2DFactory, $oWICFactory, $oDWriteFactory, _EmojiFromCodePoint(0x1F600), 96) ; 😀 Global $hEmoji2 = D2D1_RenderEmojiToGDIpBitmap($oD2DFactory, $oWICFactory, $oDWriteFactory, _EmojiFromCodePoint(0x1F525), 96) ; 🔥 Global $hEmoji3 = D2D1_RenderEmojiToGDIpBitmap($oD2DFactory, $oWICFactory, $oDWriteFactory, _EmojiFromCodePoint(0x1F680), 96) ; 🚀 Global $hEmoji4 = D2D1_RenderEmojiToGDIpBitmap($oD2DFactory, $oWICFactory, $oDWriteFactory, _EmojiFromCodePoint(0x2764), 96) ; ❤ GUISetState(@SW_SHOW) GUIRegisterMsg($WM_PAINT, "_OnPaint") _WinAPI_RedrawWindow($hGUI) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Cleanup() Exit EndSwitch WEnd Func _OnPaint($hWnd, $iMsg, $wParam, $lParam) Local $tPaintStruct = DllStructCreate($tagPAINTSTRUCT) Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaintStruct) If @error Then Return $GUI_RUNDEFMSG Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($hGraphics, $GDIP_TEXTRENDERINGHINTANTIALIAS) Local $xPos = 80 If $hEmoji1 Then _GDIPlus_GraphicsDrawImage($hGraphics, $hEmoji1, $xPos, 30) If $hEmoji2 Then _GDIPlus_GraphicsDrawImage($hGraphics, $hEmoji2, $xPos + 110, 30) If $hEmoji3 Then _GDIPlus_GraphicsDrawImage($hGraphics, $hEmoji3, $xPos + 220, 30) If $hEmoji4 Then _GDIPlus_GraphicsDrawImage($hGraphics, $hEmoji4, $xPos + 330, 30) Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI") Local $hFont = _GDIPlus_FontCreate($hFamily, 22, 1) Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) Local $tLayout = _GDIPlus_RectFCreate(0, 160, 600, 50) $hBrush = _GDIPlus_BrushCreateSolid(0xFF1B5E20) _GDIPlus_GraphicsDrawStringEx($hGraphics, "DirectWrite + Direct2D + GDI+", $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_GraphicsDispose($hGraphics) _WinAPI_EndPaint($hWnd, $tPaintStruct) Return $GUI_RUNDEFMSG EndFunc ;==>_OnPaint Func D2D1_RenderEmojiToGDIpBitmap($oD2DFactory, $oWICFactory, $oDWriteFactory, $sEmoji, $iSize) Local $oWICBitmap = _WIC_ImagingFactory_CreateBitmap($oWICFactory, $iSize, $iSize, $sGUID_WICPixelFormat32bppPBGRA, 0x1) If Not IsObj($oWICBitmap) Then Return SetError(-1, 0, 0) Local $oRenderTarget = _D2D_Factory_CreateWicBitmapRenderTarget($oD2DFactory, $oWICBitmap) If Not IsObj($oRenderTarget) Then $oWICBitmap = 0 Return SetError(-2, 0, 0) EndIf Local $oTextFormat = _DWrite_Factory_CreateTextFormat($oDWriteFactory, "Segoe UI Emoji", $iSize * 0.75) If Not IsObj($oTextFormat) Then $oRenderTarget = 0 $oWICBitmap = 0 Return SetError(-3, 0, 0) EndIf $oTextFormat.SetTextAlignment($DWRITE_TEXT_ALIGNMENT_CENTER) $oTextFormat.SetParagraphAlignment($DWRITE_PARAGRAPH_ALIGNMENT_CENTER) $oRenderTarget.SetTextAntialiasMode($D2D1_TEXT_ANTIALIAS_MODE_ALIASED) $oRenderTarget.SetAntialiasMode($D2D1_ANTIALIAS_MODE_ALIASED) $oRenderTarget.BeginDraw() _D2D_RenderTarget_Clear($oRenderTarget, 0, 0, 0, 0) Local $oBrush = _D2D_RenderTarget_CreateSolidColorBrush($oRenderTarget, 0, 0, 0, 0) $oRenderTarget.DrawText($sEmoji, StringLen($sEmoji), $oTextFormat, _D2D1_RECT_F(0, 0, $iSize, $iSize), $oBrush, $D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT, $DWRITE_MEASURING_MODE_NATURAL) $oRenderTarget.EndDraw(Null, Null) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iSize, $iSize, $GDIP_PXF32ARGB) If Not $hBitmap Then $oBrush = 0 $oTextFormat = 0 $oRenderTarget = 0 $oWICBitmap = 0 Return SetError(-4, 0, 0) EndIf Local $tBitmapData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $iSize, $iSize, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) Local $pScan0 = $tBitmapData.Scan0 Local $iStride = $iSize * 4 Local $tRect = DllStructCreate($tagRECT) $tRect.Left = 0 $tRect.Top = 0 $tRect.Right = $iSize $tRect.Bottom = $iSize $oWICBitmap.CopyPixels($tRect, $iStride, $iStride * $iSize, $pScan0) _GDIPlus_BitmapUnlockBits($hBitmap, $tBitmapData) $oBrush = 0 $oTextFormat = 0 $oRenderTarget = 0 $oWICBitmap = 0 Return $hBitmap EndFunc ;==>D2D1_RenderEmojiToGDIpBitmap Func _Cleanup() If $hEmoji1 Then _GDIPlus_ImageDispose($hEmoji1) If $hEmoji2 Then _GDIPlus_ImageDispose($hEmoji2) If $hEmoji3 Then _GDIPlus_ImageDispose($hEmoji3) If $hEmoji4 Then _GDIPlus_ImageDispose($hEmoji4) _GDIPlus_Shutdown() GUIDelete($hGUI) DllClose($__g_hDWriteDLL) ;DllClose($__g_hD2D1DLL) ;crashing EndFunc ;==>_Cleanup ;https://unicode.org/emoji/charts/full-emoji-list.html Func _EmojiFromCodePoint($iCodePoint) ; Basic Multilingual Plane (BMP): U+0000 to U+FFFF If $iCodePoint <= 0xFFFF Then Return ChrW($iCodePoint) Local $iAdjusted = $iCodePoint - 0x10000 Local $iHigh = 0xD800 + BitShift($iAdjusted, 10) Local $iLow = 0xDC00 + BitAND($iAdjusted, 0x3FF) Return ChrW($iHigh) & ChrW($iLow) EndFunc ;==>_EmojiFromCodePoint Func _WIC_ImagingFactory_Create() Local $oObj = ObjCreateInterface($sCLSID_WICImagingFactory, $sIID_IWICImagingFactory, $tagIWICImagingFactory) If Not IsObj($oObj) Then Return SetError(0x80080001, 0, False) Return $oObj EndFunc ;==>_WIC_ImagingFactory_Create Func _WIC_ImagingFactory_CreateBitmap(Const ByRef $oIImagingFactory, $iWidth, $iHeight, $sPixelFormat = $sGUID_WICPixelFormat32bppPBGRA, $iOption = 0x2) If Not IsObj($oIImagingFactory) Then Return SetError($WICERR_NOOBJ, 0, False) Local $tGUID = _WinAPI_GUIDFromString($sPixelFormat) If @error Or Not IsDllStruct($tGUID) Then Return SetError(0x80070057, 1, False) Local $pBitmap Local $iHResult = $oIImagingFactory.CreateBitmap($iWidth, $iHeight, $tGUID, $iOption, $pBitmap) If $iHResult Or Not $pBitmap Then Return SetError($iHResult, 2, False) Local $oBitmap = ObjCreateInterface($pBitmap, $sIID_IWICBitmap, $tagIWICBitmap) If Not IsObj($oBitmap) Then Return SetError(0x80080001, 3, False) Return $oBitmap EndFunc ;==>_WIC_ImagingFactory_CreateBitmap Func _D2D_Factory_Create() Local $tIID_ID2D1Factory = _WinAPI_GUIDFromString($sIID_ID2D1Factory) Local $aResult = DllCall($__g_hD2D1DLL, "int", "D2D1CreateFactory", "uint", 0, "struct*", $tIID_ID2D1Factory, "uint*", 0, "ptr*", 0) If @error Then Return SetError($D2DERR_UFAIL, 1, False) If $aResult[0] Or Not $aResult[4] Then Return SetError($aResult[0], 2, False) Local $oFactory = ObjCreateInterface($aResult[4], $sIID_ID2D1Factory, $tagID2D1Factory) If Not IsObj($oFactory) Then Return SetError(0x80080001, 3, False) Return $oFactory EndFunc ;==>_D2D_Factory_Create Func _D2D_Factory_CreateWicBitmapRenderTarget(Const ByRef $oIFactory, Const ByRef $oWICBitmap, $iPixelFormat = 87, $iAlphaMode = 1, $fDpiX = 0, $fDpiY = 0, $iUsage = 0x00000000) If Not IsObj($oIFactory) Then Return SetError($D2DERR_NOOBJ, 0, False) If Not IsObj($oWICBitmap) Then Return SetError($D2DERR_NOOBJ, 1, False) Local $tD2D1_RENDER_TARGET_PROPERTIES = _D2D1_RENDER_TARGET_PROPERTIES(1, $iPixelFormat, $iAlphaMode, $fDpiX, $fDpiY, $iUsage, 0) Local $pRenderTarget Local $iHResult = $oIFactory.CreateWicBitmapRenderTarget($oWICBitmap, $tD2D1_RENDER_TARGET_PROPERTIES, $pRenderTarget) If $iHResult Or Not $pRenderTarget Then Return SetError($iHResult, 2, False) Local $oRenderTarget = ObjCreateInterface($pRenderTarget, $sIID_ID2D1RenderTarget, $tagID2D1RenderTarget) If Not IsObj($oRenderTarget) Then Return SetError(0x80080001, 3, False) Return $oRenderTarget EndFunc ;==>_D2D_Factory_CreateWicBitmapRenderTarget Func _D2D_RenderTarget_CreateSolidColorBrush(Const ByRef $oIRenderTarget, $fRed = 0, $fGreen = 0, $fBlue = 0, $fAlpha = 1, $fOpacity = 1) If Not IsObj($oIRenderTarget) Then Return SetError($D2DERR_NOOBJ, 0, False) Local $pSolidColorBrush Local $iHResult = $oIRenderTarget.CreateSolidColorBrush(_D2D1_COLOR_F($fRed, $fGreen, $fBlue, $fAlpha), _D2D1_BRUSH_PROPERTIES($fOpacity), $pSolidColorBrush) If $iHResult Or Not $pSolidColorBrush Then Return SetError($iHResult, 1, False) Local $oSolidColorBrush = ObjCreateInterface($pSolidColorBrush, $sIID_ID2D1SolidColorBrush, $tagID2D1SolidColorBrush) If Not IsObj($oSolidColorBrush) Then Return SetError(0x80080001, 2, False) Return $oSolidColorBrush EndFunc ;==>_D2D_RenderTarget_CreateSolidColorBrush Func _D2D_RenderTarget_Clear(Const ByRef $oIRenderTarget, $fR = 0, $fG = 0, $fB = 0, $fA = 1) If Not IsObj($oIRenderTarget) Then Return SetError($D2DERR_NOOBJ, 0, False) $oIRenderTarget.Clear(_D2D1_COLOR_F($fR, $fG, $fB, $fA)) Return True EndFunc ;==>_D2D_RenderTarget_Clear Func _D2D1_COLOR_F($fR = 0, $fG = 0, $fB = 0, $fA = 1) Local $tStruct = DllStructCreate($tagD2D1_COLOR_F) $tStruct.R = $fR $tStruct.G = $fG $tStruct.B = $fB $tStruct.A = $fA Return $tStruct EndFunc ;==>_D2D1_COLOR_F Func _D2D1_RECT_F($fLeft = 0, $fTop = 0, $fRight = 0, $fBottom = 0) Local $tStruct = DllStructCreate($tagD2D1_RECT_F) $tStruct.Left = $fLeft $tStruct.Top = $fTop $tStruct.Right = $fRight $tStruct.Bottom = $fBottom Return $tStruct EndFunc ;==>_D2D1_RECT_F Func _D2D1_SIZEOF(Const ByRef $sTag) Local $tStruct = DllStructCreate($sTag) Return DllStructGetSize($tStruct) EndFunc ;==>_D2D1_SIZEOF Func _D2D1_BRUSH_PROPERTIES($fOpacity = 0, $tMatrix = Null) Local $tStruct = DllStructCreate($tagD2D1_BRUSH_PROPERTIES) $tStruct.Opacity = $fOpacity If IsDllStruct($tMatrix) Then DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", DllStructGetPtr($tStruct) + 4, "struct*", $tMatrix, "ulong_ptr", _D2D1_SIZEOF($tagD2D1_MATRIX_3X2_F)) Else $tStruct.M11 = 1 $tStruct.M22 = 1 EndIf Return $tStruct EndFunc ;==>_D2D1_BRUSH_PROPERTIES Func _D2D1_RENDER_TARGET_PROPERTIES($iType = 2, $iPixelFormat = 0, $iAlphaMode = 0, $fDpiX = 0, $fDpiY = 0, $iUsage = 0x00000000, $iMinLevel = 0) Local $tStruct = DllStructCreate($tagD2D1_RENDER_TARGET_PROPERTIES) $tStruct.Type = $iType $tStruct.PixelFormat = $iPixelFormat $tStruct.AlphaMode = $iAlphaMode $tStruct.DpiX = $fDpiX $tStruct.DpiY = $fDpiY $tStruct.Usage = $iUsage $tStruct.MinLevel = $iMinLevel Return $tStruct EndFunc ;==>_D2D1_RENDER_TARGET_PROPERTIES Func _DWrite_Factory_Create() Local $tIID_IDWriteFactory = _WinAPI_GUIDFromString($sIID_IDWriteFactory) Local $aResult = DllCall($__g_hDWriteDLL, "int", "DWriteCreateFactory", "uint", 0, "struct*", $tIID_IDWriteFactory, "ptr*", 0) If @error Or $aResult[0] Then Return SetError(1, 1, False) Local $oObj = ObjCreateInterface($aResult[3], $sIID_IDWriteFactory, $tagIDWriteFactory) If Not IsObj($oObj) Then Return SetError(0x80080001, 2, False) Return $oObj EndFunc ;==>_DWrite_Factory_Create Func _DWrite_Factory_CreateTextFormat(Const ByRef $oIFactory, $sFontFamilyName = "Arial", $fFontSize = 48, $iFontWeight = 400, $iFontStyle = 0, $iFontStretch = 5, $oFontCollection = Null, $sLocaleName = "en-us") If Not IsObj($oIFactory) Then Return SetError($DWRITEERR_NOOBJ, 0, False) If $oFontCollection <> Null And Not IsObj($oFontCollection) Then Return SetError($DWRITEERR_NOOBJ, 1, False) Local $pTextFormat Local $iHResult = $oIFactory.CreateTextFormat($sFontFamilyName, $oFontCollection, $iFontWeight, $iFontStyle, $iFontStretch, $fFontSize, $sLocaleName, $pTextFormat) If $iHResult Or Not $pTextFormat Then Return SetError($iHResult, 2, False) Local $oTextFormat = ObjCreateInterface($pTextFormat, $sIID_IDWriteTextFormat, $tagIDWriteTextFormat) If Not IsObj($oTextFormat) Then Return SetError(0x80080001, 3, False) Return $oTextFormat EndFunc ;==>_DWrite_Factory_CreateTextFormat
-
wakillon reacted to a post in a topic:
SampleControls.au3 in Dark Mode
-
WildByDesign reacted to a post in a topic:
SampleControls.au3 in Dark Mode
-
Code updated -> see 1st post.
-
UEZ reacted to a file:
AutoIt DLL Guide
-
Another WMI methode seems to work, too: ;Coded by UEZ build 2025-12-07 Func WMI_GetHDDSerialNumber() Local $oWMI = ObjGet("winmgmts:\\.\root\Microsoft\Windows\Storage") If Not IsObj($oWMI) Then Return "Error: WMI Storage Namespace not found (Win8+ required)" Local $colItems = $oWMI.ExecQuery("SELECT FriendlyName, SerialNumber, AdapterSerialNumber FROM MSFT_PhysicalDisk") Local $aResult[100][3], $c = 0 For $objItem In $colItems With $objItem $aResult[$c][0] = .FriendlyName $aResult[$c][1] = .SerialNumber $aResult[$c][2] = .AdapterSerialNumber ConsoleWrite("-----------------------------------" & @CRLF) ConsoleWrite("Name: " & $aResult[$c][0]& @CRLF) ConsoleWrite("SerialNumber: " & $aResult[$c][1] & @CRLF) ConsoleWrite("AdapterSerial: " & $aResult[$c][2]& @CRLF) EndWith $c += 1 Next ReDim $aResult[$c][3] Return $aResult EndFunc Global $a = WMI_GetHDDSerialNumber()
-
This is the same result as C:\Windows\System32>wmic path win32_physicalmedia get serialnumber SerialNumber 8CE3_8E10_02B1_5166. Yes, CrystalDiskInfo shows 7E5CT5TPZ164 as s/n. Need some more investigation...
-
Or the WinAPI way: ;Coded by UEZ build 2025-12-07 beta ;~ #RequireAdmin #include <WinAPIFiles.au3> #include <WinAPIHObj.au3> Func _WinAPI_GetPhysicalDriveNumber($driveLetter) $driveLetter = StringLeft($driveLetter, 1) Local $hVolume = _WinAPI_CreateFile("\\.\" & $driveLetter & ":", 2, 0, 6) If $hVolume = 0 Then Return SetError(1, 0, -1) Local $tSDN = DllStructCreate("dword DeviceType;dword DeviceNumber;dword PartitionNumber") Local $bResult = _WinAPI_DeviceIoControl($hVolume, $IOCTL_STORAGE_GET_DEVICE_NUMBER, 0, 0, $tSDN, DllStructGetSize($tSDN)) _WinAPI_CloseHandle($hVolume) If Not $bResult Then Return SetError(2, 0, -1) Return $tSDN.DeviceNumber EndFunc Func _WinAPI_GetHDDSerialByPhysicalDrive($driveNumber = 0) Local $hDrive = _WinAPI_CreateFile("\\.\PhysicalDrive" & $driveNumber, 2, 0, 6) If $hDrive = 0 Then Return SetError(1, 0, "") Local $tSPQ = DllStructCreate("int PropertyId;int QueryType;byte AdditionalParameters[1]") With $tSPQ .PropertyId = 0 ; StorageDeviceProperty .QueryType = 0 ; PropertyStandardQuery EndWith Local $tBuffer = DllStructCreate("byte[65536]") Local $bResult = _WinAPI_DeviceIoControl($hDrive, $IOCTL_STORAGE_QUERY_PROPERTY, $tSPQ, DllStructGetSize($tSPQ), $tBuffer, DllStructGetSize($tBuffer)) _WinAPI_CloseHandle($hDrive) If Not $bResult Then Return SetError(2, 0, "") ; Parse STORAGE_DEVICE_DESCRIPTOR header Local $tHeader = DllStructCreate("dword Version;dword Size;byte DeviceType;byte DeviceTypeModifier;" & _ "byte RemovableMedia;byte CommandQueueing;dword VendorIdOffset;dword ProductIdOffset;" & _ "dword ProductRevisionOffset;dword SerialNumberOffset", DllStructGetPtr($tBuffer)) Local $serialOffset = $tHeader.SerialNumberOffset If $serialOffset = 0 Then Return SetError(3, 0, "") ; Read the serial number string Local $basePtr = DllStructGetPtr($tBuffer) Local $serial = "", $i, $tChar, $byte For $i = 0 To 200 $tChar = DllStructCreate("byte b", $basePtr + $serialOffset + $i) $byte = $tChar.b If $byte = 0 Then ExitLoop $serial &= Chr($byte) Next Return StringStripWS($serial, 3) EndFunc Func _WinAPI_GetHDDModelByPhysicalDrive($driveNumber = 0) Local $hDrive = _WinAPI_CreateFile("\\.\PhysicalDrive" & $driveNumber, 2, 0, 6) If $hDrive = 0 Then Return SetError(1, 0, "") Local $tSPQ = DllStructCreate("int PropertyId;int QueryType;byte AdditionalParameters[1]") With $tSPQ .PropertyId = 0 .PropertyId = 0 EndWith Local $tBuffer = DllStructCreate("byte[65536]") Local $bResult = _WinAPI_DeviceIoControl($hDrive, $IOCTL_STORAGE_QUERY_PROPERTY, $tSPQ, DllStructGetSize($tSPQ), $tBuffer, DllStructGetSize($tBuffer)) _WinAPI_CloseHandle($hDrive) If Not $bResult Then Return SetError(2, 0, "") Local $tHeader = DllStructCreate("dword Version;dword Size;byte DeviceType;byte DeviceTypeModifier;" & _ "byte RemovableMedia;byte CommandQueueing;dword VendorIdOffset;dword ProductIdOffset;" & _ "dword ProductRevisionOffset;dword SerialNumberOffset", DllStructGetPtr($tBuffer)) Local $productOffset = $tHeader.ProductIdOffset If $productOffset = 0 Then Return SetError(3, 0, "") Local $basePtr = DllStructGetPtr($tBuffer) Local $product = "", $tChar, $tChar, $i For $i = 0 To 200 $tChar = DllStructCreate("byte b", $basePtr + $productOffset + $i) $byte = $tChar.b If $byte = 0 Then ExitLoop $product &= Chr($byte) Next Return StringStripWS($product, 3) EndFunc Func _WinAPI_GetVolumeSerial($drive = "C:\") Local $aInfo = _WinAPI_GetVolumeInformation($drive) If @error Then Return SetError(@error, 0, "") Return Hex($aInfo[1], 8) EndFunc ConsoleWrite("=== HDD Information ===" & @CRLF & @CRLF) Local $physDrive = _WinAPI_GetPhysicalDriveNumber("C") ConsoleWrite("Physical drive number for C: " & $physDrive & @CRLF) If $physDrive >= 0 Then Local $model = _WinAPI_GetHDDModelByPhysicalDrive($physDrive) ConsoleWrite("Model: " & $model & @CRLF) Local $serial = _WinAPI_GetHDDSerialByPhysicalDrive($physDrive) ConsoleWrite("Serial Number: " & $serial & @CRLF) EndIf Local $volSerial = _WinAPI_GetVolumeSerial() ConsoleWrite("Volume Serial: " & $volSerial & @CRLF & @CRLF) My result: === HDD Information === Physical drive number for C: 0 Model: BG6 KIOXIA 256GB Serial Number: 8CE3_8E10_02B1_5166. Volume Serial: 40D09020
-
I didn't read all the posts in this thread. I found an old WMI script which returns the s/n: Global $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler") MsgBox(0, "Test", WMI_GetHDDSN(".")) Func WMI_GetHDDSN($host, $usr = "", $pass = "") ;coded by UEZ 2011 If $host = "." Then $host = "localhost" Local $HDD_SN Local $ping = Ping($host, 1000) If @error Then Return SetError(1, 0, -1) Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") Local $objWMIService = $objWMILocator.ConnectServer($host, "\root\cimv2", $usr, $pass, "", "", 128) If @error Then Return SetError(2, 0, -1) Local $colItems = $objWMIService.ExecQuery("SELECT Model, Name, SerialNumber FROM Win32_DiskDrive WHERE MediaType='Fixed hard disk media'", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems $HDD_SN &= "Model: " & $objItem.Model & ", S/N: " & WMI_GetHDDSN2(StringMid($objItem.Name, 5), $host, $usr, $pass) & @LF Next Else Return SetError(3, 0, -1) EndIf Return $HDD_SN EndFunc Func WMI_GetHDDSN2($Tag, $host, $usr = "", $pass = "") ;coded by UEZ 2011 Local $HDD_SN Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") Local $objWMIService = $objWMILocator.ConnectServer($host, "\root\cimv2", $usr, $pass, "", "", 128) Local $colItems = $objWMIService.ExecQuery("SELECT SerialNumber,Tag FROM Win32_PhysicalMedia WHERE Tag LIKE '%" & $Tag & "%'", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems ;~ ConsoleWrite($objItem.Tag & @LF) $HDD_SN = $objItem.SerialNumber Next Else Return SetError(3, 0, -1) EndIf Return $HDD_SN EndFunc Func ObjErrorHandler() ConsoleWrite( "A COM Error has occured!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _ "err.windescription:" & @TAB & $oErrorHandler & @CRLF & _ "err.number is: " & @TAB & Hex($oErrorHandler.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oErrorHandler.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _ "err.source is: " & @TAB & $oErrorHandler.source & @CRLF & _ "err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oErrorHandler.helpcontext & @CRLF _ ) EndFunc I don't know if this is what you guys are looking for.
-
I assume you must hook to the external program to change visuals.
-
Converting Transparency Level 0-255 To Percentage
UEZ replied to WildByDesign's topic in AutoIt General Help and Support
A generic map function: ;Coded by UEZ build 2025-10-29 Func Map($val, $source_start, $source_stop, $dest_start, $dest_stop) Return (($val - $source_start) * ($dest_stop - $dest_start) / ($source_stop - $source_start) + $dest_start) EndFunc $iCol = Int(Map(87, 0, 100, 0, 255)) ConsoleWrite($iCol & " - 0x" & Hex($iCol, 2) & @CRLF) ;87% from color value (0 - 255) $iCol = 1 + Int(Map($iCol, 0, 255, 0, 100)) ;and back again ConsoleWrite($iCol & " - 0x" & Hex($iCol, 2) & @CRLF) -
UEZ reacted to a post in a topic:
FileExplorer Treeview and Listview (TreeListExplorer)
-
When you parse the GIF anim you will get a handle to the current frame which you can resize and display appropriatly.
-
UEZ reacted to a post in a topic:
Need help removing line from dark mode menubar
-
UEZ reacted to a post in a topic:
SampleControls.au3 in Dark Mode
-
UEZ reacted to a post in a topic:
SampleControls.au3 in Dark Mode
-
Yes, thanks 👍 Updated the code for the window when date pick icon was clicked. Still searching for a way to change the date control itself.
-
UEZ reacted to a post in a topic:
Date/Time Pick coloring
-
UEZ reacted to a post in a topic:
SampleControls.au3 in Dark Mode
-
Can you please try this? Func _OverpaintWhiteLine() Local $hDC = _WinAPI_GetWindowDC($g_hGUI) If Not $hDC Then Return Local $tWndRect = _WinAPI_GetWindowRect($g_hGUI) Local $iWndWidth = $tWndRect.right - $tWndRect.left ; 1. Caption height Local $iCaptionHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION) ; 2. Border height (top) Local $iBorderHeight = _WinAPI_GetSystemMetrics($SM_CYSIZEFRAME) If $iBorderHeight = 0 Then $iBorderHeight = _WinAPI_GetSystemMetrics($SM_CYFIXEDFRAME) ; 3. Determine menu height dynamically Local $iMenuHeight = _WinAPI_GetSystemMetrics($SM_CYMENU) ; standard menu height ; Alternative: get menu height via GetMenuBarInfo Local $tMenuBarInfo = DllStructCreate("dword cbSize;long left;long top;long right;long bottom;handle hwndMenu;handle hwndItem;bool fBarFocused;bool fFocused") DllStructSetData($tMenuBarInfo, "cbSize", DllStructGetSize($tMenuBarInfo)) Local $aResult = DllCall("user32.dll", "bool", "GetMenuBarInfo", "hwnd", $g_hGUI, "long", 0xFFFFFFFD, "long", 0, "ptr", DllStructGetPtr($tMenuBarInfo)) If IsArray($aResult) And $aResult[0] Then ; Calculate the actual menu height from the coordinates Local $iMenuTop = $tMenuBarInfo.top Local $iMenuBottom = $tMenuBarInfo.bottom Local $tWndPos = _WinAPI_GetWindowRect($g_hGUI) Local $iWndTop = $tWndPos.top ; Convert to window coordinates $iMenuHeight = ($iMenuBottom - $iMenuTop) EndIf ; The white line is directly below the menu Local $iWhiteLineY = $iCaptionHeight + $iBorderHeight + $iMenuHeight - _WinAPI_GetSystemMetrics($SM_CYFIXEDFRAME) * 2 ConsoleWrite("Caption: " & $iCaptionHeight & ", Border: " & $iBorderHeight & ", Menu: " & $iMenuHeight & " -> White Line at Y=" & $iWhiteLineY & @CRLF) ; Overpaint the white line (1–2 pixels) Local $tRect = DllStructCreate($tagRECT) With $tRect .left = 0 .top = $iWhiteLineY .right = $iWndWidth .bottom = $iWhiteLineY + 2 ; 2 pixels high EndWith ;~ Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF(0xFF0000)) _WinAPI_FillRect($hDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($g_hGUI, $hDC) EndFunc ;==>_OverpaintWhiteLine I marked the line in red to see where it is painted. Is it now calculated properly?
-
UEZ reacted to a post in a topic:
enumicons.au3
-
Updated the code -> see 1st post. To do: date picker