Jump to content

AutoBert

Active Members
  • Posts

    1,935
  • Joined

  • Last visited

  • Days Won

    9

Reputation Activity

  1. Like
    AutoBert reacted to Nine in Automating restart for MC server   
    Best way is to create a scheduled task (taskschd.msc) to run every day at 6am.
  2. Like
    AutoBert reacted to Nine in Troubleshooting for Infinite Loop Keyboard button presses - (Locked)   
    Please read forum rules, especially the part about game automation
  3. Like
    AutoBert reacted to Nine in UDF : Multi-threading made easy   
    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.au3
  4. Like
    AutoBert reacted to water in Fork UDF (ish)   
    I added this UDF to the wiki
  5. Like
    AutoBert reacted to MattyD in LED Banners (good resolutions for the New Year)   
    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_Led
  6. Like
    AutoBert reacted to Gianni in LED Banners (good resolutions for the New Year)   
    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  
  7. Like
    AutoBert reacted to MattyD in Resizable & Dragable Windows Controls   
    Hi all,
    I've just been playing with window messages that are sent to win32 controls themselves (rather than to the parent GUI), and it looks like you can do some cool stuff. So I thought I'd share some things that I found interesting. And yeah I know the code probably needs a cleanup - but I figure its good enough to get the point across...
    Anyway what I have is: while the "lock" checkbox is selected, the buttons behave normally. Otherwise you can drag them around and/or resize them. Because you're essentially dragging the buttons by their "Caption" bar, double clicking  will also maximise them.
    #include <guiConstants.au3> #include <winapi.au3> Global Const $DLGC_BUTTON = 0x2000 Global Const $DLGC_WANTTAB = 0x0002 Global $hGui = GUICreate("", 300, 200) Global $idBtn = GUICtrlCreateButton("Button 1", 4, 4, 80, 80) Global $idBtn2 = GUICtrlCreateButton("Button 2", 90, 4, 80, 80) Global $idLockButtons = GUICtrlCreateCheckbox("Lock Buttons", 200, 20, 80, 20) Global $hCursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $OCR_CROSS)) Global $hBtnMoveProc = DllCallbackRegister("ButtonMoveProc", "long", "hwnd;uint;wparam;lparam") Global $pBtnMoveProc = DllCallbackGetPtr($hBtnMoveProc) Global $hBtn = GUICtrlGetHandle($idBtn) Global $hBtn2 = GUICtrlGetHandle($idBtn2) Global $pOrigBtnProc = _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, $pBtnMoveProc) _WinAPI_SetWindowLong($hBtn2, $GWL_WNDPROC, $pBtnMoveProc) GUISetState() While 1 Local $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $idLockButtons _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, (GUICtrlRead($iMsg) = $GUI_CHECKED) ? $pOrigBtnProc : $pBtnMoveProc) _WinAPI_SetWindowLong($hBtn2, $GWL_WNDPROC, (GUICtrlRead($iMsg) = $GUI_CHECKED) ? $pOrigBtnProc : $pBtnMoveProc) Case $idBtn, $idBtn2 ConsoleWrite("Click " & GUICtrlRead($iMsg) & @CRLF) EndSwitch WEnd Func ButtonMoveProc($hWnd, $uMsg, $wParam, $lParam) Local $aPos, $iRet, $aPoint[2], $iSrc, $iEvent Local $aRes = DllCallAddress("long", $pOrigBtnProc, "hwnd", $hWnd, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam) Switch $uMsg Case $WM_NCHITTEST $aPos = WinGetPos($hWnd) $aPoint[0] = BitAND($lParam, 0xFFFF) $aPoint[1] = BitShift($lParam, 16) $iRet = $HTCAPTION If $aPoint[0] - $aPos[0] < 10 Then $iRet = $HTLEFT If $aPoint[0] - $aPos[0] > ($aPos[2] - 10) Then $iRet = $HTRIGHT If $aPoint[1] - $aPos[1] < 10 Then Switch $iRet Case $HTLEFT $iRet = $HTTOPLEFT Case $HTRIGHT $iRet = $HTTOPRIGHT Case Else $iRet = $HTTOP EndSwitch ElseIf $aPoint[1] - $aPos[1] > ($aPos[3] - 10) Then Switch $iRet Case $HTLEFT $iRet = $HTBOTTOMLEFT Case $HTRIGHT $iRet = $HTBOTTOMRIGHT Case Else $iRet = $HTBOTTOM EndSwitch EndIf Return $iRet Case $WM_SETCURSOR $iSrc = BitAND($lParam, 0xFFFF) $iEvent = BitShift($lParam, 16) If $iSrc = $HTCAPTION And $iEvent = $WM_LBUTTONDOWN Then _WinAPI_SetCursor($hCursor) Return True EndIf Case Else EndSwitch Return $aRes[0] ;~ Return _WinAPI_DefWindowProcW($hWnd, $uMsg, $wParam, $lParam) EndFunc ;==>ButtonProc  
  8. Like
    AutoBert reacted to ioa747 in Input control with label and rounded corners   
    Input control for the GUI with label and rounded corners
    It all started in this post
    I tried to make a rectangle with rounded corners, using $GUI_GR_BEZIER.
    I managed to do it but the result did not satisfy me because $GUI_GR_BEZIER produced (is producing) a rough result. A flickering, which I could not overcome.

    So I changed the approach with two rectangles and a circle for each corner
    The script demonstrates the use of functions to create input fields with and without labels, and rounded corners,
    where the font size changes dynamically depending on the height of Input control.

    Valid value for Corner    [0=Rectangle]   to   [($Height/2)=Round],   Default=($Height/4)
     


    Example1: _CreateInputWL()
    #include <GUIConstants.au3> _Example() ;---------------------------------------------------------------------------------------- Func _Example() Local $hGUI = GUICreate("Shipping Details", 390, 320) GUISetStyle(-1, $WS_EX_COMPOSITED) GUISetBkColor(0x0D1117) Local $ShippingDetails = GUICtrlCreateLabel("Shipping Address", 10, 5, 380, 30) GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFD800) Local $Exit = GUICtrlCreateButton("EXIT", 20, 270, 95, 40) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0D1117) GUICtrlSetBkColor(-1, 0xFFD800) Local $Corner = -1 ; *** <- Valid value from [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) *** <- Local $FirstName = _CreateInputWL("First Name:", "John", 10, 50, 180, 40, 0x00FFFF, $Corner) Local $LastName = _CreateInputWL("Last Name:", "Doe", 200, 50, 180, 40, 0x00FFFF, $Corner) Local $Address = _CreateInputWL("Address:", "123 Main St", 10, 100, 230, 40, 0x00FFFF, $Corner) Local $Apt = _CreateInputWL("Apt:", "4B", 250, 100, 130, 40, 0x00FFFF, $Corner) Local $City = _CreateInputWL("City:", "Springfield", 10, 150, 140, 40, 0x00FFFF, $Corner) Local $State = _CreateInputWL("State:", "IL", 160, 150, 80, 40, 0x00FFFF, $Corner) Local $ZipCode = _CreateInputWL("Zip Code:", "627 01", 250, 150, 130, 40, 0x00FFFF, $Corner) Local $Email = _CreateInputWL("Email:", "jdoe627@gmail.com", 10, 200, 230, 40, 0x00FFFF, $Corner) Local $Phone = _CreateInputWL("Phone:", "0123456789", 250, 200, 130, 40, 0x00FFFF, $Corner) GUISetState(@SW_SHOW) Sleep(4000) GUICtrlSetData($Email[0], "Johndoe@gmail.com") GUICtrlSetData($Phone[1], "Mobile:") GUICtrlSetData($Phone[0], "654210789") ;********************************** While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Exit ExitLoop EndSwitch WEnd ;********************************** EndFunc ;==>_Example ;---------------------------------------------------------------------------------------- Func _CreateInputWL($Label, $Text, $Left, $Top, $Width, $Height, $Color, $Corner = -1) ; $Corner Valid value [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) ; Validate parameters If $Corner < 0 Or $Corner = Default Then $Corner = $Height / 4 If $Corner > $Height / 2 Then $Corner = $Height / 2 If $Width <= 0 Or $Height <= 0 Then Return SetError(1, 0, 0) EndIf ; graphic GUICtrlCreateGraphic($Left, $Top, $Width, $Height) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Color, $Color) ; body GUICtrlSetGraphic(-1, $GUI_GR_RECT, $Corner, 0, $Width - ($Corner * 2), $Height) ; outer part GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, $Corner, $Width, $Height - ($Corner * 2)) ; inner part ; corners GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $Corner * 2, $Corner * 2) ; Top-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, 0, $Corner * 2, $Corner * 2) ; Top-right GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-right GUICtrlSetState(-1, $GUI_DISABLE) Local $idLabel = GUICtrlCreateLabel($Label, $Left + $Corner, $Top, $Width - ($Corner * 2), $Height * 0.4) GUICtrlSetBkColor($idLabel, $Color) GUICtrlSetFont($idLabel, $Height * 0.25) Local $idInput1 = GUICtrlCreateInput($Text, $Left + $Corner, $Top + ($Height * 0.35), $Width - ($Corner * 2), $Height * 0.60, -1 ,$WS_EX_COMPOSITED) GUICtrlSetFont($idInput1, $Height * 0.35) GUICtrlSetBkColor($idInput1, $Color) Local $aRet[] = [$idInput1, $idLabel] Return $aRet ; Return both ID EndFunc ;==>_CreateInputWL ;----------------------------------------------------------------------------------------  
    Example2: _CreateInputWL(),   _CreateInput()
     
    #include <GUIConstants.au3> Global $hGUI = GUICreate("GUI") GUISetStyle ( -1, $WS_EX_COMPOSITED ) GUISetBkColor(0x0D1117) Global $id_1 = _CreateInput("INPUT1", 20, 20, 150, 30, "0xFFD800", 15) Global $id_2 = _CreateInput("INPUT2", 20, 60, 150, 30, "0xB6FF00") Global $id_3 = _CreateInput("INPUT3", 20, 100, 150, 35, "0x00FFFF", 10) Global $id_4 = _CreateInput("INPUT4", 20, 145, 150, 35, "0x0094FF") Global $id_5 = _CreateInput("INPUT5", 20, 190, 150, 40, "0xFF0000", 10) Global $id_6 = _CreateInput("INPUT6", 20, 240, 150, 40, "0xFF80EE") Global $id_7 = _CreateInputWL("Label:", "INPUT7", 220, 20, 150, 30, "0xFFD800", 10) Global $id_8 = _CreateInputWL("Label:", "INPUT8", 220, 60, 150, 30, "0xB6FF00") Global $id_9 = _CreateInputWL("Label:", "INPUT9", 220, 100, 150, 35, "0x00FFFF", 10) Global $id_10 = _CreateInputWL("Label:", "INPUT10", 220, 145, 150, 35, "0x0094FF") Global $id_11 = _CreateInputWL("Label:", "INPUT11", 220, 190, 150, 40, "0xFF0000", 10) Global $id_12 = _CreateInputWL("Label:", "INPUT12", 220, 240, 150, 40, "0xFF80EE") Global $id_13 = _CreateInputWL("LabelXXL:", "INPUTXXL", 20, 300, 350, 60, "0xB6B6B6", 30) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;---------------------------------------------------------------------------------------- Func _CreateInput($Text, $Left, $Top, $Width, $Height, $Color, $Corner = 10) ; $Corner Valid value [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) ; Validate parameters If $Corner < 0 Or $Corner = Default Then $Corner = $Height / 4 If $Corner > $Height / 2 Then $Corner = $Height / 2 If $Width <= 0 Or $Height <= 0 Then Return SetError(1, 0, 0) EndIf ; graphic GUICtrlCreateGraphic($Left, $Top, $Width, $Height) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Color, $Color) ; body GUICtrlSetGraphic(-1, $GUI_GR_RECT, $Corner, 0, $Width - ($Corner * 2), $Height) ; outer part GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, $Corner, $Width, $Height - ($Corner * 2)) ; inner part ; corners GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $Corner * 2, $Corner * 2) ; Top-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, 0, $Corner * 2, $Corner * 2) ; Top-right GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-right GUICtrlSetState(-1, $GUI_DISABLE) $idInput1 = GUICtrlCreateInput($Text, $Left + $Corner, $Top + ($Height * 0.2), $Width - ($Corner * 2), $Height * 0.6, -1, $WS_EX_COMPOSITED) GUICtrlSetFont($idInput1, $Height * 0.4, 400) GUICtrlSetBkColor($idInput1, $Color) Return $idInput1 EndFunc ;==>_CreateInput ;---------------------------------------------------------------------------------------- Func _CreateInputWL($Label, $Text, $Left, $Top, $Width, $Height, $Color, $Corner = -1) ; $Corner Valid value [0=Rectangle] to [($Height/2)=Round], Default=($Height/4) ; Validate parameters If $Corner < 0 Or $Corner = Default Then $Corner = $Height / 4 If $Corner > $Height / 2 Then $Corner = $Height / 2 If $Width <= 0 Or $Height <= 0 Then Return SetError(1, 0, 0) EndIf ; graphic GUICtrlCreateGraphic($Left, $Top, $Width, $Height) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $Color, $Color) ; body GUICtrlSetGraphic(-1, $GUI_GR_RECT, $Corner, 0, $Width - ($Corner * 2), $Height) ; outer partt GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, $Corner, $Width, $Height - ($Corner * 2)) ; inner part ; corners GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $Corner * 2, $Corner * 2) ; Top-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, 0, $Corner * 2, $Corner * 2) ; Top-right GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-left GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, $Width - $Corner * 2, $Height - $Corner * 2, $Corner * 2, $Corner * 2) ; Bottom-right GUICtrlSetState(-1, $GUI_DISABLE) Local $idLabel = GUICtrlCreateLabel($Label, $Left + $Corner, $Top, $Width - ($Corner * 2), $Height * 0.4) GUICtrlSetBkColor($idLabel, $Color) GUICtrlSetFont($idLabel, $Height * 0.25) Local $idInput1 = GUICtrlCreateInput($Text, $Left + $Corner, $Top + ($Height * 0.35), $Width - ($Corner * 2), $Height * 0.60, -1, $WS_EX_COMPOSITED) GUICtrlSetFont($idInput1, $Height * 0.35) GUICtrlSetBkColor($idInput1, $Color) Local $aRet[]=[$idInput1, $idLabel] Return $aRet ; Return both ID EndFunc ;==>_CreateInputWL ;----------------------------------------------------------------------------------------  
    Please, every comment is appreciated!
    leave your comments and experiences here!
    Thank you very much 
     
  9. Like
    AutoBert got a reaction from argumentum in exit program when i press confirm button   
    1. Your script isn't runable:
    seems that you missed one include that isn't part of the standard autoit.
    2. as @argumentum already posted:
     
     
  10. Like
    AutoBert got a reaction from ioa747 in [SOLVED] Treeview from Directory using "native" functions.   
    This script:
    ;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> Global $sPath = @ScriptDir Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() _CreatePath($sPath, $idTreeView) Do Until GUIGetMsg() = -3 Func _CreatePath($sPath, $idParent) Local $aFolder, $aFiles, $idItem If StringRight($sPath, 1) <> '\' Then $sPath &= '\' $aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS) If Not @error Then For $i = 1 To $aFolder[0] $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) Next EndFunc does same as yours with native GUICtrlCreateTreeViewItem and _FileListToArray.
  11. Like
    AutoBert reacted to ioa747 in Round buttons   
    Method for Colorful Rectangle Buttons
    ; https://www.autoitscript.com/forum/topic/211721-round-buttons/ ;---------------------------------------------------------------------------------------- ; Title...........: RectButtonsSpecial.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> ; ~~~~~~~~~~~~~~~~~ Example - what is ColorLight() Global $test = ColorLight(0xC800C8, 50) ConsoleWrite($test & @CRLF) $test = ColorLight(0xC800C8, 50, 1) ConsoleWrite($test & @CRLF) $test = ColorLight(0xC800C8, 50, 2) ConsoleWrite(StringFormat("RGB(%d,%d,%d)", $test[0], $test[1], $test[2]) & @CRLF & @CRLF) ; ~~~~~~~~~~~~ End of Example - what is ColorLight() Global $MyGui, $aBtn[6][2], $btnColor = 0xC800C8 $MyGui = GUICreate(@ScriptName, 180, 220) GUISetBkColor(0x000000) $aBtn[0][0] = 5 ; cnt of buttons $aBtn[1][0] = GUICtrlCreateLabel("Button1", 10, 20, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[1][1] = 0xA64500 GUICtrlSetBkColor(-1, $aBtn[1][1]) $aBtn[2][0] = GUICtrlCreateLabel("Button2", 10, 60, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[2][1] = 0x826E00 GUICtrlSetBkColor(-1, $aBtn[2][1]) $aBtn[3][0] = GUICtrlCreateLabel("Button3", 10, 100, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[3][1] = 0x268000 GUICtrlSetBkColor(-1, $aBtn[3][1]) $aBtn[4][0] = GUICtrlCreateLabel("Button4", 10, 140, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[4][1] = 0x0094FF GUICtrlSetBkColor(-1, $aBtn[4][1]) $aBtn[5][0] = GUICtrlCreateLabel("Button5", 10, 180, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[5][1] = 0x9600D5 GUICtrlSetBkColor(-1, $aBtn[5][1]) GUISetState(@SW_SHOW) ; 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...........: 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 much 
  12. Thanks
    AutoBert reacted to ioa747 in SmartNote   
    SmartNote UWPOCR Edition:
    For those who don't want to install the tesseract .
    Using only the Windows Optical character recognition API  (at least Windows 10 )
    and the  UWPOCR UDF  ( Thanks to @Danyfirex )
    from:  uwpocr-windows-platform-optical-character-recognition-api-implementation
    otherwise it is a clone of the above

    SmartNote_UWPOCR.au3
    ; https://www.autoitscript.com/forum/topic/208600-smartnote/?do=findComment&comment=1532353 ;---------------------------------------------------------------------------------------- ; Title...........: SmartNote_UWPOCR.au3 ; Description.....: SmartNote is a screen snip tool to take Screenshot with OCR ability from UWPOCR ; AutoIt Version..: 3.3.16.1 Author: ioa747 ;---------------------------------------------------------------------------------------- #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=mmcndmgr-106.ico #AutoIt3Wrapper_Res_Description=SmartNote is a screen snip tool to take Screenshot with OCR ability from UWPOCR #AutoIt3Wrapper_Res_Fileversion=0.0.2.20240331 #AutoIt3Wrapper_Res_ProductName=SmartNote_UWPOCR.au3 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon If WinExists(StringTrimRight(@ScriptName, 4) & "_STUB") Then Exit 5 AutoItWinSetTitle(StringTrimRight(@ScriptName, 4) & "_STUB") If @AutoItX64 Then Exit MsgBox(262144 + 64, StringTrimRight(@ScriptName, 4), "Please run as 32bit", 60) #include <MsgBoxConstants.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> #include <Misc.au3> #include <Array.au3> #include <GDIPlus.au3> #include <Clipboard.au3> #include <String.au3> #include "UWPOCR.au3" ; * < -"https://www.autoitscript.com/forum/topic/207324-uwpocr-windows-platform-optical-character-recognition-api-implementation" ; Initialization DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2 Opt("MouseCoordMode", 1) ; 1=absolute, 0=relative, 2=client Opt("TrayMenuMode", 3) ; 0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Opt("GUIOnEventMode", 1) ; 0=disabled, 1=OnEvent mode enabled ; tray entry to exit script Global $TRAY_ExitScript = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TRAY_EVENT") ; separator TrayCreateItem("") ; tray entry to capture Global $TRAY_NewCapture = TrayCreateItem("Capture") TrayItemSetOnEvent(-1, "TRAY_EVENT") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TRAY_EVENT") TraySetIcon("mmcndmgr.dll", -106) TraySetClick(16) ; $TRAY_CLICK_SECONDARYUP = 16 TraySetState($TRAY_ICONSTATE_SHOW) TraySetToolTip("SmartNote" & @CRLF & "Double Click to take new note") Global $mPos, $aRecPos[4], $hGUICapture, $block_gui Global $hDLL = DllOpen("user32.dll") ; array to hold the Contextmenu data Global $NoteGui[1][18] $NoteGui[0][0] = 0 ; cnt, Note_Handle $NoteGui[0][1] = "jpgPath" $NoteGui[0][2] = "Gui_Size" $NoteGui[0][3] = "ID_PicCtrl" $NoteGui[0][4] = "ID_ContextMenu" $NoteGui[0][5] = "ID_cMenuCopy" $NoteGui[0][6] = "ID_cMenuShareX" $NoteGui[0][7] = "ID_cMenuSave" $NoteGui[0][8] = "ID_cMenuOpen" $NoteGui[0][9] = "ID_FutureUse" $NoteGui[0][10] = "ID_FutureUse" $NoteGui[0][11] = "ID_Lang1" $NoteGui[0][12] = "ID_Lang2" $NoteGui[0][13] = "ID_Lang3" $NoteGui[0][14] = "ID_Lang4" $NoteGui[0][15] = "ID_cMenuClose" $NoteGui[0][16] = "ID_Dummy_DeleteKey" $NoteGui[0][17] = "ID_Dummy_EnterKey" ; Check for leftover files Global $iFileExists = FileExists(@ScriptDir & "\tmp") If $iFileExists Then FileDelete(@ScriptDir & "\tmp\*.*") Else DirCreate(@ScriptDir & "\tmp") EndIf Global $aSupportedLanguages = _UWPOCR_GetSupportedLanguages() Global $iLanguagesCnt = UBound($aSupportedLanguages) - 1 ;~ HotKeySet("{PGUP}", "_Array_Gui_display") ; *** Debug _ArrayDisplay($NoteGui, "$NoteGui") <<- HotKey ; ℹ️ While Left Windows Key IsPressed, tap 2 times the Left SHIFT key to start NewCapture, ; is useful when Capture menu or contex menu. ; While start NewCapture point click anywhere to escape. (does not catch smaller than 9*9 px) ; While start NewCapture escape with ESC Global $iShift ; loop until program exit ;************************************************ While Sleep(100) $iShift = 0 While _IsPressed("5B", $hDLL) ; 5B Left Windows key Sleep(100) If _IsPressed("A0", $hDLL) Then ; A0 Left SHIFT key While _IsPressed("A1", $hDLL) Sleep(100) WEnd $iShift += 1 EndIf If $iShift = 2 Then NewCapture() ExitLoop EndIf WEnd WEnd ;************************************************ ;---------------------------------------------------------------------------------------- Func NewCapture() ; NewCapture Local $aRecPos[4], $aMPos[2], $tPos ;, $aTipPos[4], $iX, $iY Local $iDeskWidth, $iDeskHeight, $iDeskLeft, $iDeskTop Local $sDevice, $hMonitor, $sCurDevice, $aData, $Status = 0 ; make Capture gui $hGUICapture = GUICreate("Capture_gui", 1, 1, 1, 1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor("0xFFFF00", $hGUICapture) ; $COLOR_YELLOW WinSetTrans($hGUICapture, "", 50) ; make mouse block gui $block_gui = GUICreate("block_gui", 1, 1, 1, 1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) WinSetTrans($block_gui, "", 1) GUISetState(@SW_SHOW, $block_gui) GUISetCursor($MCID_CROSS, 1, $block_gui) Sleep(200) Local $iMaxLoop = 1200, $iCntLoop = 0 While Sleep(10) $iCntLoop += 1 If $iCntLoop = $iMaxLoop Then ExitLoop ; get mouse coordinates $tPos = _WinAPI_GetMousePos() $aMPos[0] = DllStructGetData($tPos, 1) $aMPos[1] = DllStructGetData($tPos, 2) ; get $hMonitor from previously defined Mouse coordinates $hMonitor = _WinAPI_MonitorFromPoint($tPos) ; get monitor $aData appropriate for previously defined coordinates $aData = _WinAPI_GetMonitorInfo($hMonitor) If Not @error Then $sDevice = $aData[3] $iDeskLeft = DllStructGetData($aData[0], 1) $iDeskTop = DllStructGetData($aData[0], 2) $iDeskWidth = DllStructGetData($aData[0], 3) $iDeskHeight = DllStructGetData($aData[0], 4) EndIf ;move the $block_gui to active monitor If $sCurDevice <> $sDevice Then $sCurDevice = $sDevice ;ConsoleWrite("- $sCurDevice=" & $sCurDevice & @CRLF) WinMove($block_gui, "", $iDeskLeft, $iDeskTop, $iDeskWidth, $iDeskHeight) EndIf ; whait Left_mouse_button _IsPressed If _IsPressed("01", $hDLL) Then $Status = 1 $aMPos = MouseGetPos() $aRecPos[0] = $aMPos[0] $aRecPos[1] = $aMPos[1] ; Wait until key is released. While _IsPressed("01", $hDLL) Sleep(50) $aMPos = MouseGetPos() $aRecPos[2] = $aMPos[0] $aRecPos[3] = $aMPos[1] ; show Capture gui GUISetState(@SW_SHOW, $hGUICapture) WinMove($hGUICapture, "", $aRecPos[0], $aRecPos[1], $aRecPos[2] - $aRecPos[0], $aRecPos[3] - $aRecPos[1]) WEnd ElseIf _IsPressed("1B", $hDLL) Then ;1B=ESC key - emergency exit GUIDelete($hGUICapture) GUIDelete($block_gui) Return SetError(1, 1, 0) EndIf If $Status = 1 Then ExitLoop WEnd GUIDelete($hGUICapture) GUIDelete($block_gui) ;ConsoleWrite($aRecPos[0] & ";" & $aRecPos[1] & ";" & $aRecPos[2] - $aRecPos[0] & ";" & $aRecPos[3] - $aRecPos[1] & @CRLF) ; if bigger from 9*9 px then create note If ($aRecPos[2] - $aRecPos[0]) > 9 And ($aRecPos[3] - $aRecPos[1]) > 9 Then CreateNew_NoteGui($aRecPos) ; create new note ;Return $FilePath EndFunc ;==>NewCapture ;---------------------------------------------------------------------------------------- Func CreateNew_NoteGui($aRecPos) ; create new note gui Local $n, $aSize[2] ReDim $NoteGui[UBound($NoteGui) + 1][18] $NoteGui[0][0] += 1 $n = $NoteGui[0][0] $aSize[0] = $aRecPos[2] - $aRecPos[0] ; width $aSize[1] = $aRecPos[3] - $aRecPos[1] ; height ; create note GUI $NoteGui[$n][0] = GUICreate($NoteGui[$n][1], $aSize[0], $aSize[1], $aRecPos[0], $aRecPos[1], $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_RESIZED, "GUI_EVENT", $NoteGui[$n][0]) ; jpg Path for _ScreenCapture_Capture $NoteGui[$n][1] = @ScriptDir & "\tmp\image_" & $NoteGui[$n][0] & ".jpg" _ScreenCapture_Capture($NoteGui[$n][1], $aRecPos[0], $aRecPos[1], $aRecPos[2], $aRecPos[3]) ; save the Gui_Size $NoteGui[$n][2] = $aSize ; set jpg Path as GUI title WinSetTitle($NoteGui[$n][0], "", $NoteGui[$n][1]) ; Creates a Picture control $NoteGui[$n][3] = GUICtrlCreatePic($NoteGui[$n][1], 0, 0, 0, 0, -1, $GUI_WS_EX_PARENTDRAG) ; Creates a Label control just for $SS_GRAYFRAME GUICtrlCreateLabel("", 0, 0, $aSize[0], $aSize[1], $SS_GRAYFRAME) ; Creates a context menu $NoteGui[$n][4] = GUICtrlCreateContextMenu($NoteGui[$n][3]) ; MenuItem for the context menu "Copy to Clipboard" $NoteGui[$n][5] = GUICtrlCreateMenuItem("Copy to Clipboard" & @TAB & "ENTER", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_CopyToClipboard") ; MenuItem for the context menu "ID_cMenuShareX" $NoteGui[$n][6] = GUICtrlCreateMenuItem("Send to ShareX", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_ShareX") ; MenuItem for the context menu "Save as..." $NoteGui[$n][7] = GUICtrlCreateMenuItem("Save as...", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_SaveAs") ; MenuItem for the context menu "Open" $NoteGui[$n][8] = GUICtrlCreateMenuItem("Open", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_Open") ; separator GUICtrlCreateMenuItem("", $NoteGui[$n][4]) ; Check for Language (maximal 4) ; $NoteGui[0][11] = "ID_Lang1" ; $NoteGui[0][12] = "ID_Lang2" ; $NoteGui[0][13] = "ID_Lang3" ; $NoteGui[0][14] = "ID_Lang4" For $i = 0 To $iLanguagesCnt ;UBound($aSupportedLanguages) - 1 If $i > 4 Then ExitLoop ; MenuItem for the context menu "OCR - Language $i" $NoteGui[$n][11 + $i] = GUICtrlCreateMenuItem("OCR - " & $aSupportedLanguages[$i][1], $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_OCR_Lang_" & $i + 1) ;ConsoleWrite($i & " - Language: " & $aSupportedLanguages[$i][1] & " - " & $aSupportedLanguages[$i][0] & @CRLF) Next ; separator GUICtrlCreateMenuItem("", $NoteGui[$n][4]) ; MenuItem for the context menu "Close" $NoteGui[$n][15] = GUICtrlCreateMenuItem("Close" & @TAB & "DELETE", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_Close") ; Display the GUI. GUISetState(@SW_SHOW, $NoteGui[$n][0]) $NoteGui[$n][16] = GUICtrlCreateDummy() $NoteGui[$n][17] = GUICtrlCreateDummy() Local $aAccelKeys[2][2] = [["{DELETE}", $NoteGui[$n][16]], ["{ENTER}", $NoteGui[$n][17]]] GUISetAccelerators($aAccelKeys) GUICtrlSetOnEvent($NoteGui[$n][16], "cm_Close") GUICtrlSetOnEvent($NoteGui[$n][17], "cm_CopyToClipboard") Return $NoteGui[$n][0] EndFunc ;==>CreateNew_NoteGui ;---------------------------------------------------------------------------------------- Func SaveFileDlg($Active_title) ; Save file Dialog ; Create a constant variable in Local scope of the message to display in FileSaveDialog. Local Const $sMessage = "Choose a filename." ; Display a save dialog to select a file. Local $sFileSaveDialog = FileSaveDialog($sMessage, @ScriptDir & "\SET\", "image (*.jpg)", $FD_PATHMUSTEXIST) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was saved.") Else ; Retrieve the filename from the filepath e.g. Example.jpg Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSEBASIC, -1)) ; Check if the extension .jpg is appended to the end of the filename. Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSEBASIC) ; If a period (dot) is found then check whether or not the extension is equal to .jpg If $iExtension Then ; If the extension isn't equal to .jpg then append to the end of the filepath. If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".jpg") Then $sFileSaveDialog &= ".jpg" Else ; If no period (dot) was found then append to the end of the file. $sFileSaveDialog &= ".jpg" EndIf ; Display the saved file. ;ConsoleWrite("You saved the following file:" & @CRLF & $sFileSaveDialog & @CRLF) FileCopy($Active_title, $sFileSaveDialog, $FC_OVERWRITE + $FC_CREATEPATH) EndIf EndFunc ;==>SaveFileDlg ;---------------------------------------------------------------------------------------- Func NoteGui_Delete($hWnd) ; NoteGui_Delete For $i = 1 To $NoteGui[0][0] If $NoteGui[$i][0] = $hWnd Then _ArrayDelete($NoteGui, $i) $NoteGui[0][0] -= 1 ExitLoop EndIf Next EndFunc ;==>NoteGui_Delete ;---------------------------------------------------------------------------------------- Func PicToClip($Path) ; put image to clipboard (Thanks to @Nine) _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($Path) Local $hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Local $hBitmap2 = _WinAPI_CopyImage($hBitmap1, $IMAGE_BITMAP, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG) _WinAPI_DeleteObject($hBitmap1) _GDIPlus_Shutdown() _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_SetDataEx($hBitmap2, $CF_BITMAP) _ClipBoard_Close() _WinAPI_DeleteObject($hBitmap2) EndFunc ;==>PicToClip ;---------------------------------------------------------------------------------------- Func PerformOCR($ImagePath, $lang = Default) ; perform ocr (Thanks to @Danyfirex) ;_GetTextFromFile($sFileName, $iBorder = 20, $dScale = 1, $sLanguageTagToUse = Default, $bUseOcrLine = False) Local $Result = _GetTextFromFile($ImagePath, 20, 1, $lang) Local $Msg = @CRLF & @CRLF & _StringRepeat(@TAB, 4) & "Copy to ClipBoard ?" Local $iMsgBoxAnswer = MsgBox(4, "OCR Result", $Result & $Msg) If $iMsgBoxAnswer = 6 Then ;Yes ClipPut($Result) ToolTip("The text was copied to the clipboard") Sleep(1000) ToolTip("") EndIf EndFunc ;==>PerformOCR ;---------------------------------------------------------------------------------------- Func TRAY_EVENT() ; TRAY_Event Switch @TRAY_ID ; Check the last tray item identifier. Case $TRAY_EVENT_PRIMARYDOUBLE, $TRAY_NewCapture NewCapture() Case $TRAY_ExitScript DllClose($hDLL) Exit EndSwitch EndFunc ;==>TRAY_EVENT ;---------------------------------------------------------------------------------------- Func GUI_EVENT() ; GUI_EVENT Select Case @GUI_CtrlId = $GUI_EVENT_RESIZED Local $aSize For $i = 1 To $NoteGui[0][0] If $NoteGui[$i][0] = @GUI_WinHandle Then $aSize = $NoteGui[$i][2] WinMove(@GUI_WinHandle, "", Default, Default, $aSize[0], $aSize[1]) ControlMove(@GUI_WinHandle, "", "Static1", 0, 0, $aSize[0], $aSize[1]) ControlMove(@GUI_WinHandle, "", "Static2", 0, 0, $aSize[0], $aSize[1]) ExitLoop EndIf Next EndSelect EndFunc ;==>GUI_EVENT ;---------------------------------------------------------------------------------------- Func cm_CopyToClipboard() ; ContextMenu "Copy to Clipboard" Local $Active_title = WinGetTitle(@GUI_WinHandle) ToolTip("Copied to clipboard") PicToClip($Active_title) Sleep(500) ToolTip("") EndFunc ;==>cm_CopyToClipboard ;---------------------------------------------------------------------------------------- Func cm_ShareX() ; ContextMenu "Send to ShareX"" Local $Active_title = WinGetTitle(@GUI_WinHandle) PicToClip($Active_title) Sleep(100) Local $strLen = StringLen(@ScriptDir & "\tmp\image_") If StringLeft($Active_title, $strLen) = @ScriptDir & "\tmp\image_" Then GUIDelete(@GUI_WinHandle) FileDelete($Active_title) NoteGui_Delete(@GUI_WinHandle) EndIf ShellExecute("C:\Program Files\ShareX\ShareX.exe", "-imageeditor ") ; ℹ️ Give your path * <- Local $hShareXImageEd = WinWait("[TITLE:ShareX - Image editor; REGEXPCLASS:WindowsForms10\.Window\..\.app\.0\..+_r\d+_ad1]", "", 2) While WinExists($hShareXImageEd) ControlClick($hShareXImageEd, "", "[NAME:btnLoadImageFromClipboard]") Sleep(300) WEnd $hShareXImageEd = WinWait("[TITLE:ShareX - Image editor; REGEXPCLASS:WindowsForms10\.Window\..\.app\.0\..+_r\d+_ad1]", "", 2) WinActivate($hShareXImageEd) WinSetState($hShareXImageEd, "", @SW_MAXIMIZE) EndFunc ;==>cm_ShareX ;---------------------------------------------------------------------------------------- Func cm_SaveAs() ; ContextMenu "Save as..." Local $Active_title = WinGetTitle(@GUI_WinHandle) SaveFileDlg($Active_title) EndFunc ;==>cm_SaveAs ;---------------------------------------------------------------------------------------- Func cm_Open() ; ContextMenu "Open" Local $Active_title = WinGetTitle(@GUI_WinHandle) ShellExecute($Active_title) EndFunc ;==>cm_Open ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_1() ; ContextMenu "OCR - Language 0" Local $Active_title = WinGetTitle(@GUI_WinHandle) PerformOCR($Active_title, $aSupportedLanguages[0][0]) EndFunc ;==>cm_OCR_Lang_1 ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_2() ; ContextMenu "OCR - Language 1" Local $Active_title = WinGetTitle(@GUI_WinHandle) If $iLanguagesCnt > 1 Then PerformOCR($Active_title, $aSupportedLanguages[1][0]) EndFunc ;==>cm_OCR_Lang_2 ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_3() ; ContextMenu "OCR - Language 2" Local $Active_title = WinGetTitle(@GUI_WinHandle) If $iLanguagesCnt > 2 Then PerformOCR($Active_title, $aSupportedLanguages[2][0]) EndFunc ;==>cm_OCR_Lang_3 ;---------------------------------------------------------------------------------------- Func cm_OCR_Lang_4() ; ContextMenu "OCR - Language 3" Local $Active_title = WinGetTitle(@GUI_WinHandle) If $iLanguagesCnt > 3 Then PerformOCR($Active_title, $aSupportedLanguages[3][0]) EndFunc ;==>cm_OCR_Lang_4 ;---------------------------------------------------------------------------------------- Func cm_Close() ; ContextMenu "Close" Local $Active_title = WinGetTitle(@GUI_WinHandle) Local $strLen = StringLen(@ScriptDir & "\tmp\image_") If StringLeft($Active_title, $strLen) = @ScriptDir & "\tmp\image_" Then GUIDelete(@GUI_WinHandle) FileDelete($Active_title) NoteGui_Delete(@GUI_WinHandle) ;ConsoleWrite("- WinClose " & @GUI_WinHandle & " & FileDelete " & $Active_title & @CRLF) EndIf EndFunc ;==>cm_Close ;---------------------------------------------------------------------------------------- Func _Array_Gui_display() ; *** Debug _ArrayDisplay($NoteGui) _ArrayDisplay($NoteGui, "$NoteGui") EndFunc ;==>_Array_Gui_display ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GetTextFromFile ; Description ...: reading text from a picture file ; Syntax.........: _GetText($sFileName [, $iBorder = 20 [, $dScale = 1 [, $sLanguageTagToUse = Default [, $bUseOcrLine = False]]]]) ; Parameters ....: $sFileName Full path and extension of the image file ; $iBorder [optional] Draw a border araunt, The color is taken from first pixel ; $dScale [optional] Scale factor ; $sLanguageTagToUse [optional] Gets the language being used for text recognition ; $bUseOcrLine [optional] Represents a single line of text recognized by the OCR engine and returned as part of the OcrResult. ; Return value...: Success: Contains the String results of Optical Character Recognition (OCR). ; Failure: "" Empty String otherwise. ; On Error: false ; ; Author ........: ioa747 ; Notes .........: https://www.autoitscript.com/forum/topic/211521-ocr-from-a-small-area ;-------------------------------------------------------------------------------------------------------------------------------- Func _GetTextFromFile($sFileName, $iBorder = 20, $dScale = 1, $sLanguageTagToUse = Default, $bUseOcrLine = False) Local $hHBitmap, $hBitmap, $hImage, $hImageCtxt, $sOCRTextResult, $iBmpW, $iBmpH, $iBorderColor _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile($sFileName) $iBmpW = $dScale * _GDIPlus_ImageGetWidth($hBitmap) $iBmpH = $dScale * _GDIPlus_ImageGetHeight($hBitmap) ; Add Border If $iBorder > 0 Then $iBorderColor = _GDIPlus_BitmapGetPixel($hBitmap, 1, 1) ;get pixel color from 1,1 $hImage = _GDIPlus_BitmapCreateFromScan0($iBmpW + (2 * $iBorder), $iBmpH + (2 * $iBorder)) ;create an empty bitmap If @error Then Return SetError(3, 0, False) $hImageCtxt = _GDIPlus_ImageGetGraphicsContext($hImage) ;get the graphics context of the bitmap _GDIPlus_GraphicsSetSmoothingMode($hImageCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hImageCtxt, $iBorderColor) ;clear bitmap with color white _GDIPlus_GraphicsDrawImage($hImageCtxt, $hBitmap, $iBorder, $iBorder) _GDIPlus_ImageDispose($hBitmap) Else $hImage = $hBitmap EndIf $sOCRTextResult = _UWPOCR_GetText($hImage, $sLanguageTagToUse, $bUseOcrLine) If @error Then Return SetError(4, 0, False) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() Return $sOCRTextResult EndFunc ;==>_GetTextFromFile ;-------------------------------------------------------------------------------------------------------------------------------- Snipe new note
    Double Click the tray icon to start  NewCapture

    or While Left Windows Key IsPressed, tap 2 times the Left  Shift key  (is useful when Capture menu or context menu).
      While start NewCapture point click anywhere to escape. (Does not catch smaller than 9*9 px)
      While start NewCapture escape with ESC  

    Please, every comment is appreciated!
    leave your comments and experiences here!
    Thank you very much 
  13. Thanks
    AutoBert reacted to MattyD in GDI - Interactive Fader and Knob controls   
    hi all
    This one is nowhere near finished - I'd probably call it a proof of concept for now -
    "GDIControls.au3" needs to be included, then there's a couple of control types that you should be able to create.
    _GUICtrlGDI_CreateHFader($hGUI, $iX, $iY, $iWidth, $iHeight [, $Colour [, $iStyle [, $iExStyle ]]]) _GUICtrlGDI_CreateVFader($hGUI, $iX, $iY, $iWidth, $iHeight [, $Colour [, $iStyle [, $iExStyle ]]]) _GUICtrlGDI_CreateKnob($hGUI, $iX, $iY, $iWidth, $iHeight [, $Colour [, $iStyle [, $iExStyle ]]]) _GUICtrlGDI_CreateLRKnob($hGUI, $iX, $iY, $iWidth, $iHeight [, $Colour [, $iStyle [, $iExStyle ]]]) _GUICtrlGDI_CreateVMeter($hWnd, $iX, $iY, $iWidth, $iHeight [, $iStyle [, $iExStyle]]) _GUICtrlGDI_CreateHMeter($hWnd, $iX, $iY, $iWidth, $iHeight [, $iStyle [, $iExStyle]]) _GUICtrlGDI_Create7SegDisplay($hGUI, $iX, $iY, $iWidth, $iHeight [, $Colour [, $iStyle [, $iExStyle ]]]) _GUICtrlGDI_Create14SegDisplay($hGUI, $iX, $iY, $iWidth, $iHeight [, $Colour [, $iStyle [, $iExStyle ]]]) The above functions return a controlID which can be read with GuiCtrlRead() via the usual methods. The controls can also be manipulated with GuiCtrlSetData()
    Valid values can be from 0 through to 127.
    That's about the long and short of it!
    ----------
    Theres a bit going on with the mechanics of it here, and I'm sure theres probably a better way of going about things...
    But for anyone who' s interested this is what's going on:
    I take the requested dimentions of the control, If there's already bitmaps available for the requested type/dimentions/colour we use those. Otherwise, we dynamically generate a set of 128 bitmaps for the control.
      The next step is to create a "static" control, which is basically the same as a label. With the right style we can push images to these however. At this stage those optional $iStyle and $iExStyle flags come into play. There are some forced style values to make things work, but hey, if you want to add $WS_BORDER or something I'm not gonna stop ya!
      Static controls are pretty dumb, but they do know when they're clicked on ($STN_CLICKED). This is enough to let me know that a control needs updating.
      Next we need to track the mouse. We need to know when and where the mouse in released. I can't really utillise the $GUI_EVENT_* method for this. I'd either have to force OnEvent() mode, or we'd have to ask the user to call some function in the Main GuiGetMsg() Loop. So then I thought of handling $WM_MOUSEMOVE.  This works great until you move over a control in the client area! It seems the message gets gobbled up. So now I'm using a low-level mouse hook. With this I can find where we are relative to the control and update it accordingly.
      The next peice of the puzzle is to let the user know that something has been done.   I can easily provide a "getter" function that retrieves the control's values. I'd rather not have a bespoke function for this though. So I thought its better to associate dummy controls, which I use as a delivery mechanism.
      Lastly we need have a method of updating the control from outsige the GUI.  For ease of use we probably want to leverage GuiCtrlSetData(). Setting the dummy control this way puts us in the same predicament as earlier however - we can't really use GuiGetMsg() to monitor it. but we can periodically check the value of the dummy control with an adlib function. If the value of the dummy is not where the GDI control was set with the GUI, we know we need to update it!  
    GDICtrls_1-9.zip
  14. Like
    AutoBert got a reaction from TOOD in How to WinExist('[CLASS:#32770]') with Button1?   
    Study this small script:
    ; Open a browser with the basic example page, insert an ; event script into the head of the document that creates ; a JavaScript alert when someone clicks on the document #include <IE.au3> Local $oIE = _IE_Example("basic") _IEHeadInsertEventScript($oIE, "document", "onclick", "alert('Someone clicked the document!');") AdlibRegister('CloseAlert', 1000) $tdStart = TimerInit() While TimerDiff($tdStart) < 60000 Sleep(1000) WEnd _IEQuit($oIE) Func CloseAlert () Sleep(3000) ControlClick('[CLASS:#32770]', 'Someone clicked the document!', 2) EndFunc ;==>CloseAlert after example is shown ckick into brower document. 3 sec's later the shown alert is closed.
  15. Thanks
    AutoBert reacted to AspirinJunkie in TableData - more efficient handling with table structured data   
    Introduction
    In AutoIt, we often have to deal with data structured like tables.
    Depending on the source, we sometimes have to write a lot of code to convert the data into a form that we can continue working with.
    Subsequently, working with this data is not necessarily any easier, as instead of accessing the descriptive names of the data attributes, we have to deal with numerical indices where it is very easy to lose track.
    Both problems are addressed by the UDF.
    In the basic approach, the UDF works with a table object (just an AutoIt map) in which the data is separated from the header.
    This enables cleaner processing of the data.
    It offers functions to read in data from various sources (CSV, array, string with fixed-width-columns, strings with their own column separators).
    Within this call, the data is separated from the header or header data is added to it in the first place.
    The data is then processed according to its format (with csv quotes and escapes removed, with fixed-width spaces removed...).
    In addition, the user can define how exactly the data should be processed for each column individually. He is completely free to do this.
    In this way, the data is already given the final format in which it is to be further processed when it is read in.
    The data can then be handled on a column-based or attribute-based basis.
    In other words, instead of using indices, the attribute names of the data can simply be used - this makes the code clearer.
    Example (much more examples provided >>here<<)
    We want to evaluate the open ports on a computer with AutoIt.
    The command line command for this is netstat -t and gives us the following output (Depending on the system, the output may look slightly different for you):
    Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 116 192.168.64.110:ssh 192.168.29.200:65069 ESTABLISHED tcp 0 0 192.168.64.110:ssh 192.168.29.200:65068 ESTABLISHED To continue processing the data in a meaningful way, we may need to carry out the following steps in AutoIt:
    Delete the first useless lines Extract the header row (it is treated differently from the data) Create an array with the correct dimension to hold the data Separate the data either by spaces or by fixed column widths Removal of unnecessary spaces from the data Converting the Recv-Q and Send-Q column to a numeric data type (for sorting etc.) Separation of address data into IP address and port This can mean a lot of (error-prone) code effort.
    With this UDF, however, you can solve the whole thing in a single call as follows:
    $sString = 'Active Internet connections (w/o servers)' & @CRLF & _ '' & @CRLF & _ 'Proto Recv-Q Send-Q Local Address Foreign Address State' & @CRLF & _ 'tcp 0 116 192.168.64.110:ssh 192.168.29.200:65069 ESTABLISHED' & @CRLF & _ 'tcp 0 0 192.168.64.110:ssh 192.168.29.200:65068 ESTABLISHED' ; Transfer data to table type by using the size of every column: Global $mData = _td_fromFixWidth($sString, _ "left 6; Number 7; Number 7; StringSplit($x, ':', 2) 24;StringSplit($x, ':', 2) 24;", _ ; column definitions "1-2", _ ; skip row 1 to 2 True) ; display data _td_display($mData) and we get the result:

    If you now use functions such as _td_toObjects(), you can process the individual data with expressions such as $aData.Proto or $aData.State.
    This should be much clearer than having to deal with array indices.
    Functions

    >>sourcecode and download on github<<
  16. Thanks
    AutoBert reacted to mLipok in WebcamDS (DirectShow webcam)   
    modified verision:
     
    WebcamDS_UDF.zip
  17. Thanks
    AutoBert reacted to Nine in Printer Manager   
    In this topic, it was mentioned by @mLipok that it could be doable to manage printers with winspool.drv DLL.  It was enough to get my attention on it.  I do not remember seeing any UDF gathering all those functions.
    Func _PRNT_GetDefaultPrinter()
    Func _PRNT_SetDefaultPrinter($sPrinter)
    Func _PRNT_OpenPrinter($sName)
    Func _PRNT_ClosePrinter($hPrinter)
    Func _PRNT_GetPrinterInfo($hPrinter, $bGlobal, $bRAW = False)
    Func _PRNT_SetPrinterInfo($hPrinter, $iProp, $iValue, $bGlobal)
    Func _PRNT_EnumPrinters()
    Func _PRNT_IsValidDevmode($tDevMode)
    Func _PRNT_EnumJobs($hPrinter)
    Version 2023-10-17
    *added new functions _PRNT_IsValidDevmode and _PRNT_EnumJobs
    Version 2023-10-15
    * solved a problem where garbage collector would destroy $tDevMode after a while on return of _PRNT_GetPrinterInfo
     
    There is a multitude of other functions that could be part of this UDF, but I have decided to stop here and see how you like it.
    If you have comments or suggestions, they are always welcome.
    Printer_UDF.zip
  18. Thanks
    AutoBert reacted to ioa747 in Desktop icons save and restore   
    Saves the position of the icons, from the desktop, with the ability of restoring
    With command line parameters  -save , it save the icons setting,   with  -restore , it restore the icons setting.
    Without  command line parameters display a GUI with  save , restore buttons
    DesktopIconSet.au3
    ; https://www.autoitscript.com/forum/topic/210688-desktop-icons-save-and-restore/ ;---------------------------------------------------------------------------------------- ; Title...........: DesktopIconSet.au3 ; Description.....: Saves the position of the icons, from the desktop, with the ability of restoring ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Notes ..........: Tested on Windows 10 Version 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $g_sIniPath = @ScriptDir & "\Setting.ini" Global $g_hDesktop = _WinGetDesktopHandle() Global $g_hDeskCtrlListView = ControlGetHandle($g_hDesktop, "", "[CLASS:SysListView32;INSTANCE:1]") ConsoleWrite("$g_sIniPath=" & $g_sIniPath & @CRLF) ConsoleWrite("$g_hDesktop=" & $g_hDesktop & @CRLF) ConsoleWrite("$g_hDeskCtrlListView=" & $g_hDeskCtrlListView & @CRLF) Global $iParams = $CmdLine[0] ;Check if $CmdLine parameters If Not $iParams Then _CallGUI() Else $iParams = $CmdLine EndIf Switch $iParams[1] Case "-save" _SaveSetting() Case "-restore" _RestoreSetting() EndSwitch Exit ;_SetShortcutPos("Recycle Bin", 0, 0) ;---------------------------------------------------------------------------------------- Func _CallGUI() GUICreate(" DeskTop shortcuts", 170, 90, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) Local $ButtonSave = GUICtrlCreateButton("Save Setting", 10, 10, 150, 30) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Local $ButtonRestore = GUICtrlCreateButton("Restore Setting", 10, 50, 150, 30) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $ButtonSave _SaveSetting() ExitLoop Case $ButtonRestore _RestoreSetting() ExitLoop EndSwitch WEnd Exit EndFunc ;==>_CallGUI ;---------------------------------------------------------------------------------------- Func _SetShortcutPos($Name = "", $X = 0, $Y = 0) Local $iIndex = _GUICtrlListView_FindInText($g_hDeskCtrlListView, $Name) If $iIndex == -1 Then Return SetError(1, 0, "! Could not find icon: " & $Name) EndIf _GUICtrlListView_SetItemPosition($g_hDeskCtrlListView, $iIndex, $X, $Y) Return "- " & $Name & "=" & $X & "," & $Y EndFunc ;==>_SetShortcutPos ;---------------------------------------------------------------------------------------- Func _SaveSetting() Local $iItemCount, $sTxt, $aPos $iItemCount = _GUICtrlListView_GetItemCount($g_hDeskCtrlListView) ConsoleWrite("> Save Setting:" & @CRLF) ConsoleWrite("- Item Count:" & $iItemCount & @CRLF) $sTxt = "[Setting]" & @CRLF For $i = 0 To $iItemCount - 1 $sTxt &= _GUICtrlListView_GetItemText($g_hDeskCtrlListView, $i) $aPos = _GUICtrlListView_GetItemPosition($g_hDeskCtrlListView, $i) $sTxt &= "=" & $aPos[0] & "," & $aPos[1] & @CRLF Next ConsoleWrite($sTxt & @CRLF) Local $hFileOpen = FileOpen($g_sIniPath, $FO_OVERWRITE + $FO_CREATEPATH + $FO_UTF8_NOBOM) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the txt file.") Return False EndIf FileWrite($hFileOpen, $sTxt) EndFunc ;==>_SaveSetting ;---------------------------------------------------------------------------------------- Func _RestoreSetting() ConsoleWrite("> Restore Setting:" & @CRLF) Local $aPos ; Read the INI section labelled 'Setting'. This will return a 2 dimensional array. Local $aArray = IniReadSection($g_sIniPath, "Setting") If Not @error Then ; Enumerate through the array displaying the keys and their respective values. For $i = 1 To $aArray[0][0] $aPos = StringSplit($aArray[$i][1], ",") If $aPos[0] = 2 Then ConsoleWrite(_SetShortcutPos($aArray[$i][0], $aPos[1], $aPos[2]) & @CRLF) EndIf Next EndIf EndFunc ;==>_RestoreSetting ;---------------------------------------------------------------------------------------- ; https://www.autoitscript.com/forum/topic/119783-desktop-class-workerw/#comment-903081 ; <_WinGetDesktopHandle.au3> ; Function to get the Windows' Desktop Handle. ; Since this is no longer a simple '[CLASS:Progman]' on Aero-enabled desktops, this method uses a slightly ; more involved method to find the correct Desktop Handle. ; ; Author: Ascend4nt, credits to Valik for pointing out the Parent->Child relationship: Desktop->'SHELLDLL_DefView' ;---------------------------------------------------------------------------------------- Func _WinGetDesktopHandle() Local $i, $hDeskWin, $hSHELLDLL_DefView, $h_Listview_Configs, $aWinList ; The traditional Windows Classname for the Desktop, not always so on newer O/S's $hDeskWin = WinGetHandle("[CLASS:Progman]") ; Parent->Child relationship: Desktop->SHELLDLL_DefView $hSHELLDLL_DefView = ControlGetHandle($hDeskWin, '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') ; No luck with finding the Desktop and/or child? If $hDeskWin = '' Or $hSHELLDLL_DefView = '' Then ; Look through a list of WorkerW windows - one will be the Desktop on Windows 7+ O/S's $aWinList = WinList("[CLASS:WorkerW]") For $i = 1 To $aWinList[0][0] $hSHELLDLL_DefView = ControlGetHandle($aWinList[$i][1], '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') If $hSHELLDLL_DefView <> '' Then $hDeskWin = $aWinList[$i][1] ExitLoop EndIf Next EndIf ; Parent->Child relationship: Desktop->SHELDLL_DefView->SysListView32 $h_Listview_Configs = ControlGetHandle($hSHELLDLL_DefView, '', '[CLASS:SysListView32; INSTANCE:1]') If $h_Listview_Configs = '' Then Return SetError(-1, 0, '') Return SetExtended($h_Listview_Configs, $hDeskWin) EndFunc ;==>_WinGetDesktopHandle ;----------------------------------------------------------------------------------------  
    Please, leave your comments and experiences here.
    thank you very much !
  19. Like
    AutoBert got a reaction from AIG in Program window freezing during the hashing process   
    That's the GuiGetMsg, a bigger block in the FileRead helps for getting better performance, using:
    $dTempData = FileRead($hFile, Ceiling($iFileSizeForProgress / 100)) will effect better performance for files gt 51200 kb, but smaller files will be slower than actual.
  20. Like
    AutoBert got a reaction from AIG in Program window freezing during the hashing process   
    Inserting a block like this in the 2. Do .. Until  (func _Crypt_HashFile2)
    Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ;ESC => break hashing $vReturn = -1 ExitLoop 2 Case Else ;hash the data EndSwitch is a possible solution  wich breaks if user use the X-Button or press ESCape.
  21. Like
    AutoBert reacted to Andreik in Bulldozer   
    Added 20 more levels, so there are 60 levels now. Since some of you already played some levels I added also the option to start to a specific level so you don't have to play again from the beginning. To use this functionality just press J and enter the level that you want to play.
  22. Like
    AutoBert got a reaction from Zedna in GuiCtrlCreatePic equivalent for PNG or TIFF images?   
    I don't know if it works with TIF's but sure it works with PNG's. Edit: Just tested with the welcomefax.tif (the onliest tif i have) and it works:
    #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUICtrlPic.au3> #include <Array.au3> Global $hGui = GUICreate("Show Tif",@DesktopWidth, @DesktopHeight) Global $aDim = WinGetClientSize($hGui) Global $sAutoItPath If @Compiled Then $sAutoItPath=RegRead64('HKLM\Software\AutoIt v3\AutoIt', 'InstallDir')&'\' Else $sAutoItPath= StringReplace(@AutoItExe, "autoit3.exe", "")&'\' $sAutoItPath= StringReplace(@AutoItExe, "autoit3_x64.exe", "") EndIf Global $Background = _GUICtrlPic_Create("C:\Users\(len)Bert\Downloads\Documents\Fax\Inbox\WelcomeFax.tif", 0, 0, $aDim[0], $aDim[1], $SS_CENTERIMAGE, Default) GUICtrlSetState(-1, $Gui_DISABLE) GUISetState() While 1 Switch GUIGetMsg() Case $Gui_EVENT_CLOSE Exit EndSwitch WEnd Func RegRead64($sKeyname, $sValue) ;Aus AutoUpdateIt.au3 Local $sRes = RegRead($sKeyname, $sValue) If @error And @AutoItX64 Then $sKeyname = StringReplace($sKeyname, "HKEY_LOCAL_MACHINE", "HKLM") $sKeyname = StringReplace($sKeyname, "HKLM\SOFTWARE\", "HKLM\SOFTWARE\Wow6432Node\") $sRes = RegRead($sKeyname, $sValue) If @error Then SetError(1) Return "" EndIf EndIf SetError(0) Return $sRes EndFunc ;==>RegRead64  
    GUICtrlPic.au3
  23. Haha
    AutoBert got a reaction from Andreik in Bulldozer   
    Easier, as finding a solution for level 8.
  24. Like
    AutoBert got a reaction from Skeletor in full screen gui   
    ESC insn't colsing the script. and script has also bad coding practice defining global var in a loop. Add this:
    #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 and have a look in the console output.
     
    So i prefer to do i this way:
    ; https://www.autoitscript.com/forum/topic/210078-full-screen-gui/?do=findComment&comment=1516762 #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region (=== GUI generated by GuiBuilderPlus 1.0.0-beta4 ===) Global $hGUI = GUICreate("MyGUI", 400, 350, 760, 365, -1, -1) Global $idFullScreen = GUICtrlCreateDummy() #EndRegion (=== GUI generated by GuiBuilderPlus 1.0.0-beta4 ===) _GDIPlus_Startup() ; ========== USED TO ADD PICTURE IN MEMORY ==================== Global Const $Pic_Banner = _GDIPlus_BitmapCreateFromMemory(_vista(), True) ; ============================================================= OnAutoItExitRegister("_Exit") _main() ;------------------------------------------------------------------------------ ; Title...........: _main ; Description.....: run the main program loop ;------------------------------------------------------------------------------ Func _main() GUISetState(@SW_SHOW) Local $aAccelKeys[1][2] = [["{F11}", $idFullScreen]] GUISetAccelerators($aAccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idFullScreen _FullScreen() Case Else ; EndSwitch ;Sleep(10) WEnd EndFunc ;==>_main ;------------------------------------------------------------------------------ Func _FullScreen() Local Static $aWPos, $aGUIStyle = GUIGetStyle($hGUI), $iFullScreen = 0 If $iFullScreen = 0 Then $aWPos = WinGetPos($hGUI) WinMove($hGUI, "", 0, 0, @DesktopWidth, @DesktopHeight) Local $Pic1 = GUICtrlCreatePic("", 0, 0, @DesktopWidth, @DesktopHeight) _WinAPI_DeleteObject(GUICtrlSendMsg($Pic1, $STM_SETIMAGE, $IMAGE_BITMAP, $Pic_Banner)) GUISetStyle(BitOR($WS_POPUP, $WS_EX_TOPMOST), -1) $iFullScreen = 1 Else WinMove($hGUI, "", $aWPos[0], $aWPos[1], $aWPos[2], $aWPos[3]) GUISetStyle($aGUIStyle[0], $aGUIStyle[1]) $iFullScreen = 0 EndIf EndFunc ;==>_FullScreen ;------------------------------------------------------------------------------------- Func _exit() ;_WinAPI_DeleteObject($Pic_Banner) _GDIPlus_Shutdown() Exit EndFunc ;==>_exit ;------------------------------------------------------------------------------------- ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2020-06-05 ESC is closing GUI and no warnings or errors in console.
  25. Thanks
    AutoBert reacted to water in make Au3Check.exe check library only one   
    Why not check the library first and when there are no errors then check all scripts using the library?
×
×
  • Create New...