Jump to content

UEZ

MVPs
  • Posts

    7,429
  • 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 :-)

Recent Profile Visitors

10,706 profile views

UEZ's Achievements

  1. I enhanced the Delaunay function in my _GDIPlus_BitmapApplyFilter Dll and created a front-end GUI to generate Low-Polygon images: Code: ;Coded by UEZ v0.60 build 2026-02-13 ;Requires 3.3.15.0+ version #AutoIt3Wrapper_Version=p #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_HiDpi=y #include <ComboConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <ScreenCapture.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #include "_GDIPlus_BitmapApplyFilter.au3" Global Const $hDLL = _GDIPlus_BitmapApplyFilter_Open() Global Const $hGUI = GUICreate("Low-Polygon Maker v0.60", 252, 716, 4, 150, -1, $WS_EX_TOPMOST) GUISetFont(8, 400, 0, "Consolas") GUISetBkColor(0xABCDEF, $hGUI) Global $aRet = _GDIPlus_BitmapCreateVerticalText("Coded by UEZ 2026", 21.75, "Consolas", 0x380000FF, 1) Global Const $iPic_Label = GUICtrlCreatePic("", 204, 88, $aRet[1], $aRet[2]) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_Label, $STM_SETIMAGE, $IMAGE_BITMAP, $aRet[0])) Global Const $iLbl_Title = GUICtrlCreateLabel("Low-Polygon Maker", 0, 8, 238, 32, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "Consolas") Global Const $iLbl_EdgeDetection = GUICtrlCreateLabel("Edge Detection", 4, 58, 88, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iCombo_EdgeDetection = GUICtrlCreateCombo("", 96, 56, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetData($iCombo_EdgeDetection, "SOBEL|" & _ "SCHARR|" & _ "PREWITT|" & _ "FREI_CHEN|" & _ "ROBERTS_CROSS|" & _ "ROBINSON_COMPASS|" & _ "KAYYALI|" & _ "RIDGE_DETECTION|" & _ "DIAGONAL_EDGES|" & _ "SOVELVSPREWITT|" & _ "OUTLINE3X3|" & _ "LAPLACE3x3_1|" & _ "LAPLACE3x3_2|" & _ "LAPLACE5x5|" & _ "EDGE_DETECTION1|" & _ "EDGE_DETECTION2|" & _ "EDGE_DETECTION3|" & _ "EDGE_DETECTION4|" & _ "EDGE_DETECTION5|" & _ "EMBOSS1|" & _ "EMBOSS2|" & _ "EMBOSS3|" & _ "EMBOSS4|" & _ "KIRSCH|" & _ "ISOTROPIC_SOBEL", _ "DIAGONAL_EDGES") Global $iInp_x = 96, $iInp_w = 100 Global Const $iLbl_Threshold = GUICtrlCreateLabel("ED Threshold", 4, 96, 76, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Threshold = GUICtrlCreateInput(0.35, $iInp_x, 92, $iInp_w, 21) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_Blur = GUICtrlCreateLabel("Blur Level", 4, 128, 64, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Blur = GUICtrlCreateInput(4, $iInp_x, 124, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_Colors = GUICtrlCreateLabel("Max. Colors", 4, 160, 70, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Colors = GUICtrlCreateInput(32, $iInp_x, 156, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_MinSpace = GUICtrlCreateLabel("Min Space", 4, 192, 58, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_MinSpace = GUICtrlCreateInput(4, $iInp_x, 188, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_MaxSpace = GUICtrlCreateLabel("Max Space", 4, 224, 58, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_MaxSpace = GUICtrlCreateInput(8, $iInp_x, 220, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_BorderSpaceX = GUICtrlCreateLabel("Border Space X", 4, 256, 88, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_BorderSpaceX = GUICtrlCreateInput(2, $iInp_x, 252, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_BorderSpaceY = GUICtrlCreateLabel("Border Space Y", 4, 288, 88, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_BorderSpaceY = GUICtrlCreateInput(2, $iInp_x, 284, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_Alpha = GUICtrlCreateLabel("Edges Alpha", 4, 320, 70, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_Alpha = GUICtrlCreateInput(32, $iInp_x, 316, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") Global Const $iLbl_PosterizeLvl = GUICtrlCreateLabel("Posterize Lvl", 4, 352, 80, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iInp_PosterizeLvl = GUICtrlCreateInput(8, $iInp_x, 348, $iInp_w, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)) GUICtrlSetFont(-1, 10, 400, 0, "Consolas") GUICtrlSetTip(-1, "When the posterization level is set, the value for “Max. Colors” is ignored.") Global Const $iChkB_ShowEdges = GUICtrlCreateCheckbox("Show Edges", 4, 386, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") GUICtrlSetState(-1, $GUI_CHECKED) Global Const $iChkB_Wireframe = GUICtrlCreateCheckbox("Show Wireframes only", 4, 414, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iChkB_GIFAnim = GUICtrlCreateCheckbox("Convert all GIF frames", 4, 442, 233, 17) GUICtrlSetFont(-1, 8.5, 400, 0, "Consolas") Global Const $iBtn_Apply = GUICtrlCreateButton("&Apply", 8, 476, 235, 57) GUICtrlSetFont(-1, 12, 400, 0, "Consolas") GUICtrlSetBkColor(-1, 0xCCCCFF) Global Const $iBtn_Load = GUICtrlCreateButton("&Load Image", 8, 548, 235, 57) GUICtrlSetFont(-1, 12, 400, 0, "Consolas") GUICtrlSetBkColor(-1, 0xCCCCFF) Global Const $iBtn_Save = GUICtrlCreateButton("&Save Image", 8, 620, 235, 57) GUICtrlSetFont(-1, 12, 400, 0, "Consolas") GUICtrlSetBkColor(-1, 0xCCCCFF) Global $aParts[1] = [-1] Global Const $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aParts, "Ready") Local $hFont = _WinAPI_CreateFont(12, 0, 0, 0, $FW_MEDIUM, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DRAFT_QUALITY, 0, "Segoe UI") _WinAPI_SetFont($hStatusBar, $hFont, True) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') Global $aMsg, $hImage, $sImgFile, $hGUI_Display = 0, $hGDI_LowPoly, $sFileLowPoly ConsoleWrite("Screen: " & @DesktopWidth & "x" & @DesktopHeight & @CRLF) Dim $aFrameDelays[1], $aFramesGDI[1], $aFrames_LowPoly[1] Global $iCurrentFrame = 0, $iAnimFrameCount = 0, $bIsGIF, $iPic_LowPoly, $iSeed, $i While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $hGUI Switch $aMsg[0] Case $GUI_EVENT_CLOSE AdlibUnRegister("PlayGIFAnimPreview") GUIDelete($hGUI) If UBound($aFrameDelays) Then For $i = 0 To UBound($aFrameDelays) - 1 _WinAPI_DeleteObject($aFramesGDI[$i]) _GDIPlus_ImageDispose($aFrames_LowPoly[$i + 1]) Next EndIf _GDIPlus_BitmapApplyFilter_Close() Exit Case $iBtn_Load $sImgFile = FileOpenDialog("Select a GDI+ supported image", "", "Images (*.bmp;*.gif;*.png;*.jpg;*.tif)", $FD_FILEMUSTEXIST, "", $hGUI) If @error Then ContinueLoop If Not FileExists($sImgFile) Then MsgBox($MB_ICONERROR, "Error", $sImgFile & " doesn't exist", 30) ContinueLoop EndIf If $hImage Then _GDIPlus_ImageDispose($hImage) $hImage = _GDIPlus_ImageLoadFromFile($sImgFile) If Not $hImage Then MsgBox($MB_ICONERROR, "Error", "Unable to load file to GDI+", 30) ContinueLoop EndIf $bIsGIF = False If StringRight($sImgFile, 4) = ".gif" Then $bIsGIF = True $iSeed = Int(Random() * 0xFFFFFF) $iCurrentFrame = 0 $iAnimFrameCount = 0 EncodeAndDisplay($hImage) Case $iBtn_Save If $sImgFile = "" Or ($bIsGIF ? UBound($aFrames_LowPoly) < 2 : $hGDI_LowPoly = 0) Then ContinueLoop $sFileLowPoly = FileSaveDialog("Save Low-Polygone Image", "", "Images (*.bmp;*.gif;*.png;*.jp?g;*.tif?)", 0, StringRegExpReplace($sImgFile, "^.*\\([^\\]+)(\.[^.]+)$", "\1_Low-Polygon\2"), $hGUI) If @error Or $sFileLowPoly = "" Then ContinueLoop If ((UBound($aFrames_LowPoly) > 1 And $bIsGIF) ? _GDIPlus_GIFAnimCreateFile2($aFrames_LowPoly, $sFileLowPoly, $aFrameDelays) : _ScreenCapture_SaveImage($sFileLowPoly, $hGDI_LowPoly, False)) Then MsgBox($MB_ICONINFORMATION, "Information", "Low-Poly image saved.", 15, $hGUI) Else MsgBox($MB_ICONERROR, "Error", "Low-Poly image could not be save!", 15, $hGUI) EndIf Case $iBtn_Apply If $sImgFile = "" Or $hImage = 0 Then ContinueLoop GUICtrlSetState($iBtn_Apply, $GUI_DISABLE) EncodeAndDisplay($hImage) GUICtrlSetState($iBtn_Apply, $GUI_ENABLE) EndSwitch Case $hGUI_Display Switch $aMsg[0] Case $GUI_EVENT_CLOSE AdlibUnRegister("PlayGIFAnimPreview") GUIDelete($hGUI_Display) $hGUI_Display = 0 EndSwitch EndSwitch WEnd Func Min($a, $b) Return $a < $b ? $a : $b EndFunc Func EncodeAndDisplay($hImage, $ResizeinGUI = True) Local $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage) If $iW = 0 Or $iH = 0 Then Return SetError(1, 0, 0) Local $iMode = 0, $fScaleX, $fScaleY, $fFactor = 0.925 ConsoleWrite("Original: " & $iW & "x" & $iH & @CRLF) If $ResizeinGUI Then If $iH > @DesktopHeight And $iW < @DesktopWidth + 1 Then $fScaleY = @DesktopHeight / $iH $iW *= $fScaleY $iH *= $fScaleY $iMode = 1 ElseIf $iH < @DesktopHeight + 1 And $iW > @DesktopWidth Then $fScaleX = @DesktopWidth / $iW $iW *= $fScaleX $iH *= $fScaleX $iMode = 2 ElseIf $iH > @DesktopHeight And $iW > @DesktopWidth Then If $iH > $iW Then $fScaleY = @DesktopHeight / $iH $iH *= $fScaleY $iW *= $fScaleY Else $fScaleX = @DesktopWidth / $iW $iH *= $fScaleX $iW *= $fScaleX EndIf $iMode = 3 EndIf If $iMode Then $iW *= $fFactor $iH *= $fFactor EndIf EndIf ConsoleWrite("Display: " & Int($iW) & "x" & Int($iH) & @CRLF) Static $iWp = 0, $iHp = 0 If $iW <> $iWp Or $iH <> $iHp Then If $hGUI_Display Then GUIDelete($hGUI_Display) $hGUI_Display = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_OVERLAPPEDWINDOW) $iPic_LowPoly = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1) GUISetState(@SW_SHOWNA, $hGUI_Display) EndIf $iWp = $iW $iHp = $iH If $hGDI_LowPoly Then _WinAPI_DeleteObject($hGDI_LowPoly) $hGDI_LowPoly = 0 ;~ ConsoleWrite("Blur level: " & Number(GUICtrlRead($iInp_Blur)) & @CRLF & _ ;~ "Kernel: " & Execute("$" & GUICtrlRead($iCombo_EdgeDetection)) & @CRLF & _ ;~ "Threshold: " & Number(GUICtrlRead($iInp_Threshold), $NUMBER_DOUBLE) & @CRLF & _ ;~ "Amount of Colors: " & Number(GUICtrlRead($iInp_Colors)) & @CRLF & _ ;~ "Min Space: " & Number(GUICtrlRead($iInp_MinSpace)) & @CRLF & _ ;~ "Max Space: " & Number(GUICtrlRead($iInp_MaxSpace)) & @CRLF & _ ;~ "Border Space X: " & Number(GUICtrlRead($iInp_BorderSpaceX)) & @CRLF & _ ;~ "Border Space Y: " & Number(GUICtrlRead($iInp_BorderSpaceY)) & @CRLF & _ ;~ "Show Edges Checked: " & Int(BitAND(GUICtrlRead($iChkB_ShowEdges), $GUI_CHECKED) = $GUI_CHECKED) & @CRLF & _ ;~ "Alpha Value: " & Number(GUICtrlRead($iInp_Alpha)) & @CRLF & _ ;~ "Wireframe Checked: " & Int(BitAND(GUICtrlRead($iChkB_Wireframe), $GUI_CHECKED) = $GUI_CHECKED) & @CRLF & _ ;~ "Posterize level: " & Number(GUICtrlRead($iInp_PosterizeLvl)) & @CRLF & _ ;~ "GIF Mode Checked: " & Int(BitAND(GUICtrlRead($iChkB_GIFAnim), $GUI_CHECKED) = $GUI_CHECKED) & @CRLF) ;~ ConsoleWrite("-----------------------------------------------------------------------" & @CRLF) AdlibUnRegister("PlayGIFAnimPreview") Local $i Local Const $iAnimDimCount = _GDIPlus_GIFAnimGetFrameDimensionsCount($hImage) Local Const $tGUID = _GDIPlus_GIFAnimGetFrameDimensionsList($hImage, $iAnimDimCount) $iAnimFrameCount = _GDIPlus_GIFAnimGetFrameCount($hImage, $tGUID) $aFrameDelays = _GDIPlus_GIFAnimGetFrameDelays($hImage, $iAnimFrameCount) Local Const $fTimer = TimerInit() If Int(BitAND(GUICtrlRead($iChkB_GIFAnim), $GUI_CHECKED) = $GUI_CHECKED) And $bIsGIF And $iAnimFrameCount > 1 Then If UBound($aFramesGDI) > 1 Then For $i = 0 To UBound($aFramesGDI) - 1 _WinAPI_DeleteObject($aFramesGDI[$i]) _GDIPlus_ImageDispose($aFrames_LowPoly[$i + 1]) Next EndIf ReDim $aFramesGDI[$iAnimFrameCount] ReDim $aFrames_LowPoly[$iAnimFrameCount + 1] $aFrames_LowPoly[0] = $iAnimFrameCount For $i = 0 To $iAnimFrameCount - 1 _GDIPlus_GIFAnimSelectActiveFrame($hImage, $tGUID, $i) $aFrames_LowPoly[$i + 1] = _GDIPlus_BitmapApplyFilter_Delaunay3($hImage, Number(GUICtrlRead($iInp_Blur)), _ Execute("$" & GUICtrlRead($iCombo_EdgeDetection)), _ Number(GUICtrlRead($iInp_Threshold), $NUMBER_DOUBLE), _ Number(GUICtrlRead($iInp_Colors)), _ Number(GUICtrlRead($iInp_MinSpace)), _ Number(GUICtrlRead($iInp_MaxSpace)), _ Number(GUICtrlRead($iInp_BorderSpaceX)), _ Number(GUICtrlRead($iInp_BorderSpaceY)), _ Int(BitAND(GUICtrlRead($iChkB_ShowEdges), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_Alpha)), _ Int(BitAND(GUICtrlRead($iChkB_Wireframe), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_PosterizeLvl)), _ $iSeed, _ 0xFFFFFFFF, _ False) $aFramesGDI[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($aFrames_LowPoly[$i + 1]) _GDIPlus_BitmapConvertTo8Bit($aFrames_LowPoly[$i + 1], 256, $GDIP_DitherTypeNone, $GDIP_PaletteTypeFixedHalftone256) ToolTip($i + 1 & "/" & $iAnimFrameCount & " : " & Round(($i + 1) / UBound($aFrameDelays) * 100, 2) & "%", MouseGetPos(0), MouseGetPos(1) + 30, "", 0, $TIP_CENTER) Next ToolTip("") AdlibRegister("PlayGIFAnimPreview", 10) Else $hGDI_LowPoly = _GDIPlus_BitmapApplyFilter_Delaunay3($hImage, Number(GUICtrlRead($iInp_Blur)), _ Execute("$" & GUICtrlRead($iCombo_EdgeDetection)), _ Number(GUICtrlRead($iInp_Threshold), $NUMBER_DOUBLE), _ Number(GUICtrlRead($iInp_Colors)), _ Number(GUICtrlRead($iInp_MinSpace)), _ Number(GUICtrlRead($iInp_MaxSpace)), _ Number(GUICtrlRead($iInp_BorderSpaceX)), _ Number(GUICtrlRead($iInp_BorderSpaceY)), _ Int(BitAND(GUICtrlRead($iChkB_ShowEdges), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_Alpha)), _ Int(BitAND(GUICtrlRead($iChkB_Wireframe), $GUI_CHECKED) = $GUI_CHECKED), _ Number(GUICtrlRead($iInp_PosterizeLvl)), _ $iSeed, _ 0, _ True) If $hGDI_LowPoly = 0 Then GUIDelete($hGUI_Display) $hGUI_Display = 0 Return SetError(1, 0, 0) EndIf If $iMode Then ResizeImage($hGDI_LowPoly, $iW, $iH) Local $hHBmp = GUICtrlSendMsg($iPic_LowPoly, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDI_LowPoly) If $hHBmp Then _WinAPI_DeleteObject($hHBmp) EndIf _GUICtrlStatusBar_SetText($hStatusBar, "Generated in: " & Round(TimerDiff($fTimer), 2) & " ms. Dimension: " & _GDIPlus_ImageGetWidth($hImage) & "x" & _GDIPlus_ImageGetHeight($hImage), 0, $SBT_POPOUT) _WinAPI_InvalidateRect($hGUI_Display) _WinAPI_RedrawWindow($hGUI_Display) EndFunc ;==>EncodeAndDisplay Func PlayGIFAnimPreview() AdlibUnRegister("PlayGIFAnimPreview") Local $iDelay = $aFrameDelays[$iCurrentFrame] Local Static $iTimerCurrentFrame = TimerInit() _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_LowPoly, 0x0172 , 0, $aFramesGDI[$iCurrentFrame])) ;$STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 If TimerDiff($iTimerCurrentFrame) > $iDelay Then $iCurrentFrame += 1 $iTimerCurrentFrame = TimerInit() EndIf If $iCurrentFrame > UBound($aFrameDelays) - 1 Then $iCurrentFrame = 0 AdlibRegister("PlayGIFAnimPreview", 10) EndFunc ;==>PlayGIFAnimPreview Func ResizeImage(ByRef $hBitmapGDI, $newW, $newH) Local $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmapGDI) Local $hImageResized = _GDIPlus_ImageResize($hImage, $newW, $newH) _WinAPI_DeleteObject($hBitmapGDI) $hBitmapGDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageResized, 0) _GDIPlus_ImageDispose($hImageResized) EndFunc Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iNotifyCode = BitShift($wParam, 16) Local $iCtrlID = BitAND($wParam, 0x0000FFFF) Local $var If $iNotifyCode = $EN_KILLFOCUS Then Switch $iCtrlID Case $iInp_Blur $val = GUICtrlRead($iInp_Blur) If $val = "" Then $val = 4 $val = Number($val) If $val < 1 Then $val = 1 If $val > 127 Then $val = 127 GUICtrlSetData($iInp_Blur, $val) Case $iInp_Threshold $val = GUICtrlRead($iInp_Threshold) If $val = "" Then $val = 0.35 $val = Number($val) If $val < 0 Then $val = 0 If $val > 10 Then $val = 10 GUICtrlSetData($iInp_Threshold, StringFormat("%.2f", $val)) Case $iInp_Colors $val = GUICtrlRead($iInp_Colors) If $val = "" Then $val = 32 $val = Number($val) If $val < 2 Then $val = 2 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_Colors, $val) Case $iInp_MinSpace $val = GUICtrlRead($iInp_MinSpace) If $val = "" Then $val = 3 $val = Number($val) If $val < 1 Then $val = 1 GUICtrlSetData($iInp_MinSpace, $val) Case $iInp_MaxSpace $val = GUICtrlRead($iInp_MaxSpace) If $val = "" Then $val = 8 $val = Number($val) If $val < 1 Then $val = 1 GUICtrlSetData($iInp_MaxSpace, $val) Case $iInp_BorderSpaceX, $iInp_BorderSpaceY $val = GUICtrlRead($iCtrlID) If $val = "" Then $val = 2 $val = Number($val) If $val < 1 Then $val = 1 If $val > 255 Then $val = 255 GUICtrlSetData($iCtrlID, $val) Case $iInp_Alpha $val = GUICtrlRead($iInp_Alpha) If $val = "" Then $val = 32 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_Alpha, $val) Case $iInp_PosterizeLvl $val = GUICtrlRead($iInp_PosterizeLvl) If $val = "" Then $val = 8 $val = Number($val) If $val < 0 Then $val = 0 If $val > 255 Then $val = 255 GUICtrlSetData($iInp_PosterizeLvl, $val) EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Func _GDIPlus_BitmapCreateVerticalText($sString, $fFontSize = 10, $sFont = "Arial", $iColor_Text = 0xFF000000, $iFlip = 3) $iFlip = $iFlip <> 3 Or $iFlip <> 1 ? 3 : $iFlip Local Const $hDC = _WinAPI_GetWindowDC(0) Local Const $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColor_Text) Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fFontSize) Local $tLayout = _GDIPlus_RectFCreate() Local Const $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat) Local $iError = 1 If Not @error Then Local Const $iW = Ceiling($aInfo[0].Width), $iH = Ceiling($aInfo[0].Height) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH), $hCanvas = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($hCanvas, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) $tLayout.X = 0 $tLayout.Y = 0 $tLayout.Width = $iW $tLayout.Height = $iH _GDIPlus_GraphicsDrawStringEx($hCanvas, $sString, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_ImageRotateFlip($hBitmap, $iFlip) Local Const $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_BitmapDispose($hBitmap) $iError = 0 EndIf _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_ReleaseDC(0, $hDC) If $iError Then Return SetError(1, 0, 0) Local $aResult[3] = [$hBitmap_GDI, $iH, $iW] Return $aResult EndFunc ;==>_GDIPlus_BitmapCreateVerticalText ;_GDIPlus_GIFAnim* function taken from _GDIPlus_GIFAnim UDF Func _GDIPlus_GIFAnimGetFrameDimensionsCount($hImage) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageGetFrameDimensionsCount", "handle", $hImage, "ulong*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[2] EndFunc ;==>_GDIPlus_GIFAnimGetFrameDimensionsCount Func _GDIPlus_GIFAnimGetFrameDimensionsList($hImage, $iFramesCount) Local Const $tGUID = DllStructCreate($tagGUID) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageGetFrameDimensionsList", "handle", $hImage, "struct*", $tGUID, "uint", $iFramesCount) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $tGUID EndFunc ;==>_GDIPlus_GIFAnimGetFrameDimensionsList Func _GDIPlus_GIFAnimGetFrameCount($hImage, $tGUID) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageGetFrameCount", "handle", $hImage, "struct*", $tGUID, "ptr*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return Int($aResult[3]) EndFunc ;==>_GDIPlus_GIFAnimGetFrameCount Func _GDIPlus_GIFAnimSelectActiveFrame($hImage, $tGUID, $iCurrentFrame) Local Const $aResult = DllCall($__g_hGDIPDll, "int", "GdipImageSelectActiveFrame", "handle", $hImage, "struct*", $tGUID, "uint", $iCurrentFrame) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return True EndFunc ;==>_GDIPlus_GIFAnimSelectActiveFrame Func _GDIPlus_GIFAnimGetFrameDelays($hImage, $iAnimFrameCount) If $iAnimFrameCount < 2 Then Return SetError(1, 0, 0) Local Const $GDIP_PROPERTYTAGFRAMEDELAY = 0x5100 Local $tPropItem = __GDIPlus_ImageGetPropertyItem($hImage, $GDIP_PROPERTYTAGFRAMEDELAY) If IsDllStruct($tPropItem) And (Not @error) Then Local $iType = $tPropItem.type, $iLength, $tVal If $iType Then $iLength = $tPropItem.length Switch $iType Case 1 $tVal = DllStructCreate("byte delay[" & $iLength & "]", $tPropItem.value) Case 3 $tVal = DllStructCreate("short delay[" & Ceiling($iLength / 2) & "]", $tPropItem.value) Case 4 $tVal = DllStructCreate("long delay[" & Ceiling($iLength / 4) & "]", $tPropItem.value) Case Else Return SetError(3, 0, 0) EndSwitch Local $aFrameDelays[Int($iAnimFrameCount)], $i For $i = 0 To UBound($aFrameDelays) - 1 $aFrameDelays[$i] = $tVal.delay(($i + 1)) * 10 Next EndIf Return $aFrameDelays EndIf Return SetError(2, 0, 0) EndFunc ;==>_GDIPlus_GIFAnimGetFrameDelays Func __GDIPlus_ImageGetPropertyItem($hImage, $iPropID) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItemSize", "handle", $hImage, "uint", $iPropID, "ulong*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Local Static $tBuffer $tBuffer = DllStructCreate("byte[" & $aResult[3] & "]") $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetPropertyItem", "handle", $hImage, "uint", $iPropID, "ulong", $aResult[3], "struct*", $tBuffer) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(11, $aResult[0], 0) Local Const $tagGDIPPROPERTYITEM = "uint id;ulong length;word type;ptr value" Local $tPropertyItem = DllStructCreate($tagGDIPPROPERTYITEM, DllStructGetPtr($tBuffer)) If @error Then Return SetError(20, $aResult[0], 0) Return $tPropertyItem EndFunc ;==>__GDIPlus_ImageGetPropertyItem Func _GDIPlus_GIFAnimCreateFile2($aImages, $sFilename, $aDelays = 100, $bReplay = True) Local Const $GDIP_EVTFrameDimensionTime = 21 Local $iMax = $aImages[0] If $iMax < 1 Then Return SetError(1, 0, False) Local Const $sCLSID = _GDIPlus_EncodersGetCLSID("GIF") Local $tMultiFrameParam = DllStructCreate("int type;") $tMultiFrameParam.type = 18 Local $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) Local Const $hStream = _WinAPI_CreateStreamOnHGlobal() Local $tGUID = _WinAPI_GUIDFromString($sCLSID) _GDIPlus_ImageSaveToStream($aImages[1], $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams)) If $iMax > 1 Then $tMultiFrameParam.type = $GDIP_EVTFrameDimensionTime $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) For $i = 2 To $iMax _GDIPlus_ImageSaveAddImage($aImages[1], $aImages[$i], $tParams) Next $tMultiFrameParam.type = 19 $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) _GDIPlus_ImageSaveAdd($aImages[1], $tParams) EndIf $tMultiFrameParam.type = 20 $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGSAVEFLAG, 1, 4, DllStructGetPtr($tMultiFrameParam)) _GDIPlus_ImageSaveAdd($aImages[1], $tParams) Local Const $hMemory = _WinAPI_GetHGlobalFromStream($hStream) Local Const $iMemSize = _MemGlobalSize($hMemory) Local Const $pMem = _MemGlobalLock($hMemory) Local Const $iNewSize = $bReplay ? ($iMemSize + 19) : $iMemSize Local Const $hNewMem = _MemGlobalAlloc($iNewSize, 0x0002) Local Const $pNewMem = _MemGlobalLock($hNewMem) Local $tNewData = DllStructCreate("byte mem[" & $iNewSize & "]", $pNewMem) Local Const $hDLL_msvcrt = DllOpen("msvcrt.dll") Local $iCopyOffset = 0 If $bReplay Then Local $tNetscape = DllStructCreate("byte mem[19]") $tNetscape.mem = Binary("0x21FF0B4E45545343415045322E300301000000") Local $aResult = DllCall($hDLL_msvcrt, "ptr:cdecl", "memchr", "ptr", $pMem, "int", 0x21, "ulong_ptr", $iMemSize) If @error Or Not IsArray($aResult) Then _MemGlobalUnlock($hMemory) _MemGlobalUnlock($hNewMem) _MemGlobalFree($hNewMem) _WinAPI_ReleaseStream($hStream) DllClose($hDLL_msvcrt) Return SetError(3, 0, False) EndIf Local $pFound = $aResult[0], $tCheck, $iInsertPos While $pFound <> 0 $tCheck = DllStructCreate("byte mem[3]", $pFound) If $tCheck.mem(1) = 0x21 And $tCheck.mem(2) = 0xF9 And $tCheck.mem(3) = 0x04 Then $iInsertPos = $pFound - $pMem DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem, "ptr", $pMem, "ulong_ptr", $iInsertPos) DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem + $iInsertPos, "struct*", $tNetscape, "ulong_ptr", 19) DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem + $iInsertPos + 19, "ptr", $pMem + $iInsertPos, "ulong_ptr", $iMemSize - $iInsertPos) $iCopyOffset = 19 ExitLoop EndIf $aResult = DllCall($hDLL_msvcrt, "ptr:cdecl", "memchr", "ptr", $pFound + 1, "int", 0x21, "ulong_ptr", $iMemSize - ($pFound - $pMem) - 1) $pFound = $aResult[0] WEnd Else DllCall($hDLL_msvcrt, "ptr:cdecl", "memcpy", "ptr", $pNewMem, "ptr", $pMem, "ulong_ptr", $iMemSize) EndIf _MemGlobalUnlock($hMemory) _WinAPI_ReleaseStream($hStream) _MemGlobalFree($hMemory) Local $pSearch = $pNewMem Local $iRemainingByte = $iNewSize Local $iFrameCount = 0, $iDelay, $aResult, $pFound, $tCheck, $isArray = IsArray($aDelays) While $iFrameCount < $iMax And $iRemainingByte > 6 $aResult = DllCall($hDLL_msvcrt, "ptr:cdecl", "memchr", "ptr", $pSearch, "int", 0x21, "ulong_ptr", $iRemainingByte) If $aResult[0] = 0 Then ExitLoop $pFound = $aResult[0] $tCheck = DllStructCreate("byte mem[6]", $pFound) If $tCheck.mem(2) = 0xF9 And $tCheck.mem(3) = 0x04 Then $iDelay = $isArray ? $aDelays[$iFrameCount] : $aDelays $iDelay = Int($iDelay / 10) $tCheck.mem(5) = BitAND($iDelay, 0xFF) $tCheck.mem(6) = BitShift($iDelay, 8) $iFrameCount += 1 $pSearch = $pFound + 8 Else $pSearch = $pFound + 1 EndIf $iRemainingByte = $iNewSize - ($pSearch - $pNewMem) WEnd DllClose($hDLL_msvcrt) Local $hFile = FileOpen($sFilename, BitOR(16, 2)) If $hFile = -1 Then _MemGlobalUnlock($hNewMem) _MemGlobalFree($hNewMem) Return SetError(2, 0, False) EndIf FileWrite($hFile, $tNewData.mem) FileClose($hFile) _MemGlobalUnlock($hNewMem) _MemGlobalFree($hNewMem) Return True EndFunc ;==>_GDIPlus_GIFAnimCreateFile2 Func _GDIPlus_BitmapConvertTo8Bit(ByRef $hBitmap, $iColorCount = 256, $iDitherType = 9, $iPaletteType = 8, $bUseTransparentColor = True) $iColorCount = ($iColorCount > 2 ^ 8) ? 2 ^ 8 : $iColorCount Local $tPalette = _GDIPlus_PaletteInitialize(256, $iPaletteType, $iColorCount, $bUseTransparentColor, $hBitmap) If @error Then Return SetError(1, @error, 0) Local $iRet = _GDIPlus_BitmapConvertFormat($hBitmap, 0x00030803, $iDitherType, $iPaletteType, $tPalette) If @error Then Return SetError(2, @error, 0) Return $iRet EndFunc ;==>_GDIPlus_BitmapConvertTo8Bit Examples: The required DLLs (_GDIPlus_BitmapApplyFilter.dll / _GDIPlus_BitmapApplyFilter_x64.dll) and _GDIPlus_BitmapApplyFilter.au3 can be found on my OneDrive: _GDIPlus_BitmapApplyFilter
  2. Added "About" menu entry in Sysmenu (left upper corner in the GUI) and in "Menu One". Check out _WM_MENUCOMMAND function. See first post.
  3. Not that I know of.
  4. 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.
  5. 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
  6. Code updated -> see 1st post.
  7. 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()
  8. 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...
  9. 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
  10. 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.
  11. I assume you must hook to the external program to change visuals.
  12. 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)
  13. When you parse the GIF anim you will get a handle to the current frame which you can resize and display appropriatly.
  14. 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.
  15. 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?
×
×
  • Create New...