Leaderboard
Popular Content
Showing content with the highest reputation on 12/30/2024 in all areas
-
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
-
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_PathDispose2 points
-
RustDesk UDF
SOLVE-SMART reacted to BinaryBrother for a topic
Here it is. ; #CURRENT# ===================================================================================================================== ; _RustDesk_Config ; _RustDesk_DebugEnable ; _RustDesk_Deploy ; _RustDesk_GenerateRandomPassword ; _RustDesk_GetID ; _RustDesk_GetLatestVersion ; _RustDesk_GetLocalVersion ; _TustDesk_isInstalled ; _RustDesk_SetPassword ; _RustDesk_Start ; =============================================================================================================================== Update: 1/10/25 - Added _RustDesk_Config() for those who need to configure a custom relay. Update: 1/23/25 - Overhauled some portions of the code with redundancy and timers. Update: 1/26/25 - Inched closer to UDF-Spec and added Constants. Update: 1/27/25 - Finished UDF-Spec Update: 2/4/2025 - Disregard nightly builds for the download. Current.zip1 point -
Checking the return value from a GUICreate|GUIDelete function
argumentum reacted to mr-es335 for a topic
Will do....script updated!! Thanks!1 point -
Checking the return value from a GUICreate|GUIDelete function
mr-es335 reacted to argumentum for a topic
..me, me, me !. But I don't have "[CLASS:SAWSTUDIO_MAIN]". Would you be so kind as to make it work with notepad or calculator or something anyone could run in their own PC without your programs installed ?1 point -
How to set a variable with a quoted ip address from the input field?
argumentum reacted to ioa747 for a topic
TCPConnect ( IPAddr, port ) I think it's more likely that the problem is in the parameter port because the parameters come from $CmdLine and they are converted to text therefore, it needs to be converted to an integer during the call TCPConnect($CmdLine[9], int($CmdLine[10]) )1 point -
How to set a variable with a quoted ip address from the input field?
ioa747 reacted to argumentum for a topic
If you need a type from something like a command line, then you'd have to do that yourself, like $remoteserver = tcpconnect(String("192.168.1.1"), Int("23")) $remoteserver = TCPConnect(String($v101), 23)1 point -
Checking the return value from a GUICreate|GUIDelete function
argumentum reacted to mr-es335 for a topic
Good day, Well...I do believe that - with the assistance of pixelsearch and argumentum...with gratitude...I might say, I have finally completed my project...at least this portion of a much larger work. What this script does: 1) Presents a UI with three buttons, Launch App, Go to Form2, and Exit Me. 2) Launch App: Launches a test application. 3) Go to Form2: Launches Form2 • The "Go to Form2" button from Form1 is disabled. • Form2 display a border-less UI with only the text "Enable Exit" displayed. • Selecting the text "toggles" the text to display "Exit" • Selecting "Exit", exits the text test application. • The "Go to Form2" button from Form1 is enabled. 4) Exit Me: Exits the script. Dependencies A test application, which must reside in the script folder. [Click_Me] Let me know what you think... ; ----------------------------------------------- ; With the assistance of pixelsearch and argumentum...with gratitude! ; Date: 12/30/24 ; ----------------- ; Filename: Update6c ; For testing with MyApp ; ----------------------------------------------- #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) ; ---------------------------------------------- Global $iW = 170, $iH = 100 Global $MainGui2 Global $sColRow ; ----------------------------------------------- _MainGui1() ; ----------------------------------------------- Func _MainGui1() GUICreate("_MainGui1", $iW, $iH, 875, -1) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sCol1Row1 = GUICtrlCreateButton("Launch App", 10, 10, $iW - 20, 25) Local $sCol1Row2 = GUICtrlCreateButton("Go to Form2", 10, 40, $iW - 20, 25) Local $sCol1Row3 = GUICtrlCreateButton("Exit Me", 10, 70, $iW - 20, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $sCol1Row3, $GUI_EVENT_CLOSE _ExitMe() Case $sCol1Row1 _LaunchMyApp() Case $sCol1Row2 GUICtrlSetState($sCol1Row2, $GUI_DISABLE) _MainGui2() GUICtrlSetState($sCol1Row2, $GUI_ENABLE) EndSwitch WEnd EndFunc ;==>_MainGui1 ; ----------------------------------------------- Func _MainGui2() $MainGui2 = GUICreate("", 100, 25, 910, 400, $WS_POPUP, $WS_EX_TOPMOST) GUISetFont(14, 800, 0, "Calibri") GUISetBkColor(0x505050) ; ----------------------------------------------- $sColRow = GUICtrlCreateLabel("Enable Exit", 1, 1, 100, 20, $SS_CENTER) GUICtrlSetColor(-1, 0xFFFFFF) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $sColRow Local $bButtonStatus = _EnableTextToggle() If $bButtonStatus = True Then ExitLoop EndSwitch WEnd EndFunc ;==>_MainGui2 ; ----------------------------------------------- Func _EnableTextToggle() Local Static $hbToggleEnabled = True ; ----------------------------------------------- If $hbToggleEnabled = True Then GUICtrlSetData($sColRow, "Exit") $hbToggleEnabled = False Else GUICtrlSetData($sColRow, "") GUIDelete($MainGui2) _ExitMyApp() $hbToggleEnabled = True EndIf Return $hbToggleEnabled EndFunc ;==>_EnableTextToggle ; ----------------------------------------------- Func _ExitMe() GUIDelete() Exit EndFunc ;==>_ExitMe ; ----------------------------------------------- Func _LaunchMyApp() Local $sSrcAppPath = @ScriptDir & "\_MyApp.exe" ; ----------------------------------------------- Run($sSrcAppPath) ; ----------------------------------------------- Sleep(20) ; ----------------- WinMove(" MyApp", "", 875, 325, 176, 130) EndFunc ;==>_LaunchMyApp ; ----------------------------------------------- Func _ExitMyApp() Local $sAppTitle = " MyApp" ; ----------------------------------------------- WinClose($sAppTitle) EndFunc ;==>_ExitMyApp ; ----------------------------------------------- Thanks again to pixelsearch for his assistance with the "_EnableTextToggle" section, and argumentum for his assistance with the "2 Forms" functionality!1 point -
Problems when returning DllStructGetPtr from function
pixelsearch reacted to emcodem for a topic
Fantastic explaination, thank you so much @pixelsearch Also thanks a lot for the linked topic, it contains very helpful informations for me!1 point -
Could Someone Give me Advice with Automating a Dynamic Web Form in AutoIt?
SOLVE-SMART reacted to ioa747 for a topic
the two main ones suitable for this job are UI Automation UDFs WebDriver UDF both are difficult for a beginner, but worth the effort because they are basic elements (especially for the Internet) Here @SOLVE-SMART has made a nice quick entry point for getting started with WebDriver UDF. here's another way to wait Local $iTimeout = 10000 ; Set timeout 10 seconds Local $iStartTime = TimerInit() Local $oNewElement = "" ; Wait for the new elements max 10 seconds While Not IsObj($oNewElement) Sleep(100) $oNewElement = _IEGetObjById($oIE, "newElementId") ; Check if timeout If TimerDiff($iStartTime) > $iTimeout Then MsgBox(48, @ScriptName & " (" & @ScriptLineNumber & ")", "The new element did not found") Exit ; Exit? ExitLoop ? handle as needed EndIf WEnd to forum1 point -
problem that repeats the same name when saving in txt
angel83 reacted to pixelsearch for a topic
This should do it for 3 columns. Now it will be easy for you to add a 4th, 5th colum etc... Good luck #include <GuiConstantsEx.au3> #include <GuiListView.au3> $hGUI = GUICreate("Test", 800, 600) $hListView = GUICtrlCreateListView("#|Program name|Program path", 10, 10, 780, 100) _GuiCtrlListView_SetColumnWidth($hListView,0,35) _GuiCtrlListView_SetColumnWidth($hListView,1,300) _GuiCtrlListView_SetColumnWidth($hListView,2,420) $OkButton = GUICtrlCreateButton("Ok", 50, 170, 75, 23) $AddButton = GUICtrlCreateButton("Add new file", 130, 170, 75, 23) $RemButton = GUICtrlCreateButton("Remove", 210, 170, 75, 23) GUISetState(@SW_SHOW, $hGUI) _FillList(@ScriptDir & "\test.ini") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $OkButton $sData = "" For $i = 0 To _GUICtrlListView_GetItemCount($hListView) - 1 $sData &= _GUICtrlListView_GetItemText($hListView, $i, 1) & "|" & _ _GUICtrlListView_GetItemText($hListView, $i, 2) & @CRLF ; note the "|" delimiter Next $hFile = FileOpen(@ScriptDir & "\test.ini", 2) ; 2 = overwrite FileWrite($hFile, $sData) FileClose($hFile) Exit Case $AddButton $sFile = FileSaveDialog(@SCRIPTNAME,@WORKINGDIR,"(*.exe)") $iPosBackSlash = StringInStr($sFile, "\", 2, -1) ; -1 search from the right the last backslash $sPath = StringLeft($sFile, $iPosBackSlash - 1) $sFile = StringMid($sFile, $iPosBackSlash + 1) $iIndex = _SearchTextFullMatch($hListView, 1, $sFile) ; 1 = column of 1st subitem If $iIndex = -1 Then ; not found GUICtrlCreateListViewItem(_GUICtrlListView_GetItemCount($hListView) + 1 & "|" & $sFile & "|" & $sPath, $hListView) Else ; found _GUICtrlListView_EnsureVisible($hListView, $iIndex) MsgBox(0, $sFile, "already exists") EndIf Case $RemButton _GUICtrlListView_DeleteItemsSelected($hListView) EndSwitch WEnd Func _FillList($sFile) Local $sRead = FileRead($sFile) Local $aString = StringSplit($sRead, @CRLF, 1) ; 1 = entire delimiter string is needed to mark the split For $i = 1 To $aString[0] If $aString[$i] = "" Then ContinueLoop GUICtrlCreateListViewItem($i & "|" & $aString[$i], $hListView) Next EndFunc Func _SearchTextFullMatch($hListView, $iCol, $sText) Local $iItemsCount = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $iItemsCount - 1 If $sText = _GUICtrlListView_GetItemText($hListView, $i, $iCol) Then Return $i ; found Next Return -1 ; not found EndFunc1 point -
Here is a collection of small examples. Windows Explorer should be open before you run the examples. If you create shortcuts for the scripts, and copy the shortcuts to the desktop, you can run the examples and use Windows Explorer at the same time. For some of the examples you can select files or folders before you run the example. 1) GetCurrentFolder.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get current folder Local $pFolder = GetCurrentFolder(), $sFolder SHGetPathFromIDList( $pFolder, $sFolder ) MsgBox( 0, "Folder", $sFolder ) ; Free memory _WinAPI_CoTaskMemFree( $pFolder ) EndFunc 2) SetCurrentFolder.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Set current folder to desktop Local $pDesktop = _WinAPI_ShellGetSpecialFolderLocation( $CSIDL_DESKTOP ) SetCurrentFolder( $pDesktop, $SBSP_ABSOLUTE ) ; Free memory _WinAPI_CoTaskMemFree( $pDesktop ) EndFunc 3) CountItems.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Count files and folders MsgBox( 0, "Count files and folders", CountItems() ) ; Count selected files and folders MsgBox( 0, "Count selected files and folders", CountItems( True ) ) EndFunc 4) GetFiles.au3 #include "Includes\AutomatingWindowsExplorer.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get all files with full path ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aFiles = GetFiles( False, True ) _ArrayDisplay( $aFiles, "All files" ) ; Get selected files with full path ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) $aFiles = GetFiles( True, True ) _ArrayDisplay( $aFiles, "Selected files" ) EndFunc 5) GetFolders.au3 #include "Includes\AutomatingWindowsExplorer.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get all folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aFolders = GetFolders() _ArrayDisplay( $aFolders, "All folders" ) ; Get selected folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) $aFolders = GetFolders( True ) _ArrayDisplay( $aFolders, "Selected folders" ) EndFunc 6) SetSelectedItem.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Set second item selected SetSelectedItem( 1 ) EndFunc 7) GetSetIconView.au3 #include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get current icon view Local $view = GetIconView() Local $iView, $iSize If IsArray( $view ) Then ; OS > XP $iView = $view[0] ; Icon view $iSize = $view[1] ; Icon size If $iView <> $FVM_DETAILS Then ; Not details view SetIconView( $FVM_DETAILS, 16 ) ; Set details view ElseIf $iView <> $FVM_ICON Then ; Not icon view SetIconView( $FVM_ICON, 48 ) ; Set icon view EndIf Sleep( 3000 ) ; Wait 3 seconds SetIconView( $iView, $iSize ) ; Restore old view Else ; OS = XP $iView = $view If $iView <> $FVM_DETAILS Then ; Not details view SetIconView( $FVM_DETAILS ) ; Set details view ElseIf $iView <> $FVM_ICON Then ; Not icon view SetIconView( $FVM_ICON ) ; Set icon view EndIf Sleep( 3000 ) ; Wait 3 seconds SetIconView( $iView ) ; Restore old view EndIf EndFunc Zipfile The zip contains examples and necessary include files. Examples.7z1 point
-
The first if is true which runs disconnect and then the second is is also true running Connect. This is a minimal change to your script to demo that including some debug lines showing what is happening when ran from SciTE. #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $Main, $ConnectBtn, $msg, $State $Main = GUICreate("ButtonTest", 600, 600) $ConnectBtn = GUICtrlCreateButton("Connect", 50, 50, 130, 20) GUISetState()$State = "0" While 1 $msg = GUIGetMsg() If $msg = $ConnectBtn And $State = "0" Then Connect() elseIf $msg = $ConnectBtn And $State = "1" Then Disconnect() EndIf If $msg = $GUI_EVENT_CLOSE Then Exit WEndFunc Connect() GUICtrlSetData($ConnectBtn, "Disconnect") GUICtrlSetBkColor($ConnectBtn, 0xFF0000) ; red $State = "1" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $State = ' & $State & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console EndFunc ;==>Connect Func Disconnect() GUICtrlSetData($ConnectBtn, "Connect") GUICtrlSetBkColor($ConnectBtn, 0x00FF00) ; green $State = "0" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $State = ' & $State & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console EndFunc ;==>Disconnect1 point