Leaderboard
Popular Content
Showing content with the highest reputation since 12/22/2024 in all areas
-
I shamelessly used (copied and pasted) a very nice @eukalyptus's script to underline and send you some auspicious messages ... sorry for the laziness... ; source ; https://autoit.de/thread/17855-led-laufschrift/ ; ; reference for this script (by Eukalyptus): ; https://autoit.de/thread/17855-led-laufschrift/?postID=140164#post140164 #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIPlusConstants.au3> ; #include "LEDTXT.au3" ; (by Eukalyptus) already embedded here below Local $sText1 = "Hello friends! ☺ best wishes for a happy holiday and a happy new year (me)" Local $sText2 = "Let us greet together this new year that ages our friendship without aging our hearts. (Victor Hugo)" Local $sText3 = "The best time to plant a tree was 20 years ago. The second best time is now. (Chinese proverb)" Local $sText4 = "The future belongs to those who believe in the beauty of their dreams. (Eleanor Roosevelt)" Local $sText5 = "In the end, what matters is not the years of your life, but the life you put into those years. (Abraham Lincoln)" HotKeySet("{ESC}", "_Exit") _GDIPlus_Startup() $hGuiTrans = GUICreate("", @DesktopWidth, 300, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGuiTrans, 0xABCDEF) GUISetState() $hGui = GUICreate("", @DesktopWidth, 400, 0, 300, Default, $WS_EX_TOPMOST) ; WinSetTrans($hGui, "", 100) GUISetState() #cs parameters info: $hGui: Handle to the window $sText: The text $iX: X position of the scrolling text $iY: Y position $iW: Length $iH: Height $iType: Appearance of the LEDs 0=Round with 3D effect, 1=Square with 3D, 2=Round, 3=Square; (the last two are filled and/or outlined, depending on which colors are <>0) $iLedW = X-size of an LED $iLedH = Y-size of an LED $nLedOnCol1 = Color 1 of the ON LEDs (foreground for 3D, fill color for $iType 2 and 3) $nLedOnCol2 = Color 2 of the ON LEDs (background for 3D, color of the outline for $iType 2 and 3) $nLedOffCol1 = Color 1 of the OFF LEDs $nLedOffCol2 = Color 2 of the OFF LEDs $nBkColor = Background color $iDistW = X-distance of the LEDs $iDistH = Y-distance of the LEDs $sFont = Font $iTextSize = Font size $iTextOpt = Font options (see _GDIPlus_FontCreate ) $iTextOffY = Y offset of the font #ce $aLed1 = _LEDTXT_Create_Gdi($hGuiTrans, $sText1, 0, 0, @DesktopWidth, 50, 0, 2, 2, 0xFFFFAA00, 0xFF000000, 0xAA111122, 0xAA000000, 0, 0, 0, "Courier New", 40, 1) $aLed2 = _LEDTXT_Create_Gdi($hGuiTrans, $sText2, 0, 50, @DesktopWidth, 50, 3, 2, 2, 0, 0xFF0088FF, 0, 0xFF000000, 0, 0, 0, "Arial", 40, 1) $aLed3 = _LEDTXT_Create_Gdi($hGuiTrans, $sText3, 0, 100, @DesktopWidth, 100, 1, 4, 4, 0xFFFF0000, 0xFF000000, 0, 0, 0xFFABCDEF, 1, 1, "Times New Roman", 80, 1) $aLed4 = _LEDTXT_Create_Gdi($hGuiTrans, $sText4, 0, 200, @DesktopWidth, 100, 1, 4, 4, 0xFF00FF00, 0xFF000000, 0xFFABCDEF, 0xFFABCDEF, 0xFFABCDEF, 0, 0, "Arial", 80, 1) $aLed5 = _LEDTXT_Create_Gdi($hGui, $sText5, 0, 0, @DesktopWidth, 350, 0, 14, 14, 0xFF00FF00, 0xFF00AA00, 0x44111119, 0x4400EE00, 0x44000000, 0, 0, "Arial", 410, 1, -60) GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND") While 1 _LEDTXT_Step($aLed1, 1) _LEDTXT_Step($aLed2, -1) _LEDTXT_Step($aLed3, 1) _LEDTXT_Step($aLed4, -1) _LEDTXT_Step($aLed5, 1) _WinAPI_RedrawWindow($hGuiTrans, 0, 0, 5) _WinAPI_RedrawWindow($hGui, 0, 0, 5) Sleep(10) WEnd Func _WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hGuiTrans _LEDTXT_Draw($aLed1) _LEDTXT_Draw($aLed2) _LEDTXT_Draw($aLed3) _LEDTXT_Draw($aLed4) Case $hGui _LEDTXT_Draw($aLed5) EndSwitch Return True EndFunc ;==>_WM_ERASEBKGND Func _Exit() _LEDTXT_Destroy($aLed1) _LEDTXT_Destroy($aLed2) _LEDTXT_Destroy($aLed3) _LEDTXT_Destroy($aLed4) _LEDTXT_Destroy($aLed5) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit ; =============================== ; LEDTXT.au3 (by Eukalyptus) ; =============================== Func _LEDTXT_Step(ByRef $aLed, $iDir = 1) $aLed[6] -= $aLed[8] * $iDir Select Case $aLed[6] + $aLed[7] < 0 $aLed[6] = 0 Case $aLed[6] > 0 $aLed[6] = -$aLed[7] EndSelect EndFunc ;==>_LEDTXT_Step Func _LEDTXT_Draw($aLed) Local $iPos = Round($aLed[6]) - Mod(Round($aLed[6]), $aLed[8]) Switch $aLed[10] Case True Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $iPos + $aLed[7], $aLed[5], $aLed[2], $aLed[3], $iPos + $aLed[7], $aLed[5]) If $aLed[6] + $aLed[7] < $aLed[4] Then _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], 0, 0, $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5]) Case Else _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $aLed[4], $aLed[5], $aLed[2], $aLed[3], $aLed[4], $aLed[5]) EndSwitch Case Else Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[2] + $iPos + $aLed[7], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) If $aLed[6] + $aLed[7] < $aLed[4] Then _WinAPI_BitBlt($aLed[0], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[1], 0, 0, $MERGECOPY) Case Else _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[4], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) EndSwitch EndSwitch EndFunc ;==>_LEDTXT_Draw Func _LEDTXT_Create_GdiPlus($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $aReturn[11] $aReturn[0] = $hGraphics $aReturn[1] = $hLed $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = 0 $aReturn[10] = True ; True = _GdiPlus, False=_WinApi Return $aReturn EndFunc ;==>_LEDTXT_Create_GdiPlus Func _LEDTXT_Create_Gdi($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $bGdiStarted = True If Not $__g_hGDIPDll Then $bGdiStarted = False _GDIPlus_Startup() EndIf Local $hDC = _WinAPI_GetDC($hGui) Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $hBmpDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) _WinAPI_SelectObject($hBmpDC, $hBmp) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) Local $aReturn[11] $aReturn[0] = $hDC $aReturn[1] = $hBmpDC $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = $hBmp ; zum späteren destroy?! $aReturn[10] = False ; True = _GdiPlus, False=_WinApi _GDIPlus_GraphicsDispose($hGraphics) If Not $bGdiStarted Then _GDIPlus_Shutdown() Return $aReturn EndFunc ;==>_LEDTXT_Create_Gdi Func _LEDTXT_Destroy($aLed) Switch $aLed[10] Case True _GDIPlus_BitmapDispose($aLed[1]) _GDIPlus_GraphicsDispose($aLed[0]) Case Else _WinAPI_DeleteObject($aLed[9]) _WinAPI_ReleaseDC(0, $aLed[1]) _WinAPI_DeleteDC($aLed[0]) EndSwitch EndFunc ;==>_LEDTXT_Destroy Func _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, ByRef $iReturnW) $sText = StringReplace($sText, @LF, "") $iW -= Mod($iW, $iLedW + $iDistW) If Not $iTextSize Then $iTextSize = $iH Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iTextSize, $iTextOpt, 2) Local $tLayout = _GDIPlus_RectFCreate($iW, 0, 0, 0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat) Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width")) + $iW $iWidth -= Mod($iWidth, $iLedW + $iDistW) Local $iHeight = $iH ;Ceiling(DllStructGetData($aInfo[0], "Height")) DllStructSetData($aInfo[0], "Y", $iTextOffY) Local $hBmpTxt = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpLed = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpTmp = _GDIPlus_BitmapCreateFromGraphics($iLedW, $iHeight, $hGraphics) Local $hGfxTxt = _GDIPlus_ImageGetGraphicsContext($hBmpTxt) Local $hGfxLed = _GDIPlus_ImageGetGraphicsContext($hBmpLed) Local $hGfxTmp = _GDIPlus_ImageGetGraphicsContext($hBmpTmp) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) _GDIPlus_GraphicsClear($hGfxTxt, 0xFF000000) If $nBkColor Then _GDIPlus_GraphicsClear($hGfxLed, $nBkColor) _GDIPlus_GraphicsDrawStringEx($hGfxTxt, $sText, $hFont, $aInfo[0], $hFormat, $hBrush) Local $BitmapData = _GDIPlus_BitmapLockBits($hBmpTxt, $iW, 0, $iWidth - $iW, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $Stride = DllStructGetData($BitmapData, "Stride") Local $Width = DllStructGetData($BitmapData, "Width") Local $Height = DllStructGetData($BitmapData, "Height") Local $Scan0 = DllStructGetData($BitmapData, "Scan0") Local $PixelData = DllStructCreate("ubyte lData[" & (Abs($Stride) * $Height - 1) & "]", $Scan0) If $hLedOff Then For $i = 0 To $Height - 1 Step $iLedH + $iDistH _GDIPlus_GraphicsDrawImage($hGfxTmp, $hLedOff, 0, $i) Next For $i = 0 To $iW - 1 Step $iLedW + $iDistW _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $i, 0) Next EndIf For $col = 0 To $Width - 1 Step $iLedW + $iDistW If $hLedOff Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $col + $iW, 0) For $row = 0 To $Height - 1 Step $iLedH + $iDistH If DllStructGetData($PixelData, 1, $row * $Stride + ($col * 4) + 1) Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hLedOn, $col + $iW, $row) Next Next _GDIPlus_BitmapUnlockBits($hBmpTxt, $BitmapData) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBmpTxt) _GDIPlus_GraphicsDispose($hGfxTxt) _GDIPlus_BitmapDispose($hBmpTmp) _GDIPlus_GraphicsDispose($hGfxTmp) _GDIPlus_GraphicsDispose($hGfxLed) $iReturnW = $iWidth Return $hBmpLed EndFunc ;==>_LEDTXT_Create_Bmp Func _LEDTXT_Create_Led($hGraphics, $iType, $iWidth, $iHeight, $nColor1, $nColor2) If Not $nColor1 And Not $nColor2 Then Return 0 Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($iWidth + 1, $iHeight + 1, $hGraphics) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) Switch $iType Case 0 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_CreatePath() _GDIPlus_AddPathEllipse($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_CreatePathGradientFromPath($hPath) _GDIPlus_SetLineGammaCorrection($hBrushGrad, True) _GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad, $nColor2) _GDIPlus_SetPathGradientCenterColor($hBrushGrad, $nColor1) _GDIPlus_FillPath($hGfx, $hBrushGrad, $hPath) _GDIPlus_ClosePathFigure($hPath) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 1 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_CreatePath() _GDIPlus_AddPathRectangle($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_CreatePathGradientFromPath($hPath) _GDIPlus_SetLineGammaCorrection($hBrushGrad, True) _GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad, $nColor2) _GDIPlus_SetPathGradientCenterColor($hBrushGrad, $nColor1) _GDIPlus_FillPath($hGfx, $hBrushGrad, $hPath) _GDIPlus_ClosePathFigure($hPath) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 2 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf Case 3 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf EndSwitch _GDIPlus_GraphicsDispose($hGfx) Return $hBmp EndFunc ;==>_LEDTXT_Create_Led Func _GDIPlus_CreatePath($brushMode = 0) Local $hPath $hPath = DllCall($__g_hGDIPDll, "int", "GdipCreatePath", "int", $brushMode, "handle*", 0) If @error Then Return SetError(1, @error, 0) Return SetError($hPath[0], 0, $hPath[2]) EndFunc ;==>_GDIPlus_CreatePath Func _GDIPlus_AddPathEllipse($hPath, $iX, $iY, $iWidth, $iHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathEllipse", "handle", $hPath, "float", $iX, "float", $iY, "float", $iWidth, "float", $iHeight) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathEllipse Func _GDIPlus_AddPathRectangle($hPath, $iX, $iY, $iWidth, $iHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathRectangle", "handle", $hPath, "float", $iX, "float", $iY, "float", $iWidth, "float", $iHeight) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathRectangle Func _GDIPlus_CreatePathGradientFromPath($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePathGradientFromPath", "handle", $hPath, "int*", 0) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>_GDIPlus_CreatePathGradientFromPath Func _GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineGammaCorrection", "handle", $hBrush, "int", $useGammaCorrection) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetLineGammaCorrection Func _GDIPlus_SetPathGradientCenterColor($hBrush, $iARGB) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientCenterColor", "handle", $hBrush, "int", $iARGB) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetPathGradientCenterColor Func _GDIPlus_FillPath($hGraphic, $hBrushGrad, $hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillPath", "handle", $hGraphic, "handle", $hBrushGrad, "handle", $hPath) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_FillPath Func _GDIPlus_SetPathGradientSurroundColorsWithCount($hBrush, $aArgb) Local $iI, $iCount, $aResult, $res, $x, $pArgb If IsArray($aArgb) Then $iCount = UBound($aArgb) $tArgb = DllStructCreate("int[" & $iCount & "]") $pArgb = DllStructGetPtr($tArgb) For $iI = 0 To $iCount - 1 DllStructSetData($tArgb, 1, $aArgb[$iI], $iI + 1) Next Else $iCount = 1 $tArgb = DllStructCreate("int") $pArgb = DllStructGetPtr($tArgb) DllStructSetData($tArgb, 1, $aArgb, 1) EndIf $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "handle", $hBrush, "int", $pArgb, "int*", $iCount) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], $aResult[3], $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetPathGradientSurroundColorsWithCount Func _GDIPlus_ClosePathFigure($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipClosePathFigure", "handle", $hPath) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_ClosePathFigure Func __GDIPlus_PathDispose($hPath) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipDeletePath", "handle", $hPath) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>__GDIPlus_PathDispose7 points
-
Just a bit of fun because evidently I have too much time on my hands! I'm doing all sorts of bad things to in order to handle note on/off events from the stream - so I wouldn't recommend using that part for any real project. A few days early, but happy new year folks!🎉 HappyNewYear.zip7 points
-
I modified one of my old script from 2014: ;Coded by UEZ #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hGUI = GUICreate("GDI+ Test", 200, 100) GUISetBkColor(0x505050) Global Const $iPicBtn = GUICtrlCreatePic("", 50, 28, 100, 44) Global $aButtons = _GDIPlus_BitmapCreateRoundedButtonAndText("install", 100, 44) _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) GUISetState() Global $aMouseInfo, $bShow = False, $bHide = False Do If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation Switch $aMouseInfo[4] Case $iPicBtn _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1])) $bShow = True $bHide = False Case Else _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) $bHide = True $bShow = False EndSwitch EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($aButtons[0]) _WinAPI_DeleteObject($aButtons[1]) _GDIPlus_Shutdown() Exit Case $iPicBtn MsgBox(0, "Information", "Button pressed") EndSwitch Until False ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_BitmapCreateRoundedButtonAndText ; Description ...: Draw rounded button ; Syntax ........: _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[, ; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]]) ; Parameters ....: $sString - A string value. ; $iWidth - An integer value. ; $iHeight - An integer value. ; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1. ; $iFontSize - [optional] An integer value. Default is 16. ; $sFont - [optional] A string value. Default is "Times New Roman". ; $iHoverColor - [optional] An integer value. Default is 0xFFC9388C. ; $iFrameSize - [optional] An integer value. Default is 2. ; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA. ; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF. ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button ; Author ........: UEZ ; Version .......: 0.85 build 2025-01-12 ; Modified ......: ; Remarks .......: Dispose returned GDI bitmap handles when done ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $sFont = "Times New Roman", $iHoverColor = 0xF0FFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF) ;some checks If $sString = "" Then Return SetError(1, 0, 0) If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0) If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0) ;create font objects Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis ;create bitmap and graphics context handles Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)] Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])] ;set drawing quality _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[1], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) ;define brush and pen objects Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) ;, $hBrushBGColor = _GDIPlus_BrushCreateSolid($iBgColor) Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, $iFrameSize), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize) ;create path object Local Const $hPath = _GDIPlus_PathCreate() ;create cloned path object for string measurement Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath) _GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat) _GDIPlus_PathStartFigure($hPath) Local $fArcSize = $iWidth * 0.33333 _GDIPlus_PathAddArc($hPath, $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, 180, -90) ;BR _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, -270, -90) ;BL _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, 0, -90) ;TR _GDIPlus_PathAddArc($hPath, $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, -90, -90) ;TL _GDIPlus_PathCloseFigure($hPath) Local Const $hPath_Clone = _GDIPlus_PathClone($hPath) Local Const $hBrushBGColor = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetSurroundColor($hBrushBGColor, $iBgColor) _GDIPlus_PathBrushSetCenterColor($hBrushBGColor, 0xFFFFFFFF) _GDIPlus_PathBrushSetCenterPoint($hBrushBGColor, $iWidth / 2, $iHeight / 2) _GDIPlus_PathBrushSetSigmaBlend($hBrushBGColor, 1, 0.33333) _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushBGColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) _GDIPlus_PathReset($hPath) ;add string to path _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat) ;clear bitmap and draw string _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) ;draw rectangle on cloned bitmap for hover effect _GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawPath($aGfxCtxt[1], $hPath_Clone, $hPenHoverColor) ;dispose object resources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Dummy) _GDIPlus_PathDispose($hPath_Clone) _GDIPlus_GraphicsDispose($aGfxCtxt[0]) _GDIPlus_GraphicsDispose($aGfxCtxt[1]) _GDIPlus_BrushDispose($hBrushFontColor) _GDIPlus_BrushDispose($hBrushBGColor) _GDIPlus_PenDispose($hPenFontFrameColor) _GDIPlus_PenDispose($hPenHoverColor) ;create GDI bitmap for later usage Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])] ;dispose GDI+ bitmaps _GDIPlus_BitmapDispose($aBitmaps[0]) _GDIPlus_BitmapDispose($aBitmaps[1]) Return $aHBitmaps EndFunc ;==>_GDIPlus_BitmapCreateRoundedButtonAndText5 points
-
RustDesk UDF
SOLVE-SMART and 4 others reacted to BinaryBrother for a topic
Here it is. _RustDesk_isInstalled() ; Tells whether RustDesk is installed. _RustDesk_GetLocalVersion() ; Gets installed version _RustDesk_GetLatestVersion() ; Check github tags for latest version number. _RustDesk_Deploy() ; Auto pulls from current online version. _RustDesk_SetPassword() ; Sets the RustDesk password for the client _RustDesk_GetID() ; Returns the RustDesk Client ID _RustDesk_Start() ; Starts the existing RustDesk environment _RustDesk_Config() ; Confguration hash for custom relays _RustDesk_InstallService() ; Mainly for internal use. #include "UDFs\RustDesk.au3" #Region ##### OPTIONS ##### Opt("MustDeclareVars", 1) Opt("TrayIconHide", 1) #EndRegion ##### OPTIONS ##### #Region ##### ENTRY POINT ##### _Debug(">> MainThread:: Initializing... <<") Local $sID Local $sPassword = "1234567890" Local $sConfig = "ASFSA213444234TEST==" ; Not required If Not _RustDesk_isInstalled() Or $g_RustDesk_CurrentVersion <> $g_RustDesk_LatestVersion Then _RustDesk_Deploy() If @error Then _Error(@error) Else _RustDesk_Start() If @error Then _Error(@error) EndIf _RustDesk_Config($sConfig) $sID = _RustDesk_GetID() If @error Then _Error(@error) _RustDesk_SetPassword($sPassword) If @error Then _Error(@error) _Debug(">> MainThread:: Backend RustDesk Install Finished!") #EndRegion ##### ENTRY POINT ##### #Region UDF Func _Error($pError) Local $sSupport_Info = "Please call BLAH INC. for support!" Local $sAppName = "RustDesk" Switch $pError Case 1 _Debug("!> ERROR: _Download() Failed to get INetGet HNDL! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Download Failed!" & @CRLF & "Check your internet connection!" & @CRLF & $sSupport_Info) Case 2 _Debug("!> ERROR: _Download() Can't get filesize to predict progress! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Download Failed!" & @CRLF & "Check your internet connection!" & @CRLF & $sSupport_Info) Case 3 _Debug("!> ERROR: _Download() interrupted! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Download Failed!" & @CRLF & "Check your internet connection!" & @CRLF & $sSupport_Info) Case 4 _Debug("!> ERROR: _GetRemoteVersion() Failed to retrieve TAGS page! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Could not find latest version of Rust Desk!" & @CRLF & $sSupport_Info) Case 5 _Debug("!> ERROR: _GetRemoteVersion() RegEx failed to find version number! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Could not find latest version of Rust Desk!" & @CRLF & $sSupport_Info) Case 6 _Debug("!> ERROR: _Run(): Failed to run! No Args. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to Launch Application!" & @CRLF & $sSupport_Info) Case 7 _Debug("!> ERROR: _Run(): Failed to run! With Args. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to Launch Application!" & @CRLF & $sSupport_Info) Case 8 _Debug("!> ERROR: _Set_RustDesk_Password(): Failed set RustDesk Password! <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to set RustDesk Password!" & @CRLF & $sSupport_Info) Case 9 _Debug("!> ERROR: _Get_RustDesk_ID(): Failed to acquire RustDesk ID. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to get RustDeskID!" & @CRLF & $sSupport_Info) Case 10 _Debug("!> ERROR: _Deploy_RustDesk(): TIMEOUTs waiting for service RUNNING. <!") MsgBox(16, "ERROR", $sAppName & @CRLF & "Failed to properly launch RustDesk!" & @CRLF & $sSupport_Info) EndSwitch Exit EndFunc ;==>_Error #EndRegion Update: 1/10/25 - Added _RustDesk_Config() for those who need to configure a custom relay. RustDesk.au35 points -
I need from from time to time to run small processes to perform task that would otherwise clog the main process. Yes, there is a number of other UDF that could have done it very well, but I felt they were an over-kill for what I wanted. Don't throw me stones, I know it's not really multi-threading, but it is as close as I could get with simple AutoIt. If someone wonders why I called it PMT, the P stands for Pretending. And I'm also not pretending it is an elaborate UDF. Just small and simple to use... Version 2025-01-03 * changed how temporary files are deleted * changed location of temporary files to use standard folder * added support to unusual location of AutoIt Version 2025-01-02 * corrected bug when temporary files has space within their name. Version 2024-03-24 * corrected bug when 8 parameters (max) is passed to the function Example : #AutoIt3Wrapper_Res_SaveSource=y #include "PMT-UDF.AU3" #include <Constants.au3> _PMT_Init() Local $hProc1 = _PMT_Start("Test1", Default, "Test 1") _PMT_Start("Test2") _PMT_Start("Test3", 5) Local $sResponse While Sleep(50) $sResponse = _PMT_GetResponse($hProc1) If @error Then Exit MsgBox($MB_OK, "Error", "Process has dropped") If $sResponse <> "" Then MsgBox($MB_OK, "Success", $sResponse & @CRLF) ExitLoop EndIf WEnd Func Test1($sTitle, $sMessage) Local $iResp = MsgBox($MB_OK, $sTitle, $sMessage) Return "Done with value " & $iResp EndFunc Func Test2() MsgBox($MB_OK, "2", "Test 2") EndFunc Func Test3($iTimeout) MsgBox($MB_OK, "3", "Test 3", $iTimeout) EndFunc You can pass up to 8 parameters to _PMT_Start. It is up to you to manage the right number. You cannot pass structures, maps or arrays as parameter (only bool, ptr, hWnd, int, float, string, and the keyword Default). You could use my WCD-IPC if need be to exchange large amount of data. If you want to run it compiled, you need to have add #AutoIt3Wrapper_Res_SaveSource=y at the start of your script. In the case you decide to compile your script, _PMT_Init allows you to identity where AutoIt3 is located (in the situation where AutoIt is not installed in the usual directory) to get the right includes in your "threads". Let me know if you have any question, or suggestion, I will be glad to hear them. Enjoy. PMT-UDF.au34 points
-
WinActiveBorder()
Danyfirex and 3 others reacted to argumentum for a topic
4 points -
Cheers Gianni AutoIt x64 was having trouble - So if anyone uses that by default, here's the same code with the DllCalls swapped out for inbult _GDIPlus_* funcs. ; source ; https://autoit.de/thread/17855-led-laufschrift/ ; ; reference for this script (by Eukalyptus): ; https://autoit.de/thread/17855-led-laufschrift/?postID=140164#post140164 #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIPlusConstants.au3> ; #include "LEDTXT.au3" ; (by Eukalyptus) already embedded here below Local $sText1 = "Hello friends! ☺ best wishes for a happy holiday and a happy new year (me)" Local $sText2 = "Let us greet together this new year that ages our friendship without aging our hearts. (Victor Hugo)" Local $sText3 = "The best time to plant a tree was 20 years ago. The second best time is now. (Chinese proverb)" Local $sText4 = "The future belongs to those who believe in the beauty of their dreams. (Eleanor Roosevelt)" Local $sText5 = "In the end, what matters is not the years of your life, but the life you put into those years. (Abraham Lincoln)" HotKeySet("{ESC}", "_Exit") _GDIPlus_Startup() $hGuiTrans = GUICreate("", @DesktopWidth, 300, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGuiTrans, 0xABCDEF) GUISetState() $hGui = GUICreate("", @DesktopWidth, 400, 0, 300, Default, $WS_EX_TOPMOST) ; WinSetTrans($hGui, "", 100) GUISetState() #cs parameters info: $hGui: Handle to the window $sText: The text $iX: X position of the scrolling text $iY: Y position $iW: Length $iH: Height $iType: Appearance of the LEDs 0=Round with 3D effect, 1=Square with 3D, 2=Round, 3=Square; (the last two are filled and/or outlined, depending on which colors are <>0) $iLedW = X-size of an LED $iLedH = Y-size of an LED $nLedOnCol1 = Color 1 of the ON LEDs (foreground for 3D, fill color for $iType 2 and 3) $nLedOnCol2 = Color 2 of the ON LEDs (background for 3D, color of the outline for $iType 2 and 3) $nLedOffCol1 = Color 1 of the OFF LEDs $nLedOffCol2 = Color 2 of the OFF LEDs $nBkColor = Background color $iDistW = X-distance of the LEDs $iDistH = Y-distance of the LEDs $sFont = Font $iTextSize = Font size $iTextOpt = Font options (see _GDIPlus_FontCreate ) $iTextOffY = Y offset of the font #ce $aLed1 = _LEDTXT_Create_Gdi($hGuiTrans, $sText1, 0, 0, @DesktopWidth, 50, 0, 2, 2, 0xFFFFAA00, 0xFF000000, 0xAA111122, 0xAA000000, 0, 0, 0, "Courier New", 40, 1) $aLed2 = _LEDTXT_Create_Gdi($hGuiTrans, $sText2, 0, 50, @DesktopWidth, 50, 3, 2, 2, 0, 0xFF0088FF, 0, 0xFF000000, 0, 0, 0, "Arial", 40, 1) $aLed3 = _LEDTXT_Create_Gdi($hGuiTrans, $sText3, 0, 100, @DesktopWidth, 100, 1, 4, 4, 0xFFFF0000, 0xFF000000, 0, 0, 0xFFABCDEF, 1, 1, "Times New Roman", 80, 1) $aLed4 = _LEDTXT_Create_Gdi($hGuiTrans, $sText4, 0, 200, @DesktopWidth, 100, 1, 4, 4, 0xFF00FF00, 0xFF000000, 0xFFABCDEF, 0xFFABCDEF, 0xFFABCDEF, 0, 0, "Arial", 80, 1) $aLed5 = _LEDTXT_Create_Gdi($hGui, $sText5, 0, 0, @DesktopWidth, 350, 0, 14, 14, 0xFF00FF00, 0xFF00AA00, 0x44111119, 0x4400EE00, 0x44000000, 0, 0, "Arial", 410, 1, -60) GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND") While 1 _LEDTXT_Step($aLed1, 1) _LEDTXT_Step($aLed2, -1) _LEDTXT_Step($aLed3, 1) _LEDTXT_Step($aLed4, -1) _LEDTXT_Step($aLed5, 1) _WinAPI_RedrawWindow($hGuiTrans, 0, 0, 5) _WinAPI_RedrawWindow($hGui, 0, 0, 5) Sleep(10) WEnd Func _WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hGuiTrans _LEDTXT_Draw($aLed1) _LEDTXT_Draw($aLed2) _LEDTXT_Draw($aLed3) _LEDTXT_Draw($aLed4) Case $hGui _LEDTXT_Draw($aLed5) EndSwitch Return True EndFunc ;==>_WM_ERASEBKGND Func _Exit() _LEDTXT_Destroy($aLed1) _LEDTXT_Destroy($aLed2) _LEDTXT_Destroy($aLed3) _LEDTXT_Destroy($aLed4) _LEDTXT_Destroy($aLed5) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit ; =============================== ; LEDTXT.au3 (by Eukalyptus) ; =============================== Func _LEDTXT_Step(ByRef $aLed, $iDir = 1) $aLed[6] -= $aLed[8] * $iDir Select Case $aLed[6] + $aLed[7] < 0 $aLed[6] = 0 Case $aLed[6] > 0 $aLed[6] = -$aLed[7] EndSelect EndFunc ;==>_LEDTXT_Step Func _LEDTXT_Draw($aLed) Local $iPos = Round($aLed[6]) - Mod(Round($aLed[6]), $aLed[8]) Switch $aLed[10] Case True Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $iPos + $aLed[7], $aLed[5], $aLed[2], $aLed[3], $iPos + $aLed[7], $aLed[5]) If $aLed[6] + $aLed[7] < $aLed[4] Then _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], 0, 0, $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5]) Case Else _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $aLed[4], $aLed[5], $aLed[2], $aLed[3], $aLed[4], $aLed[5]) EndSwitch Case Else Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[2] + $iPos + $aLed[7], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) If $aLed[6] + $aLed[7] < $aLed[4] Then _WinAPI_BitBlt($aLed[0], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[1], 0, 0, $MERGECOPY) Case Else _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[4], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) EndSwitch EndSwitch EndFunc ;==>_LEDTXT_Draw Func _LEDTXT_Create_GdiPlus($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $aReturn[11] $aReturn[0] = $hGraphics $aReturn[1] = $hLed $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = 0 $aReturn[10] = True ; True = _GdiPlus, False=_WinApi Return $aReturn EndFunc ;==>_LEDTXT_Create_GdiPlus Func _LEDTXT_Create_Gdi($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $bGdiStarted = True If Not $__g_hGDIPDll Then $bGdiStarted = False _GDIPlus_Startup() EndIf Local $hDC = _WinAPI_GetDC($hGui) Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $hBmpDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) _WinAPI_SelectObject($hBmpDC, $hBmp) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) Local $aReturn[11] $aReturn[0] = $hDC $aReturn[1] = $hBmpDC $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = $hBmp ; zum späteren destroy?! $aReturn[10] = False ; True = _GdiPlus, False=_WinApi _GDIPlus_GraphicsDispose($hGraphics) If Not $bGdiStarted Then _GDIPlus_Shutdown() Return $aReturn EndFunc ;==>_LEDTXT_Create_Gdi Func _LEDTXT_Destroy($aLed) Switch $aLed[10] Case True _GDIPlus_BitmapDispose($aLed[1]) _GDIPlus_GraphicsDispose($aLed[0]) Case Else _WinAPI_DeleteObject($aLed[9]) _WinAPI_ReleaseDC(0, $aLed[1]) _WinAPI_DeleteDC($aLed[0]) EndSwitch EndFunc ;==>_LEDTXT_Destroy Func _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, ByRef $iReturnW) $sText = StringReplace($sText, @LF, "") $iW -= Mod($iW, $iLedW + $iDistW) If Not $iTextSize Then $iTextSize = $iH Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iTextSize, $iTextOpt, 2) Local $tLayout = _GDIPlus_RectFCreate($iW, 0, 0, 0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat) Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width")) + $iW $iWidth -= Mod($iWidth, $iLedW + $iDistW) Local $iHeight = $iH ;Ceiling(DllStructGetData($aInfo[0], "Height")) DllStructSetData($aInfo[0], "Y", $iTextOffY) Local $hBmpTxt = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpLed = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpTmp = _GDIPlus_BitmapCreateFromGraphics($iLedW, $iHeight, $hGraphics) Local $hGfxTxt = _GDIPlus_ImageGetGraphicsContext($hBmpTxt) Local $hGfxLed = _GDIPlus_ImageGetGraphicsContext($hBmpLed) Local $hGfxTmp = _GDIPlus_ImageGetGraphicsContext($hBmpTmp) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) _GDIPlus_GraphicsClear($hGfxTxt, 0xFF000000) If $nBkColor Then _GDIPlus_GraphicsClear($hGfxLed, $nBkColor) _GDIPlus_GraphicsDrawStringEx($hGfxTxt, $sText, $hFont, $aInfo[0], $hFormat, $hBrush) Local $BitmapData = _GDIPlus_BitmapLockBits($hBmpTxt, $iW, 0, $iWidth - $iW, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $Stride = DllStructGetData($BitmapData, "Stride") Local $Width = DllStructGetData($BitmapData, "Width") Local $Height = DllStructGetData($BitmapData, "Height") Local $Scan0 = DllStructGetData($BitmapData, "Scan0") Local $PixelData = DllStructCreate("ubyte lData[" & (Abs($Stride) * $Height - 1) & "]", $Scan0) If $hLedOff Then For $i = 0 To $Height - 1 Step $iLedH + $iDistH _GDIPlus_GraphicsDrawImage($hGfxTmp, $hLedOff, 0, $i) Next For $i = 0 To $iW - 1 Step $iLedW + $iDistW _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $i, 0) Next EndIf For $col = 0 To $Width - 1 Step $iLedW + $iDistW If $hLedOff Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $col + $iW, 0) For $row = 0 To $Height - 1 Step $iLedH + $iDistH If DllStructGetData($PixelData, 1, $row * $Stride + ($col * 4) + 1) Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hLedOn, $col + $iW, $row) Next Next _GDIPlus_BitmapUnlockBits($hBmpTxt, $BitmapData) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBmpTxt) _GDIPlus_GraphicsDispose($hGfxTxt) _GDIPlus_BitmapDispose($hBmpTmp) _GDIPlus_GraphicsDispose($hGfxTmp) _GDIPlus_GraphicsDispose($hGfxLed) $iReturnW = $iWidth Return $hBmpLed EndFunc ;==>_LEDTXT_Create_Bmp Func _LEDTXT_Create_Led($hGraphics, $iType, $iWidth, $iHeight, $nColor1, $nColor2) If Not $nColor1 And Not $nColor2 Then Return 0 Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($iWidth + 1, $iHeight + 1, $hGraphics) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) Switch $iType Case 0 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddEllipse($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetGammaCorrection($hBrushGrad, True) Local $aColors[2] = [1, $nColor2] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrushGrad, $aColors) _GDIPlus_PathBrushSetCenterColor($hBrushGrad, $nColor1) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrushGrad) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 1 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddRectangle($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetGammaCorrection($hBrushGrad, True) Local $aColors[2] = [1, $nColor2] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrushGrad, $aColors) _GDIPlus_PathBrushSetCenterColor($hBrushGrad, $nColor1) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrushGrad) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 2 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf Case 3 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf EndSwitch _GDIPlus_GraphicsDispose($hGfx) Return $hBmp EndFunc ;==>_LEDTXT_Create_Led4 points
-
transparent movable windows with drop shadow
argumentum and 3 others reacted to Nine for a topic
Here my take on it : #include <WinAPISys.au3> #include <GDIPlus.au3> #include <GuiConstants.au3> Opt("MustDeclareVars", True) Global $hGUI, $hGUI2, $hGUI3 Example() Func Example() _GDIPlus_Startup() $hGUI = GUICreateEx("main.png", 100, 100) $hGUI2 = GUICreateEx("item.png", 150, 400, $hGUI) $hGUI3 = GUICreateEx("item.png", 400, 400, $hGUI) GUIRegisterMsg($WM_NCHITTEST, WM_NCHITTEST) GUIRegisterMsg($WM_MOUSELEAVE, WM_MOUSELEAVE) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_Shutdown() EndFunc ;==>Example Func GUICreateEx($sImage, $iPosX = -1, $iPosY = -1, $hParent = 0) Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) Local $hWnd = GUICreate("", -1, -1, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $hParent ? $WS_EX_MDICHILD : 0), $hParent) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_UpdateLayeredWindowEx($hWnd, -1, -1, $hBitmap) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) GUISetState() Return $hWnd EndFunc ;==>GUICreateEx Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hGUI Return $HTCAPTION Case $hGUI2 ConsoleWrite("hovering GUI2" & @CRLF) Case $hGUI3 ConsoleWrite("hovering GUI3" & @CRLF) EndSwitch _WinAPI_TrackMouseEvent($hWnd, $TME_LEAVE) EndFunc ;==>WM_NCHITTEST Func WM_MOUSELEAVE($hWnd, $msg, $wParam, $lParam) ConsoleWrite("leaving " & $hWnd & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSELEAVE Func GUIUpdate($sImage, $hWnd) Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_UpdateLayeredWindowEx($hWnd, -1, -1, $hBitmap) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) EndFunc ;==>GUIUpdate4 points -
_RunWaitEx() UDF
SOLVE-SMART and 2 others reacted to argumentum for a topic
,,in the help area I gave some advice and oops !, ..it works for me because I extended the code but did not share it 😅 So here is the extended code that I call "UDF". Is not up to AutoIt UDF standards but, it runs. ( anyone willing to bring it up to standards, I'll edit this and place your version 😇 ) and here is the demo code #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "_RunWaitEx.au3" ; https://www.autoitscript.com/forum/topic/212643-_runwaitex-udf/ ConsoleWriteWLineNumber('Version: ' & _RunWaitEx_Version() & @TAB & @error & @TAB & @extended & @CRLF) ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- Example_InTheLoop() Func Example_InTheLoop() ConsoleWrite(@CRLF & '+ Example_InTheLoop' & @CRLF & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc(Example_InTheLoop) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc("") & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc("Example_InTheLoop") & '"' & @TAB & @error & @TAB & @extended & @CRLF) ;~ ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc(DontExtst) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc(MyLoopOrYours) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultLoopFunc: "' & _RunWaitEx_DefaultLoopFunc() & '"' & @TAB & @error & @TAB & @extended & @CRLF) _RunWaitEx("Dir") _RunWaitEx_DefaultLoopFunc("") EndFunc ;==>Example_InTheLoop Func MyLoopOrYours($WhateverYouMayUseThisFor, $sStringFromCmdLine = "") ; the func needs to have 2 parameters #forceref $WhateverYouMayUseThisFor ConsoleWriteWLineNumber('' & @MIN & ':' & @SEC & '.' & @MSEC & @TAB & $sStringFromCmdLine & @CRLF) ;~ ProcessClose(_RunWaitEx_Last_iPID()) ;~ _RunWaitEx_ProcessClose(1) ; ..remember to set to zero afterwards EndFunc ;==>MyLoopOrYours ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- Example_InTheEditCtrl() Func Example_InTheEditCtrl() ConsoleWrite(@CRLF & '+ Example_InTheEditCtrl' & @CRLF & @CRLF) Local $iW = 600, $iH = 400 Local $hGUI = GUICreate("Example_InTheEditCtrl", $iW, $iH, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_TABSTOP)) Local $idEdit = GUICtrlCreateEdit("", 0, 0, $iW, $iH) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM) GUISetState(@SW_SHOW) ConsoleWriteWLineNumber('DefaultConsoleWrite: "' & _RunWaitEx_DefaultConsoleWrite() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultConsoleWrite: "' & _RunWaitEx_DefaultConsoleWrite(0) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultCtrlEdit: "' & _RunWaitEx_DefaultCtrlEdit() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultCtrlEdit: "' & _RunWaitEx_DefaultCtrlEdit($idEdit) & '"' & @TAB & @error & @TAB & @extended & @CRLF) ConsoleWriteWLineNumber('DefaultCtrlEdit: "' & _RunWaitEx_DefaultCtrlEdit() & '"' & @TAB & @error & @TAB & @extended & @CRLF) ; ..remember to set to zero afterwards _RunWaitEx("Dir") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGUI) ExitLoop EndSwitch WEnd EndFunc ;==>Example_InTheEditCtrl ;--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- Func ConsoleWriteWLineNumber($sStr, $iLine = @ScriptLineNumber, $iError = @error, $iExtended = @extended) Local $iRet = ConsoleWrite('@@ (' & $iLine & ') : ' & $sStr) Return SetError($iError, $iExtended, $iRet) EndFunc ;==>ConsoleWriteWLineNumber so @daledale , please pardon my oops. On the bright side, you may find this ( what I meant ) useful, and hope it serves you in your project PS: there may be some comments that were true in the original snippet but not longer true/relevant. This is a spur-of-the-moment kind of post. Do uncomment and re-comment lines to mess with it, as a learning tool. You're gonna have to read the UDF to know what functions are available ( given my laziness ).3 points -
Added this UDF to the wiki3 points
-
Get SSL ExpiryTime
Danyfirex and 2 others reacted to argumentum for a topic
#include <WinHttp.au3> ; https://github.com/dragana-r/autoit-winhttp/tree/master ConsoleWrite("- ExpiryTime: " & _WinHttp_SSL_ExpiryTime("www.google.com") & @CRLF) Func _WinHttp_SSL_ExpiryTime($sSite, $iPort = 443, $sTimeType = "ExpiryTime") Local Const $tagINTERNET_CERTIFICATE_INFO = "dword ExpiryTime[2]; dword StartTime[2]; ptr SubjectInfo;" & _ "ptr IssuerInfo; ptr ProtocolName; ptr SignatureAlgName; ptr EncryptionAlgName; dword KeySize" Local $tINTERNET_CERTIFICATE_INFO, $hOpen = _WinHttpOpen() _WinHttpSetOption($hOpen, $WINHTTP_OPTION_SECURITY_FLAGS, 0x00003300) ; $SECURITY_FLAG_IGNORE_ALL Local $hConnect = _WinHttpConnect($hOpen, $sSite, $iPort) Local $hRequest = _WinHttpSimpleSendSSLRequest($hConnect, "GET", "/") Local $tBufferLength = DllStructCreate("dword") DllStructSetData($tBufferLength, 1, 2048) Local $sReturn, $tBuffer = DllStructCreate("byte[2048]") Local $iError, $aResult = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpQueryOption", _ "handle", $hRequest, "dword", $WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT, _ "struct*", DllStructGetPtr($tBuffer), "dword*", DllStructGetPtr($tBufferLength)) $iError = @error If Not $iError And $aResult[0] Then $tINTERNET_CERTIFICATE_INFO = DllStructCreate($tagINTERNET_CERTIFICATE_INFO, DllStructGetPtr($tBuffer)) $sReturn = __WinHttp_INTERNET_CERTIFICATE_INFO_Time($tINTERNET_CERTIFICATE_INFO, $sTimeType) ; these are "ExpiryTime" and "StartTime" Else $iError = 99 $sReturn = "error" EndIf $tBufferLength = 0 $tBuffer = 0 $tINTERNET_CERTIFICATE_INFO = 0 _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return SetError($iError, 0, $sReturn) EndFunc ;==>_WinHttp_SSL_ExpiryTime Func __WinHttp_INTERNET_CERTIFICATE_INFO_Time($tStruct, $sTimeType = "ExpiryTime") Local $tSystTime = DllStructCreate("struct;word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds;endstruct") DllCall("kernel32.dll", "bool", "FileTimeToSystemTime", "struct*", DllStructGetPtr($tStruct, $sTimeType), "struct*", $tSystTime) Return StringFormat("%04d/%02d/%02d %02d:%02d:%02d", $tSystTime.Year, $tSystTime.Month, $tSystTime.Day, $tSystTime.Hour, $tSystTime.Minute, $tSystTime.Second) EndFunc ;==>__WinHttp_INTERNET_CERTIFICATE_INFO_Time Had to scrape the site to get this. Shared here so you don't have to go trough the same trouble. This function gets the date a SSL certificate expires on a web site. Edit: Added to "ExpiryTime" the possibility of getting "StartTime". Was already there, might as well give the opportunity to get that too. ..and this one has the rest of the info I could get. If anyone can get ProtocolName, SignatureAlgName and EncryptionAlgName, post it. TIA3 points -
$WS_EX_NOACTIVATE
ioa747 and 2 others reacted to pixelsearch for a topic
On my computer too, I can reproduce the behavior you described ("a window appears above the taskbar on the left side") According to msdn, if you use $WS_EX_NOACTIVATE and want your window to appear on the TaskBar, then you need to add the ExStyle $WS_EX_APPWINDOW BitOr($WS_EX_NOACTIVATE, $WS_EX_APPWINDOW) I tested it and it works. When the GUI is restored from the TaskBar and another window partially covers it, then clicking on your GUI doesn't bring it to the foreground (which is the purpose of $WS_EX_NOACTIVATE) Hope it helps3 points -
Taquin The Taquin is a solitary puzzle game, popular since the late 19th century, that challenges the player's logic and patience. This code implements a digital version of the Taquin, where the goal is to rearrange a set of 15 numbered tiles from 1 to 15 into ascending order by moving the tiles one at a time, in a frame of 16 spaces. The game is played on a simple and intuitive graphical interface. Goal of the Game The goal of Taquin is to rearrange the 15 tiles into numerical order (from 1 to 15), with an empty space, starting from a randomly shuffled configuration. The player must move the tiles using the empty space by clicking on tiles adjacent to the empty space. Game Features Graphical Interface (GUI): The game uses AutoIt to create a simple graphical interface, where the game board consists of 15 numbered tiles. The interface allows the user to see the tiles and easily move them to solve the puzzle. Game Mechanics: Tiles can only be moved if they are adjacent to the empty space. By clicking on a tile, it moves into the empty space, and the game updates the display after each move. Solution Verification: The game continuously checks if the tiles are in the correct order, and a victory notification is displayed when the tiles are correctly arranged. Random Shuffle: At the start of the game, the tiles are randomly arranged to create a different challenge with each game. Ease of Use: The game is designed to be simple to use, with controls based on mouse clicks to move the tiles. Game Rules Tile Movement: A player can move a tile by clicking on it if it is adjacent to the empty space. The objective is to move the tiles into ascending order. Solution: The game ends when the tiles are arranged in the following order: 1, 2, 3, ..., 15, with the empty space at the end. History of the Game The Taquin was invented in the United States around 1870, before being popularized in Europe and becoming widely recognized. The invention was claimed by Sam Loyd in 1891, when the game became a global phenomenon. It is now a classic among puzzle games. #include-once #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include "AutoItObject.au3" #include <Array.au3> ; #INDEX# ======================================================================================================================= ; Title .........: Puzzle Game ; AutoIt Version : 3.3 ; AutoItObject Version : v1.2.8.2 ; Language ......: English ; Description ...: This script implements a puzzle game using AutoIt and AutoItObject.au3. ; Dependencies ..: AutoItObject.au3, GDIPlus.au3 ; Author ........: Numeric ; ======================================================================================================================= ; Game Overview: ; - The game consists of a grid of tiles. ; - The objective is to arrange the tiles in numerical order by swapping them. ; - The game ends when all tiles are correctly arranged. ; - Tiles are shuffled randomly at the start, and the player can interact with them via mouse clicks. ; Controls: ; - Mouse Click: Select a tile to move. ; - Tiles swap when an adjacent empty tile is clicked. ; Enjoy solving the puzzle! ; ======================================================================================================================= _AutoItObject_Startup() _GDIPlus_Startup() ; Classe Ligne Func CreateLine($startX, $startY, $endX, $endY, $color = 0xFF00FF00, $thickness = 1) If $color = Default Or $color = "" Or Not $color Then $color = 0xFF00FF00 Local $lineObject = _AutoItObject_Class() With $lineObject .AddProperty("StartX", $ELSCOPE_PUBLIC, $startX) .AddProperty("StartY", $ELSCOPE_PUBLIC, $startY) .AddProperty("EndX", $ELSCOPE_PUBLIC, $endX) .AddProperty("EndY", $ELSCOPE_PUBLIC, $endY) .AddProperty("Color", $ELSCOPE_PUBLIC, $color) .AddProperty("Thickness", $ELSCOPE_PUBLIC, $thickness) EndWith Return $lineObject.Object EndFunc ;==>CreateLine Func CreateTile($xPosition, $yPosition, $size, $color = 0xFFFFFFFF) Local $squareObject = _AutoItObject_Class() Local $radius = $size / 2 Local $lines[0] With $squareObject .Create() .AddProperty("Lines", $ELSCOPE_PUBLIC, $lines) .AddProperty("Type", $ELSCOPE_PUBLIC, "Square") .AddProperty("Number", $ELSCOPE_PUBLIC, 0) .AddProperty("X", $ELSCOPE_PUBLIC, $xPosition) .AddProperty("Y", $ELSCOPE_PUBLIC, $yPosition) .AddProperty("Size", $ELSCOPE_PUBLIC, $size) .AddProperty("Color", $ELSCOPE_PUBLIC, $color) .AddProperty("CircleRadius", $ELSCOPE_PUBLIC, $radius) .AddMethod("AddLine", "AddLineToSquare") .AddMethod("DisplayNumber", "DisplayNumberOnSquare") .AddMethod("Move", "MoveSquare") .AddMethod("Resize", "ResizeSquare") .AddMethod("CheckCollision", "CheckSquareCollision") .AddMethod("ContainsPoint", "PointInsideSquare") EndWith Return $squareObject.Object EndFunc ;==>CreateTile Func AddLineToSquare($this, $line) Local $lineArray = $this.Lines _ArrayAdd($lineArray, $line) $this.Lines = $lineArray EndFunc ;==>AddLineToSquare Func DisplayNumberOnSquare($this, $number) Local $lineArray[0] $this.Lines = $lineArray If $number = 0 Then $number = "" Local $segmentSize = $this.Size / 3 Local $centerX = $this.X + ($this.Size / 2) Local $centerY = $this.Y + ($this.Size / 2) Local $segmentPatterns[10][7] = [ _ [1, 1, 1, 1, 1, 1, 0], _ ; 0 [0, 1, 1, 0, 0, 0, 0], _ ; 1 [1, 1, 0, 1, 1, 0, 1], _ ; 2 [1, 1, 1, 1, 0, 0, 1], _ ; 3 [0, 1, 1, 0, 0, 1, 1], _ ; 4 [1, 0, 1, 1, 0, 1, 1], _ ; 5 [1, 0, 1, 1, 1, 1, 1], _ ; 6 [1, 1, 1, 0, 0, 0, 0], _ ; 7 [1, 1, 1, 1, 1, 1, 1], _ ; 8 [1, 1, 1, 1, 0, 1, 1] _ ; 9 ] Local $segmentCoords[7][4] = [ _ [-0.4, -0.4, 0.4, -0.4], _ ; Haut [0.4, -0.4, 0.4, 0.0], _ ; Haut-droite [0.4, 0.0, 0.4, 0.4], _ ; Bas-droite [-0.4, 0.4, 0.4, 0.4], _ ; Bas [-0.4, 0.0, -0.4, 0.4], _ ; Bas-gauche [-0.4, -0.4, -0.4, 0.0], _ ; Haut-gauche [-0.4, 0.0, 0.4, 0.0] _ ; Milieu ] Local $currentOffsetX = -($segmentSize * (StringLen($number) - 1) / 2) For $digitIndex = 0 To StringLen($number) - 1 Local $digit = Number(StringMid($number, $digitIndex + 1, 1)) For $segmentIndex = 0 To 6 If $segmentPatterns[$digit][$segmentIndex] Then Local $x1 = $centerX + $currentOffsetX + $segmentCoords[$segmentIndex][0] * $segmentSize Local $y1 = $centerY + $segmentCoords[$segmentIndex][1] * $segmentSize Local $x2 = $centerX + $currentOffsetX + $segmentCoords[$segmentIndex][2] * $segmentSize Local $y2 = $centerY + $segmentCoords[$segmentIndex][3] * $segmentSize $this.AddLine(CreateLine($x1, $y1, $x2, $y2, Default, 2)) EndIf Next $currentOffsetX += $segmentSize * 1.2 Next EndFunc ;==>DisplayNumberOnSquare Func PointInsideSquare($this, $pointX, $pointY) Return ($pointX >= $this.X And $pointX <= $this.X + $this.Size) And _ ($pointY >= $this.Y And $pointY <= $this.Y + $this.Size) EndFunc ;==>PointInsideSquare Func CheckSquareCollision($this, $otherSquare) If $this.Type = "Square" And $otherSquare.Type = "Square" Then Local $isAdjacentHorizontally = ($this.Y = $otherSquare.Y And $this.Size = $otherSquare.Size) And _ (($this.X + $this.Size = $otherSquare.X) Or ($this.X = $otherSquare.X + $otherSquare.Size)) Local $isAdjacentVertically = ($this.X = $otherSquare.X And $this.Size = $otherSquare.Size) And _ (($this.Y + $this.Size = $otherSquare.Y) Or ($this.Y = $otherSquare.Y + $otherSquare.Size)) Return $isAdjacentHorizontally Or $isAdjacentVertically EndIf Return False EndFunc ;==>CheckSquareCollision Func CreatePuzzleGame($backgroundColor = 0xFF0000FF) Local $window = GUICreate("Puzzle Game", 400, 400) GUISetState() Local $windowSize = WinGetClientSize($window) Local $windowWidth = $windowSize[0] Local $windowHeight = $windowSize[1] Local $graphicsContext[] $graphicsContext["Graphics"] = _GDIPlus_GraphicsCreateFromHWND($window) $graphicsContext["Bitmap"] = _GDIPlus_BitmapCreateFromGraphics($windowWidth, $windowHeight, $graphicsContext["Graphics"]) $graphicsContext["GraphicsObject"] = _GDIPlus_ImageGetGraphicsContext($graphicsContext["Bitmap"]) $graphicsContext["BackgroundBrush"] = _GDIPlus_BrushCreateSolid($backgroundColor) Local $tileSize = Int($windowWidth / 4) Local $tiles[] Local $index = 0 Local $numbers[16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15] _ArrayShuffle($numbers) For $row = 0 To 3 For $col = 0 To 3 Local $tile = CreateTile($col * $tileSize, $row * $tileSize, $tileSize) $tile.Number = $numbers[$index] $tile.DisplayNumber($tile.Number) $index += 1 $tiles[$index] = $tile Next Next Local $game = _AutoItObject_Class() With $game .Create() .AddProperty("Tiles", $ELSCOPE_PUBLIC, $tiles) .AddProperty("GraphicsContext", $ELSCOPE_PUBLIC, $graphicsContext) .AddProperty("Window", $ELSCOPE_PUBLIC, $window) .AddProperty("WindowWidth", $ELSCOPE_PUBLIC, $windowWidth) .AddProperty("WindowHeight", $ELSCOPE_PUBLIC, $windowHeight) .AddMethod("Render", "RenderPuzzle") .AddMethod("Reset", "ResetPuzzle") .AddMethod("CheckVictory", "VerifyWinCondition") .AddMethod("Run", "StartGameLoop") .AddMethod("HandleClick", "ProcessMouseClick") .AddMethod("GetTileAtPosition", "FindTileAtCoordinates") .AddMethod("GetEmptyAdjacentTile", "FindEmptyNeighbor") .AddMethod("SwapTiles", "ExchangeTiles") .AddMethod("UpdateDisplay", "RefreshDisplay") .AddDestructor("ReleaseResources") EndWith Return $game.Object EndFunc ;==>CreatePuzzleGame Func StartGameLoop($this) Local $msg While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN $this.HandleClick($msg[3], $msg[4]) $this.Render() EndSwitch $this.Render() WEnd EndFunc ;==>StartGameLoop ; Gestion des clics de souris Func ProcessMouseClick($this, $x, $y) Local $clickedTileIndex = $this.GetTileAtPosition($x, $y) If Not $clickedTileIndex Then Return Local $emptyTileIndex = $this.GetEmptyAdjacentTile($clickedTileIndex) If $emptyTileIndex Then $this.SwapTiles($clickedTileIndex, $emptyTileIndex) $this.UpdateDisplay() If $this.CheckVictory() Then MsgBox(0, "Congratulations!", "You have solved the puzzle") $this.Reset() EndIf EndIf EndFunc ;==>ProcessMouseClick ; Trouve une tuile à une position donnée Func FindTileAtCoordinates($this, $x, $y) For $tileKey In MapKeys($this.Tiles) Local $tile = $this.Tiles[$tileKey] If $tile.ContainsPoint($x, $y) Then Return $tileKey EndIf Next Return Null EndFunc ;==>FindTileAtCoordinates ; Trouve une tuile vide adjacente Func FindEmptyNeighbor($this, $tileKey) Local $currentTile = $this.Tiles[$tileKey] Local $tileKeys = MapKeys($this.Tiles) For $key In $tileKeys Local $neighbor = $this.Tiles[$key] If $neighbor.Number = 0 And _ $neighbor <> $currentTile And _ $currentTile.CheckCollision($neighbor) Then Return $key EndIf Next Return Null EndFunc ;==>FindEmptyNeighbor ; Échange les numéros entre deux tuiles Func ExchangeTiles($this, $tile1Key, $tile2Key) Local $tiles = $this.Tiles Local $temp = $tiles[$tile1Key].Number $tiles[$tile2Key].Number = $temp $tiles[$tile1Key].Number = 0 $this.Tiles = $tiles EndFunc ;==>ExchangeTiles ; Met à jour l'affichage des tuiles Func RefreshDisplay($this) For $tile In $this.Tiles $tile.DisplayNumber($tile.Number) Next EndFunc ;==>RefreshDisplay ; Affiche le plateau de jeu Func RenderPuzzle($this) Local $graphicsContext = $this.GraphicsContext Local $graphics = $graphicsContext["GraphicsObject"] Local $pen = _GDIPlus_PenCreate(0xFFFF0000, 2) _GDIPlus_GraphicsClear($graphics, 0xFF000000) Local $tiles = $this.Tiles For $tile In $tiles _GDIPlus_GraphicsDrawRect($graphics, $tile.X, $tile.Y, $tile.Size, $tile.Size, $pen) For $line In $tile.Lines Local $linePen = _GDIPlus_PenCreate($line.Color, $line.Thickness) _GDIPlus_GraphicsDrawLine($graphics, $line.StartX, $line.StartY, $line.EndX, $line.EndY, $linePen) _GDIPlus_PenDispose($linePen) Next Next _GDIPlus_PenDispose($pen) _GDIPlus_GraphicsDrawImageRect($graphicsContext["Graphics"], $graphicsContext["Bitmap"], 0, 0, $this.WindowWidth, $this.WindowHeight) EndFunc ;==>RenderPuzzle Func ResetPuzzle($this) Local $numbers[16] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15] _ArrayShuffle($numbers) Local $tiles = $this.Tiles For $i = 0 To UBound($tiles) - 1 $tiles[$i].Number = $numbers[$i] $tiles[$i].DisplayNumber($tiles[$i].Number) Next EndFunc ;==>ResetPuzzle ; Vérifie la condition de victoire Func VerifyWinCondition($this) Local $tiles = $this.Tiles For $i = 1 To UBound($tiles) - 1 ; Les cases doivent être triées de 1 à 15, avec la dernière case vide (0) If $tiles[$i].Number <> $i Then Return False EndIf Next Return True EndFunc ;==>VerifyWinCondition ; Libère les ressources Func ReleaseResources($this) Local $graphicsContext = $this.GraphicsContext _GDIPlus_BrushDispose($graphicsContext["BackgroundBrush"]) _GDIPlus_GraphicsDispose($graphicsContext["Graphics"]) _GDIPlus_BitmapDispose($graphicsContext["Bitmap"]) GUIDelete($graphicsContext["BoardWindow"]) _GDIPlus_Shutdown() EndFunc ;==>ReleaseResources Global $game = CreatePuzzleGame() $game.Run() $game = 0 Have fun!2 points
-
Well giving your full script with missing parts is not helping us very much. But since I am waiting for my car to get maintenance, here my take on what I think you want : #include <File.au3> #include <GUIConstants.au3> #include <InetConstants.au3> #include <GuiListView.au3> Opt("MustDeclareVars", True) Example() Func Example() Local $aDownList[20][6] Local $hGUI = GUICreate('Example', 600, 600, 200, 200, $WS_SIZEBOX) Local $idListView = GUICtrlCreateListView("ID|Status|File", 50, 20, 500, 400) _GUICtrlListView_SetColumnWidth($idListView, 1, 80) _GUICtrlListView_SetColumnWidth($idListView, 2, 300) Local $idDownload = GUICtrlCreateButton("Add DownLoad", 50, 500, 150, 25) GUISetState() Local $iIndex While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idDownload ;$iIndex = AddDown($aDownList, "http://www.autoitscript.com/autoit3/files/beta/update.dat", _TempFile(@ScriptDir, Default, ".txt", 10)) $iIndex = AddDown($aDownList, "https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3.zip", _TempFile(@ScriptDir, Default, ".zip", 10)) $aDownList[$iIndex][5] = GUICtrlCreateListViewItem($aDownList[$iIndex][0] & "|0.0%|" & $aDownList[$iIndex][3], $idListView) EndSwitch VerifyDownLoad($idListView, $aDownList) WEnd EndFunc ;==>Example Func AddDown(ByRef $aList, $sURL, $sFile) For $i = 0 To UBound($aList) - 1 If Not $aList[$i][0] Then ExitLoop Next If $i = UBound($aList) Then Return SetError(1) $aList[$i][0] = InetGet($sURL, $sFile, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) $aList[$i][1] = 0 $aList[$i][2] = 0 $aList[$i][3] = $sFile $aList[$i][4] = $sURL Return $i EndFunc ;==>AddDown Func VerifyDownLoad($idLV, ByRef $aList) Local $sStatus, $iValue Local $tInfo = DllStructCreate($tagLVFINDINFO) $tInfo.Flags = $LVFI_PARAM For $i = 0 To UBound($aList) - 1 If Not $aList[$i][0] Then ContinueLoop If InetGetInfo($aList[$i][0], $INET_DOWNLOADCOMPLETE) Then $sStatus = "Complete" InetClose($aList[$i][0]) $aList[$i][0] = 0 Else $iValue = InetGetInfo($aList[$i][0], $INET_DOWNLOADREAD) If $iValue = $aList[$i][2] Then ContinueLoop If Not $aList[$i][1] Then $aList[$i][1] = InetGetInfo($aList[$i][0], $INET_DOWNLOADSIZE) $sStatus = StringFormat("%.1f%%", $iValue / $aList[$i][1] * 100) $aList[$i][2] = $iValue EndIf $tInfo.Param = $aList[$i][5] $iValue = _GUICtrlListView_FindItem($idLV, -1, $tInfo) _GUICtrlListView_SetItem($idLV, $sStatus, $iValue, 1) Next EndFunc ;==>VerifyDownLoad ps. see how you can make a runable script without having the full blown code...2 points
-
@Gianni Added this UDF to the wiki2 points
-
So, this so often happens that I'm now considering writing my questions to a dummy forum. Once I'd laid the question out, I found a work around. Instead of deleting the rows where the images are, I use this first: _OOoCalc_RangeClearContents($oCalc, "C" & $x+1 & ":AZ" & $xEnd, -1, -1, -1, -1, 128) ;128 for objects, 1023 for all types of data) This clears the offending pictures and now when I collapse the sheet by deleting the redundant rows, they don't pile up at the bottom of the sheet. Someone else might try the same approach - I hope that I save them some time by sharing. I'd still love to find out how I can access an array of picture objects and query them to establish their anchors and thereby identify them. That would be far safer and more reliable than my clumsy approach. But, for now, back to programming and testing. Regards John2 points
-
@Numeric1, perhaps you'd like to consider changing this: to this: The goal is to flip all the pieces on the board so that they display the other color (e.g., all black if you started with all white). that way @argumentum can click the same square as much as likes, and keep enjoying this forever 🙂2 points
-
One simple way is to use a back buffer : #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphic) Local $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsSetTextRenderingHint($hBuffer, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 4) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 200, "Tahoma", 66) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example2 points
-
How to create rounded corners? (_GDIPlus)
argumentum and one other reacted to ioa747 for a topic
another approach for buttons with rounded corners https://www.autoitscript.com/forum/topic/211721-round-buttons/#findComment-15402632 points -
Method for Colorful Rectangle Buttons with rounded corners ; https://www.autoitscript.com/forum/topic/211721-round-buttons/#findComment-1540263 ;---------------------------------------------------------------------------------------- ; Title...........: RoundRectButtonsSpecial.au3 ; Description.....: collection of rectangles buttons - Special Edition ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Global $MyGui, $aBtn[6][2] $MyGui = GUICreate(@ScriptName, 180, 220) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) $aBtn[0][0] = 5 ; cnt of buttons $aBtn[1][1] = 0xA64500 $aBtn[1][0] = _CreateButton($MyGui, "Button1", 10, 20, 150, 30, $aBtn[1][1], -1, 0xFFFFFF, 10, 800) $aBtn[2][1] = 0x826E00 $aBtn[2][0] = _CreateButton($MyGui, "Button2", 10, 60, 150, 30, $aBtn[2][1], -1, 0xFFFFFF, 10, 800) $aBtn[3][1] = 0x268000 $aBtn[3][0] = _CreateButton($MyGui, "Button3", 10, 100, 150, 30, $aBtn[3][1], -1, 0xFFFFFF, 10, 800) $aBtn[4][1] = 0x0094FF $aBtn[4][0] = _CreateButton($MyGui, "Button4", 10, 140, 150, 30, $aBtn[4][1], -1, 0xFFFFFF, 10, 800) $aBtn[5][1] = 0x9600D5 $aBtn[5][0] = _CreateButton($MyGui, "Button5", 10, 180, 150, 30, $aBtn[5][1], -1, 0xFFFFFF, 10, 800) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch _IsOver() WEnd ;--------------------------------------------------------------------------------------- Func _IsOver() Local Static $iActive, $iClicked = 0 Local $aActive = GUIGetCursorInfo($MyGui) If $aActive[2] And $iClicked = 1 Then Return If $iActive <> $aActive[4] And $iClicked = 0 Then $iActive = $aActive[4] For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], 30)) ;hover Else GUICtrlSetBkColor($aBtn[$i][0], $aBtn[$i][1]) ;normal EndIf Next EndIf If $aActive[2] Or $iClicked = 1 Then For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $iActive Then If $iClicked = 0 Then GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], -30)) ;click GUICtrlSetFont($aBtn[$i][0], 10, 800, 2, "MS Sans Serif") GUICtrlSetColor($aBtn[$i][0], 0xCCCCCC) $iClicked = 1 Else GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], 30)) ;hover GUICtrlSetFont($aBtn[$i][0], 10, 800, 0, "MS Sans Serif") GUICtrlSetColor($aBtn[$i][0], 0xFFFFFF) $iClicked = 0 _ButtonCaller($aBtn[$i][0]) EndIf EndIf Next EndIf EndFunc ;==>_IsOver ;--------------------------------------------------------------------------------------- Func _ButtonCaller($Btn) Switch $Btn Case $aBtn[1][0] ConsoleWrite(GUICtrlRead($aBtn[1][0]) & @CRLF) Case $aBtn[2][0] ConsoleWrite(GUICtrlRead($aBtn[2][0]) & @CRLF) Case $aBtn[3][0] ConsoleWrite(GUICtrlRead($aBtn[3][0]) & @CRLF) Case $aBtn[4][0] ConsoleWrite(GUICtrlRead($aBtn[4][0]) & @CRLF) Case $aBtn[5][0] ConsoleWrite(GUICtrlRead($aBtn[5][0]) & @CRLF) Case $aBtn[6][0] ConsoleWrite(GUICtrlRead($aBtn[6][0]) & @CRLF) EndSwitch EndFunc ;==>_ButtonCaller ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _CreateButton ; Description....: Creates a button with rounded corners. ; Syntax.........: _CreateButton($hGUI, $Text, $Left, $Top, $Width, $Height, $Color, $Corner = -1, $fColor = -1, $fSize = -1, $fWeight = -1, $fName = -1) ; Parameters.....: $hGUI - Handle to the parent GUI. ; $Text - Text to display on the button. ; $Left - Horizontal position of the button. ; $Top - Vertical position of the button. ; $Width - Width of the button. ; $Height - Height of the button. ; $Color - Background color of the button. ; $Corner - [optional] Corner radius of the button (default: $Height / 2). ; $fColor - [optional] Font color of the button text (default: 0x000000). ; $fSize - [optional] Font size of the button text (default: $Height * 0.4). ; $fWeight - [optional] Font weight of the button text (default: 400). ; $fName - [optional] Font name of the button text (default: "MS Sans Serif"). ; Return values..: The handle to the created button control. ; Author ........: ioa747 ; Notes .........: This function uses the WinAPI function CreateRoundRectRgn() and SetWindowRgn() to create a button with rounded corners. ; Link ..........: https://www.autoitscript.com/forum/topic/211721-round-buttons/#findComment-1540263 ; Dependencies...: #include <WinAPIGdi.au3>, #include <WindowsConstants.au3> ;-------------------------------------------------------------------------------------------------------------------------------- Func _CreateButton($hGUI, $Text, $Left, $Top, $Width, $Height, $Color, $Corner = -1, $fColor = -1, $fSize = -1, $fWeight = -1, $fName = -1) ; Validate parameters If $fColor = Default Or $fColor = -1 Then $fColor = 0x000000 If $fSize = Default Or $fSize = -1 Then $fSize = $Height * 0.4 If $fWeight = Default Or $fWeight = -1 Then $fWeight = 400 If $fName = Default Or $fName = -1 Then $fName = "MS Sans Serif" If $Corner < 0 Or $Corner = Default Then $Corner = $Height / 2 If $Corner > $Height / 2 Then $Corner = $Height If $Width <= 0 Or $Height <= 0 Then Return SetError(1, 0, 0) EndIf Local $hChGUI = GUICreate("", $Width, $Height, $Left, $Top, $WS_CHILD, $WS_EX_CONTROLPARENT, $hGUI) Local $idLabel = GUICtrlCreateLabel($Text, 0, 0, $Width, $Height, BitOR($SS_CENTER, $SS_NOTIFY, $SS_CENTERIMAGE)) GUICtrlSetBkColor($idLabel, $Color) GUICtrlSetColor($idLabel, $fColor) GUICtrlSetFont($idLabel, $fSize, $fWeight, 0, $fName) Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $Width, $Height, $Corner, $Corner) _WinAPI_SetWindowRgn($hChGUI, $hRgn) GUISetState() Return $idLabel EndFunc ;==>_CreateButton ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: ColorLight() ; Description....: Returns a new color that is a combination of the $HexColor plus the amount of $Lightness it adds to all three RGB channels. ; Syntax.........: ColorLight($HexColor [, $Lightness [,$output]]) ; Parameters.....: $HexColor - The start color to be combined. ; $Lightness - The amount it adds to all three RGB channels. Negative number to subtract (darker) ; $output - Optional: The format of the output string: ; 0 = "0x" followed by the hexadecimal value of the new color (default) ; 1 = "#" followed by the hexadecimal value of the new color ; 2 = an array containing the red, green and blue values of the new color ; Return values..: The new color as a string or an array. ; Author ........: ioa747 ; Notes .........: ;-------------------------------------------------------------------------------------------------------------------------------- Func ColorLight($HexColor, $Lightness = 0, $sOutput = 0) If StringLeft($HexColor, 1) = "#" Then $HexColor = StringReplace($HexColor, "#", "0x") Local $sHexColor = Hex($HexColor, 6) ;ConsoleWrite("$sHexColor=" & $sHexColor & @CRLF) Local $aSplit = StringSplit($sHexColor, "") Local $aRGB[3] If $aSplit[0] = 6 Then $aRGB[0] = Dec($aSplit[1] & $aSplit[2], 0) $aRGB[1] = Dec($aSplit[3] & $aSplit[4], 0) $aRGB[2] = Dec($aSplit[5] & $aSplit[6], 0) ;ConsoleWrite(StringFormat("aRGB(%d,%d,%d)", $aRGB[0], $aRGB[1], $aRGB[2]) & @CRLF) Else ConsoleWrite("Something wrong $aSplit[0]=" & $aSplit[0] & @CRLF) Return SetError(1, 0, -1) EndIf Local $aNewRGB[] = [$aRGB[0] + $Lightness, $aRGB[1] + $Lightness, $aRGB[2] + $Lightness] If $aNewRGB[0] < 0 Then $aNewRGB[0] = 0 If $aNewRGB[0] > 255 Then $aNewRGB[0] = 255 If $aNewRGB[1] < 0 Then $aNewRGB[1] = 0 If $aNewRGB[1] > 255 Then $aNewRGB[1] = 255 If $aNewRGB[2] < 0 Then $aNewRGB[2] = 0 If $aNewRGB[2] > 255 Then $aNewRGB[2] = 255 ;ConsoleWrite(StringFormat("aNewRGB(%d,%d,%d)", $aNewRGB[0], $aNewRGB[1], $aNewRGB[2]) & @CRLF) Local $sColor ;$sOutput: 0:="0x" | 1:="#" | 2:=aRGB[R,G,B] Switch $sOutput Case 0, 1 $sColor = ($sOutput = 1 ? "#" : "0x") $sColor &= Hex(String($aNewRGB[0]), 2) $sColor &= Hex(String($aNewRGB[1]), 2) $sColor &= Hex(String($aNewRGB[2]), 2) ;ConsoleWrite("$sColor=" & $sColor & @CRLF & @CRLF) Case 2 $sColor = $aNewRGB EndSwitch Return $sColor EndFunc ;==>ColorLight have fun Thank you very much2 points
-
I like the AddArc. It is simpler to code than AddCurve. Here my take on your function : Func _GDIPlus_PathAddRoundRect(ByRef $hPath, $iX, $iY, $iWidth, $iHeight, $iRadius) _GDIPlus_PathAddArc($hPath, $iX, $iY, $iRadius, $iHeight, 90, 180) _GDIPlus_PathAddArc($hPath, $iX + $iWidth, $iY, $iRadius, $iHeight, -90, 180) _GDIPlus_PathCloseFigure($hPath) EndFunc Called this way : _GDIPlus_PathAddRoundRect($hPath, $tRect_Coords[0], $tRect_Coords[1], $tRect_Coords[2], $tRect_Coords[3], 60) Adding : _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; antialiasing Make really nice rounded buttons...2 points
-
a little different #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> Global $hGraphic, $hBrush, $hBrushFont, $hFont, $hFormat, $hFamily, $hGUI, $tRect_Coords[4] Global $iTheme = 0 Example() ;--------------------------------------------------------------------------------------- Func Example() ; Create GUI $hGUI = GUICreate("GDI+ Centered Text", 400, 300) ; Initialize GDI+ _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBrush = _GDIPlus_BrushCreateSolid(0xAA43A6DF) ; Blue $hBrushFont = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) ; White $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) ; Horizontal alignment _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ; Vertical alignment $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Light") $hFont = _GDIPlus_FontCreate($hFamily, 20, 2) ; Rectangle coordinates $tRect_Coords[0] = 50 $tRect_Coords[1] = 50 $tRect_Coords[2] = 200 $tRect_Coords[3] = 100 ; Register for painting GUIRegisterMsg($WM_PAINT, "WM_PAINT") GUISetState() ; Loop until the user exits Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN If CheckPointer($tRect_Coords) Then SetTheme(1) Case $GUI_EVENT_PRIMARYUP SetTheme(0) Case $GUI_EVENT_MOUSEMOVE If GetTheme() = 1 Then ContinueLoop If CheckPointer($tRect_Coords) Then SetTheme(2) Else SetTheme(0) EndIf EndSwitch Until 0 ; Clean up resources _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrushFont) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example ;--------------------------------------------------------------------------------------- Func WM_PAINT($hGUI, $iMsg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_UPDATENOW) ; Clear the canvas _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) ; Create a path for the rounded rectangle Local $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddRoundRect($hPath, $tRect_Coords[0], $tRect_Coords[1], $tRect_Coords[2], $tRect_Coords[3], 20) ; Fill the rounded rectangle _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Optionally draw the outline Local $hPen = _GDIPlus_PenCreate(0xFF3685B2, 2) ; Darker Blue border _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ; Draw the string centered in the rectangle _GDIPlus_GraphicsDrawStringEx($hGraphic, "Click Me", $hFont, _GDIPlus_RectFCreate($tRect_Coords[0], $tRect_Coords[1], $tRect_Coords[2], $tRect_Coords[3]), $hFormat, $hBrushFont) ; Clean up _GDIPlus_PenDispose($hPen) _GDIPlus_PathDispose($hPath) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_VALIDATE) Return 0 EndFunc ;==>WM_PAINT ;--------------------------------------------------------------------------------------- Func CheckPointer(ByRef $aiCoords_ClientRel) Return _WinAPI_PtInRectEx(_WinAPI_GetMousePosX(True, $hGUI), _WinAPI_GetMousePosY(True, $hGUI), $aiCoords_ClientRel[0], $aiCoords_ClientRel[1], $aiCoords_ClientRel[0] + $aiCoords_ClientRel[2], $aiCoords_ClientRel[1] + $aiCoords_ClientRel[3]) EndFunc ;==>CheckPointer ;--------------------------------------------------------------------------------------- Func GetTheme() Return $iTheme EndFunc ;==>GetTheme ;--------------------------------------------------------------------------------------- Func SetTheme($Theme, $f_Redraw = True) If GetTheme() = $Theme Then Return 1 If $Theme = 0 Then ; Idle _GDIPlus_BrushSetSolidColor($hBrush, 0xAA43A6DF) ; Blue $tRect_Coords[0] = 50 $tRect_Coords[1] = 50 ElseIf $Theme = 1 Then ; MouseDown _GDIPlus_BrushSetSolidColor($hBrush, 0xFF3685B2) ; Darker Blue $tRect_Coords[0] = 52 $tRect_Coords[1] = 52 ; Move slightly down ElseIf $Theme = 2 Then ; MouseOver _GDIPlus_BrushSetSolidColor($hBrush, 0xBB7BC1E9) ; Lighter Blue $tRect_Coords[0] = 50 $tRect_Coords[1] = 50 Else Return SetError(1, 0, 0) EndIf $iTheme = $Theme If $f_Redraw Then _WinAPI_RedrawWindow($hGUI, 0, 0, BitOR($RDW_INTERNALPAINT, $RDW_ERASE)) EndFunc ;==>SetTheme ;--------------------------------------------------------------------------------------- Func _GDIPlus_PathAddRoundRect($hPath, $iX, $iY, $iWidth, $iHeight, $iRadius) Local $iDiameter = $iRadius * 2 _GDIPlus_PathAddArc($hPath, $iX, $iY, $iDiameter, $iDiameter, 180, 90) _GDIPlus_PathAddLine($hPath, $iX + $iRadius, $iY, $iX + $iWidth - $iRadius, $iY) _GDIPlus_PathAddArc($hPath, $iX + $iWidth - $iDiameter, $iY, $iDiameter, $iDiameter, 270, 90) _GDIPlus_PathAddLine($hPath, $iX + $iWidth, $iY + $iRadius, $iX + $iWidth, $iY + $iHeight - $iRadius) _GDIPlus_PathAddArc($hPath, $iX + $iWidth - $iDiameter, $iY + $iHeight - $iDiameter, $iDiameter, $iDiameter, 0, 90) _GDIPlus_PathAddLine($hPath, $iX + $iWidth - $iRadius, $iY + $iHeight, $iX + $iRadius, $iY + $iHeight) _GDIPlus_PathAddArc($hPath, $iX, $iY + $iHeight - $iDiameter, $iDiameter, $iDiameter, 90, 90) _GDIPlus_PathAddLine($hPath, $iX, $iY + $iHeight - $iRadius, $iX, $iY + $iRadius) EndFunc ;==>_GDIPlus_PathAddRoundRect ;---------------------------------------------------------------------------------------2 points
-
Here how you could draw a rounded button with GDI+ : #include <GDIPlus.au3> #include <GUIConstants.au3> Example() Func Example() Local $hGUI = GUICreate("GDI+", 500, 300) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; antialiasing _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) Local $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA) Local $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2) Local $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2) Local $aPoints[4][2] = [[3]] Local $hPath = _GDIPlus_PathCreate() $aPoints[1][0] = 0 $aPoints[1][1] = 35 $aPoints[2][0] = 5 $aPoints[2][1] = 5 $aPoints[3][0] = 35 $aPoints[3][1] = 0 _GDIPlus_PathAddCurve($hPath, $aPoints) _GDIPlus_PathAddLine($hPath, 35, 0, 150, 0) $aPoints[1][0] = 150 $aPoints[1][1] = 0 $aPoints[2][0] = 180 $aPoints[2][1] = 5 $aPoints[3][0] = 185 $aPoints[3][1] = 35 _GDIPlus_PathAddCurve($hPath, $aPoints) $aPoints[1][0] = 185 $aPoints[1][1] = 35 $aPoints[2][0] = 180 $aPoints[2][1] = 65 $aPoints[3][0] = 150 $aPoints[3][1] = 70 _GDIPlus_PathAddCurve($hPath, $aPoints) _GDIPlus_PathAddLine($hPath, 150, 70, 35, 70) $aPoints[1][0] = 35 $aPoints[1][1] = 70 $aPoints[2][0] = 5 $aPoints[2][1] = 65 $aPoints[3][0] = 0 $aPoints[3][1] = 35 _GDIPlus_PathAddCurve($hPath, $aPoints) _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) Local $hBrushFont = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Light") Local $hFont = _GDIPlus_FontCreate($hFamily, 18, 1) _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world !", $hFont, _GDIPlus_RectFCreate(20, 20, 160, 40), $hFormat, $hBrushFont) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_BrushDispose($hBrushFont) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example I hardcoded everything since I am not sure if this is what you want.2 points
-
Best way is to create a scheduled task (taskschd.msc) to run every day at 6am.2 points
-
There's also the old highprecisionsleep() by monoceres... other variants throughout the thread.2 points
-
mr-es335, A number of solutions in this thread: M232 points
-
#include <Constants.au3> #include <GUIConstants.au3> Opt("MustDeclareVars", True) Example() Func Example() Local $hGUI = GUICreate("Example", 300, 200) Local $idDummy = GUICtrlCreateMenu("dummy") Local $idMenu = GUICtrlCreateMenuItem("click me", -1) GUICtrlDelete($idDummy) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idMenu MsgBox($MB_OK, "Test", "Working") EndSwitch WEnd EndFunc2 points
-
[Solved] PNG scaled down to GUI, cropped
ioa747 and one other reacted to cramaboule for a topic
After digging into my script I found a small bug or improvement in the code of @UEZ in the UDF of GDI+ _GDIPlus_ImageScale() : I added Floor($iNewWidth), Floor($iNewHeight) Here is my script working nicely 😄 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Local $idPic, $idPic1 GUICreate('Test', 200, 500, 1050, 50) ;Create a GUI GUISetBkColor(0xFFFFFF) $idPic = _GUICtrlCreatePngScale(@ScriptDir & "\big-green.png", 5, 5, .035) $idPic1 = _GUICtrlCreatePngScale(@ScriptDir & "\big-green.png", 5, 200, 1) $idPic2 = GUICtrlCreatePic(@ScriptDir & "\green.bmp", 5, 300, 100, 100) GUICtrlSetPos($idPic1, 5, 150, 100, 100) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idPic MsgBox($MB_TOPMOST, "Information", "PNG 1 image was clicked") Case $idPic1 MsgBox($MB_TOPMOST, "Information", "PNG 2 image was clicked") Case $idPic2 MsgBox($MB_TOPMOST, "Information", "PNG 3 image was clicked") EndSwitch WEnd Func _GUICtrlCreatePngScale($_sName, $_left, $_top, $_iScale = 1) _GDIPlus_Startup() Local $_hImage = _GDIPlus_ImageLoadFromFile($_sName) ;The PNG image that you want to display Local $B_Scaled = _GDIPlus_ImageScaleNew($_hImage, $_iScale, $_iScale) Local $_idPic = GUICtrlCreatePic("", $_left, $_top, 20, 20) GUICtrlSendMsg($_idPic, 0x0172, 0, _GDIPlus_BitmapCreateHBITMAPFromBitmap($B_Scaled)) _WinAPI_DeleteObject($_hImage) ;some clean up _GDIPlus_ImageDispose($B_Scaled) _GDIPlus_Shutdown() Return $_idPic EndFunc ;==>_GUICtrlCreatePngScale Func _GDIPlus_ImageScaleNew($hImage, $iScaleW, $iScaleH, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) If @error Then Return SetError(1, 0, 0) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) If @error Then Return SetError(2, 0, 0) Local $iNewWidth = $iWidth * $iScaleW Local $iNewHeight = $iHeight * $iScaleH Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iNewWidth, $iNewHeight) If @error Then Return SetError(3, 0, 0) Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetInterpolationMode($hBmpCtxt, $iInterpolationMode) _GDIPlus_GraphicsSetPixelOffsetMode($hBmpCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local $hIA = _GDIPlus_ImageAttributesCreate() __GDIPlus_ImageAttributesSetImageWrapMode($hIA) If @error Then _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) Return SetError(4, 0, 0) EndIf _GDIPlus_GraphicsDrawImageRectRect($hBmpCtxt, $hImage, 0, 0, $iWidth, $iHeight, 0, 0, Floor($iNewWidth), Floor($iNewHeight), $hIA) _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc ;==>_GDIPlus_ImageScale2 points -
I added this UDF to the wiki2 points
-
2 points
-
I indeed see the same on the current Beta happening, but started to work on an update for the "indent fix" logic, and that version is not having this symptom anymore. So guess you will have to wait a bit till I am feeling the urge to finish that, and an update is published.2 points
-
It does seem very easy to do with AutoIt based on the explanation given in the OP. But since we do not own Thorium viewer nor PicPick tool, it is hard to give you code that would really help you. I understand that you have zero experience in programming and you do not know where to start, right ? If it is the case, I would strongly recommend that you start one step at a time, do not try to put too much code in each step, just make sure that every step is performing well with the appropriate error handling. So based on your first post, I suppose that all your archived files are located somewhere over the network or on a special support. I would start there : get a list (at least partial) of those files. To help us, could you show us how you access them (via Windows Explorer ?). For your reading : FileListToArrayRec2 points
-
Problems when returning DllStructGetPtr from function
emcodem and one other reacted to pixelsearch for a topic
Hello, Instead of creating the Global variable $out in the main body of the script and passing 2 parameters to MakeWstrPtr() , why not simply return the structure variable name when the function ends, something like this : Global $g_tStruct = WstrPtr("test") For $i = 5 To 1 Step -1 CallEcho() Next Func WstrPtr($str) Local $tStruct = DllStructCreate("wchar [" & StringLen($str) + 1 & "]") ; +1 for null terminator DllStructSetData($tStruct, 1, $str) Return $tStruct EndFunc Func CallEcho() Local Static $pStruct = DllStructGetPtr($g_tStruct) DllCall($hDll, "WSTR", "Echo", "ptr", $pStruct) EndFunc Concerning the pointer, juste use a Static variable inside CallEcho() so its value won't be destroyed when the function ends. I tested the memory content and it was ok (e.g. "t e s t" was constantly there, during the 5 calls to CallEcho)2 points -
Speed-up GUI Launch and Exit
Musashi and one other reacted to pixelsearch for a topic
@argumentum pointed out the main issue in the script : it's the $Button control created twice with the same variable name : 1) First time, outside a function, it is created as an implicit Global variable : all variables not created inside functions are Global, as explained in this wiki link By default, AutoIt scopes any variables declared in the main body of a script (that is not between a Func and EndFunc pair) as Global and any variables declared within function declarations as Local. But it is a good idea to explicitly declare your variables to make sure that you get what you want [...] If you use the AutoItSetOption("MustDeclareVars", 1) directive you must declare the scope of your variables or you will get error messages [...] AutoIt even allows you to use the same name for Global and Local variables, although this is not recommended as it could easily lead to confusion [...] The value of the $Button variable in main body is 3 (when it is first declared) 2) Second time, inside function _form2() , $Button is declared again (with a value of 4 this time) Because you used the same variable name, then you just changed the value of the Global variable $Button in main body from 3 to 4, as displayed in the Console when you add 2 ConsoleWrite lines to your script : ... $Form1 = GUICreate("", 95, 45) $Button = GUICtrlCreateButton("Launch Me", 10, 10, 75, 25) ConsoleWrite("In Main : $Button = " & $Button & @crlf) ; <============= added line (displays 3) GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 $nMsg = GUIGetMsg() ; ----------------- Switch $nMsg Case $GUI_EVENT_CLOSE ConsoleWrite("In Main : $Button = " & $Button & @crlf) ; <============= added line (displays 4 if you called _form2() Exit ... That's why your $Button in Form1 is not active anymore after you called _form2() , it was created in main body with a value of 3, not 4, so it won't react when you press it again in Form1 Here is the console output, after you called _form2() , closed it then exited the script from Form1 : In Main : $Button = 3 In Main : $Button = 42 points -
Speed-up GUI Launch and Exit
pixelsearch and one other reacted to argumentum for a topic
use #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Don't call every button $Button.2 points -
transparent movable windows with drop shadow
pixelsearch and one other reacted to Nine for a topic
Another way to toggle the button (similar with secondary GUIs) : Global $pOldBtnProc ... Local $hGUI4 = GUICreate("", 52, 51, 300, 300, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) Local $idBtn = GUICtrlCreateButton("Test", 0, 0, 52, 51, $BS_BITMAP) GUICtrlSetImage($idBtn, "Cancel 52-51.bmp") Local $hBtnProc = DllCallbackRegister(WinBtnProc, "long", "hwnd;uint;wparam;lparam") $pOldBtnProc = _WinAPI_SetWindowLong(GUICtrlGetHandle($idBtn), $GWL_WNDPROC, DllCallbackGetPtr($hBtnProc)) ... Func WinBtnProc($hWnd, $iMsg, $wParam, $lParam) Local Static $bHover = False Switch $iMsg Case $WM_MOUSEMOVE If Not $bHover Then GUICtrlSetImage(_WinAPI_GetDlgCtrlID($hWnd), "OK 52-51.bmp") $bHover = True EndIf Case $WM_MOUSELEAVE GUICtrlSetImage(_WinAPI_GetDlgCtrlID($hWnd), "Cancel 52-51.bmp") $bHover = False EndSwitch Return DllCallAddress("long", $pOldBtnProc, "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam)[0] EndFunc ;==>WinBtnProc2 points -
We have changed the login to require your Email address and disabled the option to use your member name to make the hacking of accounts harder, as that was happening regularly lately. We can assist in case you don't remember the Email address used at signup. Just use the "Contact us" link at the bottom of the page.2 points
-
This UDF introduces one or two small tweaks to the functions I posted in Snippet Dump (nothing major). Terminating the CSV with a break is now the default behaviour (although I think it's just a lazy convention). The inclusion of a new function _ArrayToSubItemCSV() got me excited. Thanks for an awesome idea Chimaera. I have included the option to sort the returned CSV formatted strings ascending using any column. ; #include-once #include <Array.au3> ; #INDEX# ======================================================================================================================= ; Title .........: CSVSplit ; AutoIt Version : 3.3.8.1 ; Language ......: English ; Description ...: CSV related functions ; Notes .........: CSV format does not have a general standard format, however these functions allow some flexibility. ; The default behaviour of the functions applies to the most common formats used in practice. ; Author(s) .....: czardas ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_ArrayToCSV ;_ArrayToSubItemCSV ;_CSVSplit ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#============================================================================================================ ; __GetSubstitute ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayToCSV ; Description ...: Converts a two dimensional array to CSV format ; Syntax.........: _ArrayToCSV ( $aArray [, $sDelim [, $sNewLine [, $bFinalBreak ]]] ) ; Parameters ....: $aArray - The array to convert ; $sDelim - Optional - Delimiter set to comma by default (see comments) ; $sNewLine - Optional - New Line set to @LF by default (see comments) ; $bFinalBreak - Set to true in accordance with common practice => CSV Line termination ; Return values .: Success - Returns a string in CSV format ; Failure - Sets @error to: ; |@error = 1 - First parameter is not a valid array ; |@error = 2 - Second parameter is not a valid string ; |@error = 3 - Third parameter is not a valid string ; |@error = 4 - 2nd and 3rd parameters must be different characters ; Author ........: czardas ; Comments ......; One dimensional arrays are returned as multiline text (without delimiters) ; ; Some users may need to set the second parameter to semicolon to return the prefered CSV format ; ; To convert to TSV use @TAB for the second parameter ; ; Some users may wish to set the third parameter to @CRLF ; =============================================================================================================================== Func _ArrayToCSV($aArray, $sDelim = Default, $sNewLine = Default, $bFinalBreak = True) If Not IsArray($aArray) Or Ubound($aArray, 0) > 2 Or Ubound($aArray) = 0 Then Return SetError(1, 0 ,"") If $sDelim = Default Then $sDelim = "," If $sDelim = "" Then Return SetError(2, 0 ,"") If $sNewLine = Default Then $sNewLine = @LF If $sNewLine = "" Then Return SetError(3, 0 ,"") If $sDelim = $sNewLine Then Return SetError(4, 0, "") Local $iRows = UBound($aArray), $sString = "" If Ubound($aArray, 0) = 2 Then ; Check if the array has two dimensions Local $iCols = UBound($aArray, 2) For $i = 0 To $iRows -1 For $j = 0 To $iCols -1 If StringRegExp($aArray[$i][$j], '["\r\n' & $sDelim & ']') Then $aArray[$i][$j] = '"' & StringReplace($aArray[$i][$j], '"', '""') & '"' EndIf $sString &= $aArray[$i][$j] & $sDelim Next $sString = StringTrimRight($sString, StringLen($sDelim)) & $sNewLine Next Else ; The delimiter is not needed For $i = 0 To $iRows -1 If StringRegExp($aArray[$i], '["\r\n' & $sDelim & ']') Then $aArray[$i] = '"' & StringReplace($aArray[$i], '"', '""') & '"' EndIf $sString &= $aArray[$i] & $sNewLine Next EndIf If Not $bFinalBreak Then $sString = StringTrimRight($sString, StringLen($sNewLine)) ; Delete any newline characters added to the end of the string Return $sString EndFunc ;==> _ArrayToCSV ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayToSubItemCSV ; Description ...: Converts an array to multiple CSV formated strings based on the content of the selected column ; Syntax.........: _ArrayToSubItemCSV($aCSV, $iCol [, $sDelim [, $bHeaders [, $iSortCol [, $bAlphaSort ]]]]) ; Parameters ....: $aCSV - The array to parse ; $iCol - Array column used to search for unique content ; $sDelim - Optional - Delimiter set to comma by default ; $bHeaders - Include csv column headers - Default = False ; $iSortCol - The column to sort on for each new CSV (sorts ascending) - Default = False ; $bAlphaSort - If set to true, sorting will be faster but numbers won't always appear in order of magnitude. ; Return values .: Success - Returns a two dimensional array - col 0 = subitem name, col 1 = CSV data ; Failure - Returns an empty string and sets @error to: ; |@error = 1 - First parameter is not a 2D array ; |@error = 2 - Nothing to parse ; |@error = 3 - Invalid second parameter Column number ; |@error = 4 - Invalid third parameter - Delimiter is an empty string ; |@error = 5 - Invalid fourth parameter - Sort Column number is out of range ; Author ........: czardas ; Comments ......; @CRLF is used for line breaks in the returned array of CSV strings. ; ; Data in the sorting column is automatically assumed to contain numeric values. ; ; Setting $iSortCol equal to $iCol will return csv rows in their original ordered sequence. ; =============================================================================================================================== Func _ArrayToSubItemCSV($aCSV, $iCol, $sDelim = Default, $bHeaders = Default, $iSortCol = Default, $bAlphaSort = Default) If Not IsArray($aCSV) Or UBound($aCSV, 0) <> 2 Then Return SetError(1, 0, "") ; Not a 2D array Local $iBound = UBound($aCSV), $iNumCols = UBound($aCSV, 2) If $iBound < 2 Then Return SetError(2, 0, "") ; Nothing to parse If IsInt($iCol) = 0 Or $iCol < 0 Or $iCol > $iNumCols -1 Then Return SetError(3, 0, "") ; $iCol is out of range If $sDelim = Default Then $sDelim = "," If $sDelim = "" Then Return SetError(4, 0, "") ; Delimiter can not be an empty string If $bHeaders = Default Then $bHeaders = False If $iSortCol = Default Or $iSortCol == False Then $iSortCol = -1 If IsInt($iSortCol) = 0 Or $iSortCol < -1 Or $iSortCol > $iNumCols -1 Then Return SetError(5, 0, "") ; $iSortCol is out of range If $bAlphaSort = Default Then $bAlphaSort = False Local $iStart = 0 If $bHeaders Then If $iBound = 2 Then Return SetError(2, 0, "") ; Nothing to parse $iStart = 1 EndIf Local $sTestItem, $iNewCol = 0 If $iSortCol <> -1 And ($bAlphaSort = False Or $iSortCol = $iCol) Then ; In this case we need an extra Column for sorting ReDim $aCSV [$iBound][$iNumCols +1] ; Populate column If $iSortCol = $iCol Then For $i = $iStart To $iBound -1 $aCSV[$i][$iNumCols] = $i Next Else For $i = $iStart To $iBound -1 $sTestItem = StringRegExpReplace($aCSV[$i][$iSortCol], "\A\h+", "") ; Remove leading horizontal WS If StringIsInt($sTestItem) Or StringIsFloat($sTestItem) Then $aCSV[$i][$iNumCols] = Number($sTestItem) Else $aCSV[$i][$iNumCols] = $aCSV[$i][$iSortCol] EndIf Next EndIf $iNewCol = 1 $iSortCol = $iNumCols EndIf _ArraySort($aCSV, 0, $iStart, 0, $iCol) ; Sort on the selected column Local $aSubItemCSV[$iBound][2], $iItems = 0, $aTempCSV[1][$iNumCols + $iNewCol], $iTempIndex $sTestItem = Not $aCSV[$iBound -1][$iCol] For $i = $iBound -1 To $iStart Step -1 If $sTestItem <> $aCSV[$i][$iCol] Then ; Start a new csv instance If $iItems > 0 Then ; Write to main array ReDim $aTempCSV[$iTempIndex][$iNumCols + $iNewCol] If $iSortCol <> -1 Then _ArraySort($aTempCSV, 0, $iStart, 0, $iSortCol) If $iNewCol Then ReDim $aTempCSV[$iTempIndex][$iNumCols] $aSubItemCSV[$iItems -1][0] = $sTestItem $aSubItemCSV[$iItems -1][1] = _ArrayToCSV($aTempCSV, $sDelim, @CRLF) EndIf ReDim $aTempCSV[$iBound][$iNumCols + $iNewCol] ; Create new csv template $iTempIndex = 0 $sTestItem = $aCSV[$i][$iCol] If $bHeaders Then For $j = 0 To $iNumCols -1 $aTempCSV[0][$j] = $aCSV[0][$j] Next $iTempIndex = 1 EndIf $iItems += 1 EndIf For $j = 0 To $iNumCols + $iNewCol -1 ; Continue writing to csv $aTempCSV[$iTempIndex][$j] = $aCSV[$i][$j] Next $iTempIndex += 1 Next ReDim $aTempCSV[$iTempIndex][$iNumCols + $iNewCol] If $iSortCol <> -1 Then _ArraySort($aTempCSV, 0, $iStart, 0, $iSortCol) If $iNewCol Then ReDim $aTempCSV[$iTempIndex][$iNumCols] $aSubItemCSV[$iItems -1][0] = $sTestItem $aSubItemCSV[$iItems -1][1] = _ArrayToCSV($aTempCSV, $sDelim, @CRLF) ReDim $aSubItemCSV[$iItems][2] Return $aSubItemCSV EndFunc ;==> _ArrayToSubItemCSV ; #FUNCTION# ==================================================================================================================== ; Name...........: _CSVSplit ; Description ...: Converts a string in CSV format to a two dimensional array (see comments) ; Syntax.........: CSVSplit ( $aArray [, $sDelim ] ) ; Parameters ....: $aArray - The array to convert ; $sDelim - Optional - Delimiter set to comma by default (see 2nd comment) ; Return values .: Success - Returns a two dimensional array or a one dimensional array (see 1st comment) ; Failure - Sets @error to: ; |@error = 1 - First parameter is not a valid string ; |@error = 2 - Second parameter is not a valid string ; |@error = 3 - Could not find suitable delimiter replacements ; Author ........: czardas ; Comments ......; Returns a one dimensional array if the input string does not contain the delimiter string ; ; Some CSV formats use semicolon as a delimiter instead of a comma ; ; Set the second parameter to @TAB To convert to TSV ; =============================================================================================================================== Func _CSVSplit($string, $sDelim = ",") ; Parses csv string input and returns a one or two dimensional array If Not IsString($string) Or $string = "" Then Return SetError(1, 0, 0) ; Invalid string If Not IsString($sDelim) Or $sDelim = "" Then Return SetError(2, 0, 0) ; Invalid string $string = StringRegExpReplace($string, "[\r\n]+\z", "") ; [Line Added] Remove training breaks Local $iOverride = 63743, $asDelim[3] ; $asDelim => replacements for comma, new line and double quote For $i = 0 To 2 $asDelim[$i] = __GetSubstitute($string, $iOverride) ; Choose a suitable substitution character If @error Then Return SetError(3, 0, 0) ; String contains too many unsuitable characters Next $iOverride = 0 Local $aArray = StringRegExp($string, '\A[^"]+|("+[^"]+)|"+\z', 3) ; Split string using double quotes delim - largest match $string = "" Local $iBound = UBound($aArray) For $i = 0 To $iBound -1 $iOverride += StringInStr($aArray[$i], '"', 0, -1) ; Increment by the number of adjacent double quotes per element If Mod ($iOverride +2, 2) = 0 Then ; Acts as an on/off switch $aArray[$i] = StringReplace($aArray[$i], $sDelim, $asDelim[0]) ; Replace comma delimeters $aArray[$i] = StringRegExpReplace($aArray[$i], "(\r\n)|[\r\n]", $asDelim[1]) ; Replace new line delimeters EndIf $aArray[$i] = StringReplace($aArray[$i], '""', $asDelim[2]) ; Replace double quote pairs $aArray[$i] = StringReplace($aArray[$i], '"', '') ; Delete enclosing double quotes - not paired $aArray[$i] = StringReplace($aArray[$i], $asDelim[2], '"') ; Reintroduce double quote pairs as single characters $string &= $aArray[$i] ; Rebuild the string, which includes two different delimiters Next $iOverride = 0 $aArray = StringSplit($string, $asDelim[1], 2) ; Split to get rows $iBound = UBound($aArray) Local $aCSV[$iBound][2], $aTemp For $i = 0 To $iBound -1 $aTemp = StringSplit($aArray[$i], $asDelim[0]) ; Split to get row items If Not @error Then If $aTemp[0] > $iOverride Then $iOverride = $aTemp[0] ReDim $aCSV[$iBound][$iOverride] ; Add columns to accomodate more items EndIf EndIf For $j = 1 To $aTemp[0] If StringLen($aTemp[$j]) Then If Not StringRegExp($aTemp[$j], '[^"]') Then ; Field only contains double quotes $aTemp[$j] = StringTrimLeft($aTemp[$j], 1) ; Delete enclosing double quote single char EndIf $aCSV[$i][$j -1] = $aTemp[$j] ; Populate each row EndIf Next Next If $iOverride > 1 Then Return $aCSV ; Multiple Columns Else For $i = 0 To $iBound -1 If StringLen($aArray[$i]) And (Not StringRegExp($aArray[$i], '[^"]')) Then ; Only contains double quotes $aArray[$i] = StringTrimLeft($aArray[$i], 1) ; Delete enclosing double quote single char EndIf Next Return $aArray ; Single column EndIf EndFunc ;==> _CSVSplit ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __GetSubstitute ; Description ...: Searches for a character to be used for substitution, ie one not contained within the input string ; Syntax.........: __GetSubstitute($string, ByRef $iCountdown) ; Parameters ....: $string - The string of characters to avoid ; $iCountdown - The first code point to begin checking ; Return values .: Success - Returns a suitable substitution character not found within the first parameter ; Failure - Sets @error to 1 => No substitution character available ; Author ........: czardas ; Comments ......; This function is connected to the function _CSVSplit and was not intended for general use ; $iCountdown is returned ByRef to avoid selecting the same character on subsequent calls to this function ; Initially $iCountown should be passed with a value = 63743 ; =============================================================================================================================== Func __GetSubstitute($string, ByRef $iCountdown) If $iCountdown < 57344 Then Return SetError(1, 0, "") ; Out of options Local $sTestChar For $i = $iCountdown To 57344 Step -1 $sTestChar = ChrW($i) $iCountdown -= 1 If Not StringInStr($string, $sTestChar) Then Return $sTestChar EndIf Next Return SetError(1, 0, "") ; Out of options EndFunc ;==> __GetSubstitute ; See examples in post #8 below. ;2 points
-
Did not notice that. Here one way : #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $hGraphic, $hBitmap, $hBuffer Example() Func Example() Local $hGUI = GUICreate("GDI+ test", 800, 400) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics(800, 400, $hGraphic) $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetTextRenderingHint($hBuffer, $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) _GDIPlus_GraphicsSetSmoothingMode($hBuffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 200, "Tahoma", 66) GUIRegisterMsg($WM_PAINT, WM_PAINT) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) EndSwitch WEnd _GDIPlus_GraphicsDispose($hBuffer) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam) _GDIPlus_GraphicsClear($hBuffer, 0xFFF0F0F0) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 0, "Tahoma", 66) _GDIPlus_GraphicsDrawString($hBuffer, "AutoIt rulez!", 0, 200, "Tahoma", 66) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, 800, 400) Return $GUI_RUNDEFMSG EndFunc1 point
-
Can anyone help me make my script??
an0nymous reacted to argumentum for a topic
...the same way you coded Func Link(). Does chrome save browser data when incognito ?. Maybe you don't have to code anything. Or maybe have a virtual machine to browse whatever you'd like to not have in your PC.1 point -
ScITE Themes Etc
ioa747 reacted to BinaryBrother for a topic
That Theme should be added to the official list. It's pretty good.1 point -
1 point
-
Need help removing multiple nodes in XML
WildByDesign reacted to Nine for a topic
Glad I could help.1 point -
World Time for the CLI
argumentum reacted to CarlD for a topic
Revised based on comments from @argumentum. Script now uses the time server at timeapi.io. Expanded list of available cities. 2024-12-27: Added code from @argumentum to support passing command-line args in SciTE. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=TimeIn.exe #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Run_Au3Stripper=y #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; #include <Date.au3> ; World Time via API at https://timeapi.io Global $sRevDate = "[CLD rev. 2024-12-27]" ; If $CmdLine[0] = 0 Then Exit _ShowHelp() If StringInStr($CmdLine[1], "?") Then Exit _ShowHelp() Global $aData, $aDow, $aDTm, $aFrac = "", $aSubst, $aTZdata Global $bPossDST = 0, $DTadj, $DTime, $h1, $h2 Global $iDoW, $iIncr = 0, $iMatch Global $sData = "", $sOut = "", $sSubst, $iTmp Global $sTail = "", $sTZdata, $sWhere = "" Global $sURL = "https://timeapi.io/api/time/current/zone?timeZone=" If $CmdLine[0] Then $sWhere = $CmdLineRaw If StringInStr($sWhere, @ScriptFullPath) Then $sWhere = StringStripWS(StringTrimLeft($sWhere, StringInStr($sWhere, @ScriptFullPath) + StringLen(@ScriptFullPath)), 3) ConsoleWrite(">" & $sWhere & "<" & @CrLF) EndIf If StringInStr($sWhere, " ") Then $sWhere = StringReplace($sWhere, " ", "_") If StringInStr($sWhere, ".") Then $sWhere = StringReplace($sWhere, ".", "") If StringInStr($sWhere, "UTC+") Then $sWhere = StringReplace($sWhere, "UTC+", "GMT+") If StringInStr($sWhere, "UTC-") Then $sWhere = StringReplace($sWhere, "UTC-", "GMT-") If StringInStr($sWhere, "GMT+") Then $sWhere = StringReplace($sWhere, "GMT+", "GMT-") If StringInStr($sWhere, "GMT-") Then $sWhere = StringReplace($sWhere, "GMT-", "GMT+") ; Supplemental list of cities not in IANA time zone list ; Substitutes time zone for city name ; GMT offsets use opposite sign -/+ (quirk of time zone data format) $sSubst = "EST5EDT,Miami,Atlanta,Boston,Philadelphia,|CST6CDT,New_Orleans,Minneapolis,Kansas_City,Oklahoma_City,Dallas,Houston,|MST7MDT,Salt_Lake_City,|PST8PDT,San_Diego,San_Francisco,Las_Vegas,Seattle,|GMT,Douglas,Jamestown,Lome,Lomé,Edinburgh,Cardiff,Suva,Yaren,Pevek,Petropavlovsk-Kamchatsky,Yamoussoukro,Torshavn,Tórshavn,|GMT-1,Tirana,Porto_Novo,Yaounde,Yaoundé,N'Djamena,Frankfurt,Valletta,Catania,Rabat*,Abuja,Tromso,Barcelona,Bern,Vatican_City,|GMT-2,Benghazi,Gitega,Kemi,Rovaniemi,Lilongwe,Cape_Town,Pretoria,Dnipro,|GMT-3,Doha,|GMT-4,Port_Louis,Saint-Denis,Izhevsk,Seychelles,Abu_Dhabi,|GMT-5,Port-aux-Francais,Amsterdam_Island,Astana,Male,Islamabad,Lahore,|GMT-5:30,New_Delhi,Bengaluru,Mumbai,Bombay,Chennai,Sri_Jayawardenepura_Kotte,|GMT-6,Diego_Garcia,|GMT-6:30,Naypyidaw,|GMT-7,Khatanga,Norilsk,Hanoi,|GMT-8,Bandar_Seri_Begawan,Beijing,Lhasa,Denpasar,Nusantara,|GMT-9,Manokwari,Ngerulmud,Tiksi,|GMT-9:30,Alice_Springs,|GMT-10,Cairns,Hagatna,Hagåtña,Komsomolsk-on-Amur,Verkhoyansk,|GMT-11,Palikir,Yuzhno-Sakhalinsk,Honiara,Port_Vila,|GMT+1,Praia,Ponta_Delgada,|GMT+2,Ittoqqortoormiit,Kangerlussuaq,Qaanaaq,King_Edward_Point,|GMT+3,Brasilia,Rio_de_Janeiro,Punta_Arenas*,Santiago*,|GMT+3:30,Mary's_Harbour,|GMT+4,Bridgetown,Hamilton,Sucre,Happy_Valley-Thule_Air_Base,Basse-Terre,Georgetown,|GMT+5,Alert,Eureka,Grise_Fiord,Pond_Inlet,Ottawa,Chibougamau,Kuujjuaq,Easter_Island*,Quito,Kingston,|GMT+6,Belmopan,Baker_Lake,Resolute_Bay,San_Jose,Galapagos_Islands,San_Salvador,Guatemala_City,|GMT+7,Calgary,|GMT+8,Adamstown,|GMT+9,Fairbanks,Unalaska,|GMT+10,Papeete,|GMT+11,Dodoma,Alofi,Ankara,Sana,Manama,Moroni,Kuwait_City,Belushya_Guba,Marion_Island_(Prince_Edward_Islands),Marion_Island,|GMT+12,Baker_Island," $aSubst = StringSplit($sSubst, "|") For $i = 1 To $aSubst[0] If StringInStr($aSubst[$i], ("," & $sWhere)) Then If StringInStr($aSubst[$i], ("," & $sWhere & "*")) Then $sWhere &= "*" $bPossDST = 1 EndIf If StringInStr($aSubst[$i], ("," & $sWhere & ",")) Then $sWhere = _ StringLeft($aSubst[$i], StringInStr($aSubst[$i], ",") - 1) If StringInStr($sWhere, "GMT") = 1 Then $sWhere = "Etc/" & $sWhere EndIf Next ; Fractional UTC/GMT offsets If StringInStr($sWhere, ":") Then $aFrac = StringSplit($sWhere, ":") $sWhere = $aFrac[1] $iIncr = $aFrac[2] If StringInStr($sWhere, "+") Then $iIncr *= -1 EndIf $sTZdata = "Africa/Abidjan,Africa/Accra,Africa/Addis_Ababa,Africa/Algiers,Africa/Asmara,Africa/Asmera,Africa/Bamako,Africa/Bangui,Africa/Banjul,Africa/Bissau,Africa/Blantyre,Africa/Brazzaville,Africa/Bujumbura,Africa/Cairo,Africa/Casablanca,Africa/Ceuta,Africa/Conakry,Africa/Dakar,Africa/Dar_es_Salaam,Africa/Djibouti,Africa/Douala,Africa/El_Aaiun,Africa/Freetown,Africa/Gaborone,Africa/Harare,Africa/Johannesburg,Africa/Juba,Africa/Kampala,Africa/Khartoum,Africa/Kigali,Africa/Kinshasa,Africa/Lagos,Africa/Libreville,Africa/Lome,Africa/Luanda,Africa/Lubumbashi,Africa/Lusaka,Africa/Malabo,Africa/Maputo,Africa/Maseru,Africa/Mbabane,Africa/Mogadishu,Africa/Monrovia,Africa/Nairobi,Africa/Ndjamena,Africa/Niamey,Africa/Nouakchott,Africa/Ouagadougou,Africa/Porto-Novo,Africa/Sao_Tome,Africa/Timbuktu,Africa/Tripoli,Africa/Tunis,Africa/Windhoek,America/Adak,America/Anchorage,America/Anguilla,America/Antigua,America/Araguaina,America/Argentina/Buenos_Aires,America/Argentina/Catamarca,America/Argentina/ComodRivadavia,America/Argentina/Cordoba,America/Argentina/Jujuy,America/Argentina/La_Rioja,America/Argentina/Mendoza,America/Argentina/Rio_Gallegos,America/Argentina/Salta,America/Argentina/San_Juan,America/Argentina/San_Luis,America/Argentina/Tucuman,America/Argentina/Ushuaia,America/Aruba,America/Asuncion,America/Atikokan,America/Atka,America/Bahia,America/Bahia_Banderas,America/Barbados,America/Belem,America/Belize,America/Blanc-Sablon,America/Boa_Vista,America/Bogota,America/Boise,America/Buenos_Aires,America/Cambridge_Bay,America/Campo_Grande,America/Cancun,America/Caracas,America/Catamarca,America/Cayenne,America/Cayman,America/Chicago,America/Chihuahua,America/Ciudad_Juarez,America/Coral_Harbour,America/Cordoba,America/Costa_Rica,America/Creston,America/Cuiaba,America/Curacao,America/Danmarkshavn,America/Dawson,America/Dawson_Creek,America/Denver,America/Detroit,America/Dominica,America/Edmonton,America/Eirunepe,America/El_Salvador,America/Ensenada,America/Fort_Nelson,America/Fort_Wayne,America/Fortaleza,America/Glace_Bay,America/Godthab,America/Goose_Bay,America/Grand_Turk,America/Grenada,America/Guadeloupe,America/Guatemala,America/Guayaquil,America/Guyana,America/Halifax,America/Havana,America/Hermosillo,America/Indiana/Indianapolis,America/Indiana/Knox,America/Indiana/Marengo,America/Indiana/Petersburg,America/Indiana/Tell_City,America/Indiana/Vevay,America/Indiana/Vincennes,America/Indiana/Winamac,America/Indianapolis,America/Inuvik,America/Iqaluit,America/Jamaica,America/Jujuy,America/Juneau,America/Kentucky/Louisville,America/Kentucky/Monticello,America/Knox_IN,America/Kralendijk,America/La_Paz,America/Lima,America/Los_Angeles,America/Louisville,America/Lower_Princes,America/Maceio,America/Managua,America/Manaus,America/Marigot,America/Martinique,America/Matamoros,America/Mazatlan,America/Mendoza,America/Menominee,America/Merida,America/Metlakatla,America/Mexico_City,America/Miquelon,America/Moncton,America/Monterrey,America/Montevideo,America/Montreal,America/Montserrat,America/Nassau,America/New_York,America/Nipigon,America/Nome,America/Noronha,America/North_Dakota/Beulah,America/North_Dakota/Center,America/North_Dakota/New_Salem,America/Nuuk,America/Ojinaga,America/Panama,America/Pangnirtung,America/Paramaribo,America/Phoenix,America/Port_of_Spain,America/Port-au-Prince,America/Porto_Acre,America/Porto_Velho,America/Puerto_Rico,America/Punta_Arenas,America/Rainy_River,America/Rankin_Inlet,America/Recife,America/Regina,America/Resolute,America/Rio_Branco,America/Rosario,America/Santa_Isabel,America/Santarem,America/Santiago,America/Santo_Domingo,America/Sao_Paulo,America/Scoresbysund,America/Shiprock,America/Sitka,America/St_Barthelemy,America/St_Johns,America/St_Kitts," $sTZdata &= "America/St_Lucia,America/St_Thomas,America/St_Vincent,America/Swift_Current,America/Tegucigalpa,America/Thule,America/Thunder_Bay,America/Tijuana,America/Toronto,America/Tortola,America/Vancouver,America/Virgin,America/Whitehorse,America/Winnipeg,America/Yakutat,America/Yellowknife,Antarctica/Casey,Antarctica/Davis,Antarctica/DumontDUrville,Antarctica/Macquarie,Antarctica/Mawson,Antarctica/McMurdo,Antarctica/Palmer,Antarctica/Rothera,Antarctica/South_Pole,Antarctica/Syowa,Antarctica/Troll,Antarctica/Vostok,Arctic/Longyearbyen,Asia/Aden,Asia/Almaty,Asia/Amman,Asia/Anadyr,Asia/Aqtau,Asia/Aqtobe,Asia/Ashgabat,Asia/Ashkhabad,Asia/Atyrau,Asia/Baghdad,Asia/Bahrain,Asia/Baku,Asia/Bangkok,Asia/Barnaul,Asia/Beirut,Asia/Bishkek,Asia/Brunei,Asia/Calcutta,Asia/Chita,Asia/Choibalsan,Asia/Chongqing,Asia/Chungking,Asia/Colombo,Asia/Dacca,Asia/Damascus,Asia/Dhaka,Asia/Dili,Asia/Dubai,Asia/Dushanbe,Asia/Famagusta,Asia/Gaza,Asia/Harbin,Asia/Hebron,Asia/Ho_Chi_Minh,Asia/Hong_Kong,Asia/Hovd,Asia/Irkutsk,Asia/Istanbul,Asia/Jakarta,Asia/Jayapura,Asia/Jerusalem,Asia/Kabul,Asia/Kamchatka,Asia/Karachi,Asia/Kashgar,Asia/Kathmandu,Asia/Katmandu,Asia/Khandyga,Asia/Kolkata,Asia/Krasnoyarsk,Asia/Kuala_Lumpur,Asia/Kuching,Asia/Kuwait,Asia/Macao,Asia/Macau,Asia/Magadan,Asia/Makassar,Asia/Manila,Asia/Muscat,Asia/Nicosia,Asia/Novokuznetsk,Asia/Novosibirsk,Asia/Omsk,Asia/Oral,Asia/Phnom_Penh,Asia/Pontianak,Asia/Pyongyang,Asia/Qatar,Asia/Qostanay,Asia/Qyzylorda,Asia/Rangoon,Asia/Riyadh,Asia/Saigon,Asia/Sakhalin,Asia/Samarkand,Asia/Seoul,Asia/Shanghai,Asia/Singapore,Asia/Srednekolymsk,Asia/Taipei,Asia/Tashkent,Asia/Tbilisi,Asia/Tehran,Asia/Tel_Aviv,Asia/Thimbu,Asia/Thimphu,Asia/Tokyo,Asia/Tomsk,Asia/Ujung_Pandang,Asia/Ulaanbaatar,Asia/Ulan_Bator,Asia/Urumqi,Asia/Ust-Nera,Asia/Vientiane,Asia/Vladivostok,Asia/Yakutsk,Asia/Yangon,Asia/Yekaterinburg,Asia/Yerevan,Atlantic/Azores,Atlantic/Bermuda,Atlantic/Canary,Atlantic/Cape_Verde,Atlantic/Faeroe,Atlantic/Faroe,Atlantic/Jan_Mayen,Atlantic/Madeira,Atlantic/Reykjavik,Atlantic/South_Georgia,Atlantic/St_Helena,Atlantic/Stanley,Australia/ACT,Australia/Adelaide,Australia/Brisbane,Australia/Broken_Hill,Australia/Canberra,Australia/Currie,Australia/Darwin,Australia/Eucla,Australia/Hobart,Australia/LHI,Australia/Lindeman,Australia/Lord_Howe,Australia/Melbourne,Australia/North,Australia/NSW,Australia/Perth,Australia/Queensland,Australia/South,Australia/Sydney,Australia/Tasmania,Australia/Victoria,Australia/West,Australia/Yancowinna,Brazil/Acre,Brazil/DeNoronha,Brazil/East,Brazil/West,Canada/Atlantic,Canada/Central,Canada/Eastern,Canada/Mountain,Canada/Newfoundland,Canada/Pacific,Canada/Saskatchewan,Canada/Yukon,CET,Chile/Continental,Chile/EasterIsland,CST6CDT,Cuba,EET,Egypt,Eire,EST,EST5EDT,Etc/GMT,Etc/GMT-0,Etc/GMT-1,Etc/GMT-10,Etc/GMT-11,Etc/GMT-12,Etc/GMT-13,Etc/GMT-14,Etc/GMT-2,Etc/GMT-3,Etc/GMT-4,Etc/GMT-5,Etc/GMT-6,Etc/GMT-7,Etc/GMT-8,Etc/GMT-9,Etc/GMT+0,Etc/GMT+1,Etc/GMT+10,Etc/GMT+11,Etc/GMT+12,Etc/GMT+2,Etc/GMT+3,Etc/GMT+4,Etc/GMT+5,Etc/GMT+6,Etc/GMT+7,Etc/GMT+8,Etc/GMT+9,Etc/GMT0,Etc/Greenwich,Etc/UCT,Etc/Universal,Etc/UTC,Etc/Zulu,Europe/Amsterdam,Europe/Andorra,Europe/Astrakhan,Europe/Athens,Europe/Belfast,Europe/Belgrade,Europe/Berlin,Europe/Bratislava,Europe/Brussels,Europe/Bucharest,Europe/Budapest,Europe/Busingen,Europe/Chisinau,Europe/Copenhagen,Europe/Dublin,Europe/Gibraltar,Europe/Guernsey," $sTZdata &= "Europe/Helsinki,Europe/Isle_of_Man,Europe/Istanbul,Europe/Jersey,Europe/Kaliningrad,Europe/Kiev,Europe/Kirov,Europe/Kyiv,Europe/Lisbon,Europe/Ljubljana,Europe/London,Europe/Luxembourg,Europe/Madrid,Europe/Malta,Europe/Mariehamn,Europe/Minsk,Europe/Monaco,Europe/Moscow,Europe/Nicosia,Europe/Oslo,Europe/Paris,Europe/Podgorica,Europe/Prague,Europe/Riga,Europe/Rome,Europe/Samara,Europe/San_Marino,Europe/Sarajevo,Europe/Saratov,Europe/Simferopol,Europe/Skopje,Europe/Sofia,Europe/Stockholm,Europe/Tallinn,Europe/Tirane,Europe/Tiraspol,Europe/Ulyanovsk,Europe/Uzhgorod,Europe/Vaduz,Europe/Vatican,Europe/Vienna,Europe/Vilnius,Europe/Volgograd,Europe/Warsaw,Europe/Zagreb,Europe/Zaporozhye,Europe/Zurich,GB,GB-Eire,GMT,GMT-0,GMT+0,GMT0,Greenwich,Hongkong,HST,Iceland,Indian/Antananarivo,Indian/Chagos,Indian/Christmas,Indian/Cocos,Indian/Comoro,Indian/Kerguelen,Indian/Mahe,Indian/Maldives,Indian/Mauritius,Indian/Mayotte,Indian/Reunion,Iran,Israel,Jamaica,Japan,Kwajalein,Libya,MET,Mexico/BajaNorte,Mexico/BajaSur,Mexico/General,MST,MST7MDT,Navajo,NZ,NZ-CHAT,Pacific/Apia,Pacific/Auckland,Pacific/Bougainville,Pacific/Chatham,Pacific/Chuuk,Pacific/Easter,Pacific/Efate,Pacific/Enderbury,Pacific/Fakaofo,Pacific/Fiji,Pacific/Funafuti,Pacific/Galapagos,Pacific/Gambier,Pacific/Guadalcanal,Pacific/Guam,Pacific/Honolulu,Pacific/Johnston,Pacific/Kanton,Pacific/Kiritimati,Pacific/Kosrae,Pacific/Kwajalein,Pacific/Majuro,Pacific/Marquesas,Pacific/Midway,Pacific/Nauru,Pacific/Niue,Pacific/Norfolk,Pacific/Noumea,Pacific/Pago_Pago,Pacific/Palau,Pacific/Pitcairn,Pacific/Pohnpei,Pacific/Ponape,Pacific/Port_Moresby,Pacific/Rarotonga,Pacific/Saipan,Pacific/Samoa,Pacific/Tahiti,Pacific/Tarawa,Pacific/Tongatapu,Pacific/Truk,Pacific/Wake,Pacific/Wallis,Pacific/Yap,Poland,Portugal,PRC,PST8PDT,ROC,ROK,Singapore,Turkey,UCT,Universal,US/Alaska,US/Aleutian,US/Arizona,US/Central,US/East-Indiana,US/Eastern,US/Hawaii,US/Indiana-Starke,US/Michigan,US/Mountain,US/Pacific,US/Samoa,UTC,W-SU,WET,Zulu" $sSubst = StringReplace($sSubst, "_", " ") $sSubst = StringReplace($sSubst, "*", "") $sTZdata &= $sSubst $aTZdata = StringSplit($sTZdata, ",") $iMatch = _ListMatches($sWhere) If Not $iMatch Then If Not $sOut Then $sOut = "Nothing on """ & $sWhere & """" Exit ConsoleWrite($sOut) EndIf $sTail = $aTZdata[$iMatch] $sURL &= $sTail $sData = BinaryToString(InetRead($sURL)) If Not $sData Then _ExitError("No data received") $aData = StringSplit($sData, ",") $aDow = StringSplit("Mon|Tue|Wed|Thu|Fri|Sat|Sun", "|") If $iIncr = 0 Then $sOut &= StringMid($aData[12], 14, 3) & " " $sOut &= StringTrimLeft($aData[10], 8) $sOut = StringTrimRight($sOut, 1) If StringInStr($aData[13], "true") Then $sOut &= " (DST)" Else $DTime = StringReplace(StringMid($aData[8], 13, 16), "-", "/") $DTime = StringReplace($DTime, "T", " ") $DTadj = _DateAdd("n", $iIncr, $DTime) $aDTm = StringSplit(StringLeft($DTadj, 10), "/") $iDoW = _DateToDayofWeek($aDTm[1], $aDTm[2], $aDTm[3]) - 1 If $iDoW < 1 Then $iDoW = 7 $sOut &= $aDoW[$iDoW] & " " & StringRight($DTadj, 5) EndIf If $bPossDST Then $sOut &= @CRLF & "(possibly plus|minus DST offset)" Exit ConsoleWrite($sOut & @CRLF) Func _ListMatches($sStr = "") Local $iCount = 0, $iIndex = 0, $sFixGMT = "", $sStr0 = "" If $sStr Then For $i = 1 To $aTZdata[0] If StringInStr($aTZdata[$i], $sStr) = 0 Or _ StringInStr($aTZdata[$i], "|") = 1 Then ContinueLoop $iIndex = $i $sStr0 = $aTZdata[$i] If StringInStr($sStr0, "/") And Not StringInStr($sStr0, "Etc/") Then $sStr0 = StringSplit($sStr0, "/")[2] If $sStr0 = $sStr Then $sFixGMT = $aTZdata[$i] If StringInStr($sFixGMT, "Etc/") = 1 Then $sFixGMT = StringReplace($aTZdata[$i], "Etc/GMT", "UTC/GMT") If StringInStr($sFixGMT, "+") = 8 Then $sFixGMT = StringReplace($sFixGMT, "+", "-") ElseIf StringInStr($sFixGMT, "-") = 8 Then $sFixGMT = StringReplace($sFixGMT, "-", "+") EndIf EndIf If $iIncr > 0 Then $sFixGMT &= ":" & String(Abs($iIncr)) $sOut &= $sFixGMT & " " Return $iIndex EndIf $iCount += 1 If $iCount = 2 Then $sOut &= @CRLF If StringInStr($aTZdata[$i], "Etc/") = 0 Then $sOut &= $aTZdata[$i] & " " If $iCount > 1 Then $sOut &= @CRLF EndIf Next EndIf If Not $iCount Then _ExitError("Nothing on """ & $sStr & """") Else If $iCount > 1 Then $iCount = 0 Else $iCount = $iIndex EndIf EndIf Return $iCount EndFunc ;==>_ListMatches Func _ExitError($sStr = "") If $sStr Then ConsoleWrite($sStr & @CRLF) Exit EndFunc ;==>_ExitError Func _ShowHelp() ConsoleWrite("World Time via timeapi.io " & $sRevDate & @CRLF & "Usage:" & @CRLF & StringTrimRight(@ScriptName, 4) & " <CITY>" & @CRLF & "--" & @CRLF & StringTrimRight(@ScriptName, 4) & " <substring> lists cities in database containing <substring>" & @CRLF & "Listings in format <continent>/<city> (e.g., Europe/Lisbon) obtain" & @CRLF & " the current time from the server at timeapi.io." & @CRLF & "Listings with city name only obtain the time based on the applicable" & @CRLF & " UTC/GMT offset identified in www.timeanddate.com." & @CRLF & "Accuracy is NOT guaranteed!" & @CRLF) EndFunc ;==>_ShowHelp1 point -
World Time for the CLI
CarlD reacted to argumentum for a topic
..the Hippocratic oath. The same that said "A physician without knowledge of astrology has no right to call himself a physician.". ( if memory serves. Long time ago ) ..the Jewish had a strong dispute ( if not brake away ) about being a Moon follower vs. a Sun follower. ( thousands of years ago but I don't remember clearly. It was thousands of years ago ) Yes, daylight savings time will save us from .. something. Yet there are records that show that in average more people die of a heart attack the following day Maybe we should all live by the sundial. It'd be a pain to organize a game online but, ..if we needed guns to defend from wild animals like in the days of the far/wild west, a high noon bang-bang may not occur in time. To this day countries are moving time to a side or the other. ..yes, I agree. I have eyes on a pocket sundial that I like 🤪 hmmm, .. I think this goes in chat 🤦♂️1 point -
Static Button?
mr-es335 reacted to argumentum for a topic
1 point -
Hi guys, here is a small dll wrapper I made geared at making YOLOv3 (Joseph Redmon, Ali Farhadi) more accessible to AutoIt users. Homepage of YOLO: https://pjreddie.com/darknet/yolo/ Technical overview: You only look once (YOLO) is a state-of-the-art, real-time object detection system. On a Pascal Titan X it processes images at 30 FPS and has a mAP of 57.9% on COCO test-dev. (from https://pjreddie.com/darknet/yolo/) Screenshots: Features: This UDF currently supports recognizing objects in images passed in as a HBITMAP Below is a complete list of the functions currently available in this library: ; #CURRENT# ===================================================================================================================== ;_AutoYolo3_GetLastError ;_AutoYolo3_GetObjInHBitmap ;_AutoYolo3_GetVersion ;_AutoYolo3_SetConfig ;_AutoYolo3_YoloTest ; =============================================================================================================================== The _AutoYolo3_GetObjInHBitmap function returns a 2D Array of detected objects as illustrated below: Examples: Example1: basic_example.au3 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <AutoYOLO3.au3> #include <GDIPlus.au3> ConsoleWrite("Using autoyolo version:" & _AutoYolo3_GetVersion() & @CRLF) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&"\people-2557408_1920.jpg") Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage, 0x00000000) Local $aRes = _AutoYolo3_GetObjInHBitmap($hHBITMAP) _ArrayDisplay($aRes) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Example 2: gui_example.au3 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoYOLO3.au3> #include <GDIPlus.au3> ConsoleWrite("Using autoyolo version:" & _AutoYolo3_GetVersion() & @CRLF) _GUIExample1() Func _GUIExample1() _GDIPlus_Startup() Local $iPicW=609 Local $iPicH=385 #Region ### START Koda GUI section ### Form= GUICreate(@ScriptName&" - Object Detection with AutoIt!", 625, 506) GUISetFont(14, 400, 0, "Calibri") Local $Button1 = GUICtrlCreateButton("browse", 472, 8, 145, 33) Local $Input1 = GUICtrlCreateInput(@ScriptDir & "\scooter-5180947_1920.jpg", 8, 8, 457, 31) Local $Button2 = GUICtrlCreateButton("detect objects!", 228, 448, 169, 49) Local $Pic1 = GUICtrlCreatePic("", 8, 48, $iPicW, $iPicH, $SS_BITMAP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $hImage = _LoadImage($Input1, $Pic1, 0, $iPicW,$iPicH) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetData($Input1, FileOpenDialog("Please select image", @ScriptDir, "All (*.*)")) $hImage = _LoadImage($Input1, $Pic1, $hImage, $iPicW,$iPicH) Case $Button2 GUICtrlSetState($Button2, $GUI_DISABLE) GUICtrlSetData($Button2, "working..") Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage, 0x00000000) Local $aRes = _AutoYolo3_GetObjInHBitmap($hHBITMAP) ;_ArrayDisplay($aRes) If @error Then Local $iErr = @error Local $asDllErrors[6] = ["No error", "unable to use the DLL file", "unknown ""return type""", """function"" not found in the DLL file", "bad number of parameters", "bad parameter"] If $iErr < 6 Then MsgBox(32, @ScriptName, "DLL Error, " & $asDllErrors[$iErr]) Else MsgBox(32, @ScriptName, "DLL Error, " & _AutoYolo3_GetLastError()) EndIf ElseIf _AutoYolo3_GetLastError() <> "" Then MsgBox(32, @ScriptName, _AutoYolo3_GetLastError()) Else ;nice thick green boxes Local $hPen = _GDIPlus_PenCreate(0xFF00FF00, 2, 2) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Calibri") Local $hFont = _GDIPlus_FontCreate($hFamily, 12, 0) Local $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20) Local $hBrushBack = _GDIPlus_BrushCreateSolid(0x7FFFFFFF) ;color format AARRGGBB (hex) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) For $i = 1 To $aRes[0][0] ; Draw a frame around the object _GDIPlus_GraphicsDrawRect($hGraphics, $aRes[$i][2], $aRes[$i][3] , ($aRes[$i][4] - $aRes[$i][2]) , ($aRes[$i][5] - $aRes[$i][3]) , $hPen) ; Label it $sLabel = $aRes[$i][0] & " " & StringLeft($aRes[$i][1], 6) $tLayout = _GDIPlus_RectFCreate($aRes[$i][2] , $aRes[$i][3] , 200, 20) $iBackLen = 0 If (StringLen($sLabel) * 8) > $iBackLen Then $iBackLen = StringLen($sLabel) * 8 EndIf _GDIPlus_GraphicsFillRect($hGraphics, $aRes[$i][2] , $aRes[$i][3], $iBackLen, 20, $hBrushBack) _GDIPlus_GraphicsDrawStringEx($hGraphics, $sLabel, $hFont, $tLayout, $hFormat, $hBrush) Next $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage, 0x00000000) GUICtrlSendMsg($Pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP) _GDIPlus_PenDispose($hPen) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrushBack) _GDIPlus_GraphicsDispose($hGraphics) EndIf GUICtrlSetData($Button2, "detect objects!") GUICtrlSetState($Button2, $GUI_ENABLE) EndSwitch WEnd If $hImage <> 0 Then _GDIPlus_ImageDispose($hImage) EndIf _GDIPlus_Shutdown() EndFunc ;==>_GUIExample1 Func _LoadImage($Input1, $Pic1, $hImage, $iPicW, $iPicH) If $hImage <> 0 Then _GDIPlus_ImageDispose($hImage) EndIf Local $sImagePath = GUICtrlRead($Input1) $hImage = _GDIPlus_ImageLoadFromFile($sImagePath) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) Local $sFactor = 1 If $iWidth > $iPicW Then $sFactor = $iPicW / $iWidth EndIf If $iHeight > $iPicH And ($iHeight * $sFactor) > $iPicH Then $sFactor = $iPicH / $iHeight EndIf $iHeight = $iHeight * $sFactor $iWidth = $iWidth * $sFactor $hResizedImage = _GDIPlus_ImageResize($hImage, $iWidth, $iHeight) _GDIPlus_BitmapDispose($hImage) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResizedImage, 0x00000000) GUICtrlSendMsg($Pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP) Return $hResizedImage EndFunc ;==>_LoadImage Requirements: Windows x64, AutoIt x64 Microsoft Visual C++ 2015-2019 Redistributable (x64) - https://aka.ms/vs/16/release/vc_redist.x64.exe OpenCV binaries - https://sourceforge.net/projects/opencvlibrary/files/4.3.0/opencv-4.3.0-vc14_vc15.exe/download Quickstart: Ensure you are running Windows x64, AutoIt x64 Install Microsoft Visual C++ 2015-2019 Redistributable (x64) if not already installed - https://aka.ms/vs/16/release/vc_redist.x64.exe Create your project directory anywhere, for this example we use C:\projectdir\ Download OpenCV - https://sourceforge.net/projects/opencvlibrary/files/4.3.0/opencv-4.3.0-vc14_vc15.exe/download Unpack OpenCV anywhere and copy opencv_videoio_ffmpeg430_64.dll, opencv_world430.dll to C:\projectdir\ Download trained weights, classes, config files Weights file: Save as C:\projectdir\yolo\yolov3.weights - https://pjreddie.com/media/files/yolov3.weights Classes file: Save as C:\projectdir\yolo\yolov3.txt - https://github.com/pjreddie/darknet/blob/master/data/coco.names https://raw.githubusercontent.com/zishor/yolo-python-rtsp/master/cfg/yolov3.txt NEW Config file: Save as C:\projectdir\yolo\yolov3.cfg - https://github.com/pjreddie/darknet/blob/master/cfg/yolov3.cfg https://raw.githubusercontent.com/zishor/yolo-python-rtsp/master/cfg/yolov3.cfg NEW Unpack autoyolo1.1.zip from downloads below to your project dir So your project directory should look like: C:\projectdir\ │ autoyolo.dll │ AutoYOLO3.au3 │ basic_example.au3 │ gui_example.au3 │ opencv_videoio_ffmpeg430_64.dll │ opencv_world430.dll │ people-2557408_1920.jpg │ scooter-5180947_1920.jpg │ └───yolo yolov3.cfg yolov3.txt yolov3.weights You are done! Try running one of the examples! Download: LAST UPDATED: 06-JUN-2020 autoyolo1.1.zip 785 KB Credits: YOLOv3: An Incremental Improvement - Joseph Redmon, Ali Farhad https://pjreddie.com/yolo/ https://www.learnopencv.com/deep-learning-based-object-detection-using-yolov3-with-opencv-python-c/ zishor for alternative config and classes (https://github.com/zishor/yolo-python-rtsp) MIT License FAQ: I get error "Cannot use dll" Ensure that you are running script as x64, that you have Microsoft Visual C++ 2015-2019 Redistributable (x64) installed, and that the following files are in the @ScriptDir: autoyolo.dll, opencv_videoio_ffmpeg430_64.dll, opencv_world430.dll I get a crash when clicking detect Try using the NEW config and classes links above All feedback is welcome -smartee1 point
-
Autoit sometimes freezes when polling StdOutRead
argumentum reacted to Dan_555 for a topic
I'v made few tests with the code. The code from the first post is freezing somewhere in between 45 and 200 rounds. I'v tested the example code from TheXman, and i stopped it after around 700 rounds, because it did not freezed. (i changed the for loop into a while loop ) Then i took the code from the 1st post and experimented a bit with it. As you can see, i tried few things: (some things are in other posts too) #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("CMD", 500, 400, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME), BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) Global $g_idMemo = GUICtrlCreateEdit("", 0, 31, 499, 349) GUISetState(@SW_SHOW) Local $i=0,$j=0, $k=0 While True $k=0 $j=$j+1 $pid = Run('tasklist.exe', @ScriptDir, @SW_HIDE, $STDOUT_CHILD) sleep (200) $sOutput = "" ;If ProcessExists($pid) Then $i=$i+1 WinSetTitle ($hGUI,"",$i & "/" & $j & "/" & $pid) Do $k=$k+1 $sOutput &= StdoutRead($pid) ; collect new output if $k>540000 then ConsoleWrite ("emergency exit" & @CRLF) ExitLoop EndIf Until @error ; EOF reached ;StdioClose($pid) ; ... you can leave them out ;ProcessWaitClose($pid) ; These two don't make a difference... MemoWrite("",1) MemoWrite($sOutput) ;EndIf Sleep(50) WEnd Func MemoWrite($sMessage = "", $clr = 0) Local $CRLF = "" If $clr = 1 Then GUICtrlSetData($g_idMemo, "") Else $CRLF = @CRLF EndIf GUICtrlSetData($g_idMemo, $sMessage & $CRLF, 0) EndFunc ;==>MemoWrite P.S. i'v added a gui and an edit field, where the output is written. This code is running, at the moment of writing, with 1500 loops without freezing. The important part here is the Sleep (200) just after the Run('tasklist.exe") line (edit #5: i'v just tried out to increase the sleep(50) and the freezing have started (not using the sleep (200) line), so it is not up to this) If you lower it, the freezing may start happening - the lower the number - the sooner the freezes. The emergency exit has not been reached in the normal run, but only with the lowered sleep amount. If a freeze (and it is not the script which is freezing, just the capturing of the output with the StdOutRead) and this, @DanP2, has allready mentioned: All consecutive run calls will fail to capture the output. Why is this happening - IDK, maybe a bug, but the question is, is it a bug in autoIt or an windows bug ... (currently the loop has reached 4200 (after few edits) as it is running in the background). Maybe someone wants to open a ticket in the bugtracker, so that the developers may look into it (if it is a bug at all) ?1 point -
I have an AutoIT GUI with an input box. I want to run a check on the input every time the value changes. For example: $myvalue = "hello" $value = GUICtrlCreateInput("",150,75,190,20) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case ???????? If GuiCtrlRead($value) == $myvalue Then ; Enable next field. Else ; Disable next field. EndIf EndSwitch WEnd So any time a key is pressed in that input box the if statement gets executed. I don't know what I should put where I've put the ???? at. Thank you!1 point
-
lemony It`s no heavy #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test GUI", 300, 200) $hListView = GUICtrlCreateListView("Items|SubItems", 10, 10, 280, 180, $LVS_REPORT, $WS_EX_CLIENTEDGE) For $i = 1 To 10 _GUICtrlListView_AddItem($hListView, "Item " & $i) _GUICtrlListView_AddSubItem($hListView, $i - 1, "SubItem " & $i, 1) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $IdFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $IdFrom = DllStructGetData($tNMHDR, "IdFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $IdFrom Case $hListView Switch $iCode Case $LVN_ITEMCHANGING Return 1 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY1 point