Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/29/2024 in all areas

  1. 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.zip
    5 points
  2. 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_PathDispose
    4 points
  3. There ; ----------------------------------------------- #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ; ----------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _Form1() ; ----------------------------------------------- Func _Form1() Local $vVal, $iW = 270, $iH = 100 ConsoleWrite("Inside _Form1()" & @CRLF) GUICreate("_Form1", $iW, $iH) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sCol1Row1 = GUICtrlCreateButton("Go to Form2", 10, 10, $iW - 20, 25) Local $sCol1Row2 = GUICtrlCreateButton("Exit Me", 10, 40, $iW - 20, 25) Local $sCol1Row3 = GUICtrlCreateLabel("The time returned by Form2", 10, 70, $iW - 20, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 ; ----------------- Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $sCol1Row2 _ExitMe() Case $sCol1Row1 GUISetState(@SW_HIDE) $vVal = _Form2($iW, $iH) If @error Then ConsoleWrite("@@ Debug (" & @ScriptLineNumber & " : OMG, it failed !" & @CRLF) Else ConsoleWrite("@@ Debug (" & @ScriptLineNumber & ") : all good: " & $vVal & @CRLF) EndIf GUICtrlSetData($sCol1Row3, $vVal) GUISetState(@SW_SHOW) EndSwitch WEnd EndFunc ;==>_Form1 ; ----------------------------------------------- Func _Form2($iW, $iH) ConsoleWrite("Inside _Form2()" & @CRLF) Local $MainGui2 = GUICreate("_Form2", $iW, $iH) ; GUICreate() returns 0 if the window cannot be created and sets the @error flag to 1. If @error Or Not $MainGui2 Then Return SetError(1, 0, "") ; ..so we check for any and all, just to make sure. GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sColRow = GUICtrlCreateButton("Return to Form1", 10, 10, $iW - 20, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 ; ----------------- Switch GUIGetMsg() Case $sColRow, $GUI_EVENT_CLOSE GUIDelete($MainGui2) ConsoleWrite("Returning to Form1" & @CRLF) Return "Time in Form2 was: " & @MIN & ':' & @SEC & '.' & @MSEC ; return something back EndSwitch WEnd EndFunc ;==>_Form2 ; ----------------------------------------------- Func _ExitMe() ConsoleWrite("Inside _ExitMe()" & @CRLF) GUIDelete() ; last GUI in the stack of GUIs Exit EndFunc ;==>_ExitMe ; ----------------------------------------------- PS: those lines with "@@ Debug", you can double-click on the console to jump to the line that is at.
    1 point
  4. That is indeed a glitch in AutoitAutoComplete.lua. Try changing line 52 to add a test which pane has the focus to: function AutoItAutoComplete:OnKey(code, shift, control, alt) if editor.Lexer ~= SCLEX_AU3 or props['FileNameExt'] == '' or not editor.Focus then
    1 point
  5. @Nine thanks for the test on a Label control. My goal was to get rid of $WM_MOUSEMOVE but apparently it can't be easily done... and maybe it's a good thing, let's see why. I just tested with a few other controls, like Input, List etc... and each one reacts differently. To test them, I started to modify 1 line in the script (without modifying the variable name or we'll never end) ; Local $idBtn = GUICtrlCreateButton("", 0, 0, 52, 51, $BS_BITMAP) ; Local $idBtn = GUICtrlCreateInput("", 0, 0, 52, 51) ; Local $idBtn = GUICtrlCreateList("", 0, 0, 52, 51) Local $idBtn = GUICtrlCreateLabel("", 0, 0, 52, 51) etc... and with this subclass function : Func _BtnProc($hWnd, $iMsg, $wParam, $lParam, $IdSubclass, $dwRefData) Local Static $bHover, $iCounter = 0, $sClassName = _WinAPI_GetClassName($g_hBtn) Switch $iMsg Case $WM_MOUSEMOVE _WinAPI_TrackMouseEvent($g_hBtn, $TME_HOVER + $TME_LEAVE, 10) ; 10ms Case $WM_MOUSEHOVER ; not 100% satisfying If Not $bHover Then If $sClassName = "Button" Then GUICtrlSetImage($dwRefData, @ScriptDir & "\OK 52-51.bmp") $iCounter += 1 ConsoleWrite("$WM_MOUSEHOVER : $iCounter = " & $iCounter & @crlf) $bHover = True EndIf Case $WM_MOUSELEAVE If $sClassName = "Button" Then GUICtrlSetImage($dwRefData, @ScriptDir & "\Cancel 52-51.bmp") $iCounter += 1 ConsoleWrite("$WM_MOUSELEAVE : $iCounter = " & $iCounter & @crlf) $bHover = False EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_BtnProc But results are not 100% satisfying because, as you indicated in this post, the 10ms wait parameter can create issues, like those displayed below in the Console, when you move quickly the mouse inside and outside the control, then several "MouseLeave" may be displayed instead of 1 only (this is a real Console display below) $WM_MOUSEHOVER : $iCounter = 1 $WM_MOUSELEAVE : $iCounter = 2 $WM_MOUSEHOVER : $iCounter = 3 $WM_MOUSELEAVE : $iCounter = 4 $WM_MOUSEHOVER : $iCounter = 5 $WM_MOUSELEAVE : $iCounter = 6 $WM_MOUSELEAVE : $iCounter = 7 <=== bad $WM_MOUSEHOVER : $iCounter = 8 $WM_MOUSELEAVE : $iCounter = 9 Changing 10ms to 1ms won't change anything and also changing it to 0ms will use the hovering system default (which is about 400ms I guess, not sure though) So my conclusion is to start scripting it as you initially did (e.g. without using $WM_MOUSEHOVER at all) but we need to add a call to _WinAPI_TrackMouseEvent(...$TME_LEAVE) in case the subclassed control requires it (your test with a Label control, mine with a List control which requires it too) . This is the resulting function : Func _BtnProc($hWnd, $iMsg, $wParam, $lParam, $IdSubclass, $dwRefData) Local Static $bHover, $iCounter = 0, $sClassName = _WinAPI_GetClassName($g_hBtn) Switch $iMsg Case $WM_MOUSEMOVE If Not $bHover Then If $sClassName = "Button" Then GUICtrlSetImage($dwRefData, @ScriptDir & "\OK 52-51.bmp") $iCounter += 1 ConsoleWrite("$WM_MOUSEMOVE : $iCounter = " & $iCounter & @crlf) $bHover = True EndIf _WinAPI_TrackMouseEvent($g_hBtn, $TME_LEAVE) Case $WM_MOUSELEAVE If $sClassName = "Button" Then GUICtrlSetImage($dwRefData, @ScriptDir & "\Cancel 52-51.bmp") $iCounter += 1 ConsoleWrite("$WM_MOUSELEAVE : $iCounter = " & $iCounter & @crlf) $bHover = False EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_BtnProc With this reworked function, we'll never find several followed "MouseLeave" in Console (tested) but only 1, preceded and followed by 1 "MouseMove", even if we move quickly the mouse inside/outside the control, and this, no matter the subclassed control is a Button, Label, Input, List control etc... I wonder if I should post a reworked script including these last modifications, but with this imaged button code, maybe it won't be clear. Anyway you got the idea. Hope it helps
    1 point
  6. If the help file is God then the Wiki is the Goddess of AutoIt. The Tutorials you find there explain step by step how to do a specific task. Example: Managing multiple GUIs
    1 point
  7. That is a mystery for me also. And that is even more strange because on some other controls like label, you need to track the LEAVE !
    1 point
  8. ; ----------------------------------------------- #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ; ----------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _Form1() ; ----------------------------------------------- Func _Form1() Local $iW = 270, $iH = 100 ConsoleWrite("Inside _Form1()" & @CRLF) GUICreate("_Form1", $iW, $iH) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sCol1Row1 = GUICtrlCreateButton("Go to Form2", 10, 10, $iW - 20, 25) Local $sCol1Row2 = GUICtrlCreateButton("Exit Me", 10, 40, $iW - 20, 25) Local $sCol1Row3 = GUICtrlCreateLabel("The time returned by Form2", 10, 70, $iW - 20, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 ; ----------------- Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $sCol1Row2 _ExitMe() Case $sCol1Row1 GUISetState(@SW_HIDE) GUICtrlSetData($sCol1Row3, _Form2($iW, $iH)) GUISetState(@SW_SHOW) EndSwitch WEnd EndFunc ;==>_Form1 ; ----------------------------------------------- Func _Form2($iW, $iH) ConsoleWrite("Inside _Form2()" & @CRLF) Local $MainGui2 = GUICreate("_Form2", $iW, $iH) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sColRow = GUICtrlCreateButton("Return to Form1", 10, 10, $iW - 20, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 ; ----------------- Switch GUIGetMsg() Case $sColRow, $GUI_EVENT_CLOSE GUIDelete($MainGui2) ConsoleWrite("Returning to Form1" & @CRLF) Return "Time in Form2 was: " & @MIN & ':' & @SEC & '.' & @MSEC; return something back EndSwitch WEnd EndFunc ;==>_Form2 ; ----------------------------------------------- Func _ExitMe() ConsoleWrite("Inside _ExitMe()" & @CRLF) GUIDelete() ; last GUI in the stack of GUIs Exit EndFunc ;==>_ExitMe ; ----------------------------------------------- ..changed my prior example to return something back to the 1st GUI. ..anything can make sense. The question is: does it do what you need. And if it does, then you've got it. I would not spend much time in correctness. If it does what you need then is good. If you later learn a thing or two, apply your new coding style to the new projects. My code can be viewed as sucky, ..I don't mind. As long as it works, it worked. If you later, much later, become a perfectionist, good for you. You have the experience. But for now, if am not shown a working app, I have no clue of what is the goal of the app and how a user of the app would make sense of the GUI design. Get the concept working, Then you can worry about coding styles. Otherwise, I doubt anyone can correct the code. Again, is not personal. The code can be bad or good. It has nothing to do with you being good or bad. Detaching from the fruit of your labor is important. Very important. Am sure that the Buddha started as a coder, then one day..., he became illuminated Edit: changed the code a bit to pass parameters back and forth.
    1 point
  9. That seems to work fine : #include <Constants.au3> Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.load("Event.xml") If $oXML.parseError.errorCode Then Exit MsgBox($MB_SYSTEMMODAL, "You have an error", $oXML.parseError.reason) Local $oNode = $oXML.SelectNodes("//ComplexData") $oNode.removeAll() $oXML.save("New Event.xml")
    1 point
  10. ; ----------------------------------------------- #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ; ----------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _Form1() ; ----------------------------------------------- Func _Form1() ConsoleWrite("Inside _Form1()" & @CRLF) Local $MainGui1 = GUICreate("_Form1", 170, 75) #forceref $MainGui1 ; because $MainGui1 is not used, ..if you are going to use it. GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sCol1Row1 = GUICtrlCreateButton("Go to Form2", 10, 10, 150, 25) Local $sCol1Row2 = GUICtrlCreateButton("Exit Me", 10, 40, 150, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 ; ----------------- Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $sCol1Row2 _ExitMe() Case $sCol1Row1 ;~ GUIDelete($MainGui1) ; shouldn't delete itself GUISetState(@SW_HIDE) _Form2() GUISetState(@SW_SHOW) EndSwitch WEnd EndFunc ;==>_Form1 ; ----------------------------------------------- Func _Form2() ConsoleWrite("Inside _Form2()" & @CRLF) Local $MainGui2 = GUICreate("_Form2", 170, 75) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sColRow = GUICtrlCreateButton("Return to Form1", 10, 10, 150, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 ; ----------------- Switch GUIGetMsg() ;~ Case $GUI_EVENT_CLOSE ;~ Exit ; should go back ? Case $sColRow, $GUI_EVENT_CLOSE GUIDelete($MainGui2) ConsoleWrite("Returning to Form1" & @CRLF) ;~ _Form1() ; because is hidden Return ; to previous GUI EndSwitch WEnd EndFunc ;==>_Form2 ; ----------------------------------------------- Func _ExitMe() ConsoleWrite("Inside _ExitMe()" & @CRLF) GUIDelete() Exit EndFunc ;==>_ExitMe ; -----------------------------------------------
    1 point
  11. argumentum

    World Time for the CLI

    ..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
  12. OK, final note on the subject: I test radio sets and am doing that by driving an analyser under remote control (using AutoIT). There's a range of items (cables/relays/connectors and attenuators) involved and I have measurement results at a range of frequencies for each of these. What I'm trying to achieve is a certificate type document with graphs of those measurements per item. The test results for the radio go happily in one sheet, together with calculations and explanatory graphics. I am trying to use the graphing abilities of Excel (other tools are available) to draw the graphs for the other involved items. OpenOffice4 doesn't carry over the links when copying a range of cells. I use this to my advantage. On my template sheet, I fill the data table with the source data for one item and that updates the graph associated with it. Using _OOoCalc_RangeMoveOrCopy() i then copy the completed graph and table to its place in the report sheet. The links are broken and the data stays with the copy. I can then go back to the template, reset the data and draw the graph for the next item, and copy that to the next free place in the report sheet. And so on until all are done. Then delete the template and save/print to pdf. Works like a charm. Also explains why copying a sheet (as above) didn't work - the graph drawing links are left behind (I'm guessing that it emulates Excel's Copy as Values) Thanks again for your steer Great forum! Regards John G0GCD
    1 point
  13. You could wrap a function around like this : #include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include <FontConstants.au3> Example() Func Example() Local $hGui, $hRichEdit, $iMsg $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1) $hRichEdit = _GUICtrlRichEdit_CreateEx($hGui, "This is a test.", 10, 10, 300, 220, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text") GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes ; GUIDelete() ; is OK too Exit EndSelect WEnd EndFunc ;==>Example Func _GUICtrlRichEdit_CreateEx($hWnd, $sText, $iLeft, $iTop, $iWidth = 150, $iHeight = 150, $iStyle = -1, $iExStyle = -1) Local $hCtrl = _GUICtrlRichEdit_Create($hWnd, $sText, $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle) If @error Then Return SetError(@error) Local $hFont = _WinAPI_CreateFont(20, 0, 0, 0, 600, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial') _SendMessage($hCtrl, $WM_SETFONT, $hFont, True) _WinAPI_DeleteObject($hFont) Return $hCtrl EndFunc Where you would have the definition of the font standardized...
    1 point
  14. I've got that information from ... my imagination, trying to figure out what you may need to have. I figure that you have a main gui that you'd like to get back to. So I hide it, load the other gui and when closed unhide the main gui. I tend to read and chat in code, AutoIt code. Users tend to be very vague in their explanations so code is king. Now you don't read/understand code very much and that limits what I can say. I thought that the code spoke for itself. Other than that, all I can do is ignore your questions given that I cause more problems than solutions for you.
    0 points
×
×
  • Create New...