Rowlett Posted April 15, 2014 Posted April 15, 2014 i assume you wouldn't put your action (i.e. shellexecute/shellexecutewait within each case though would you because it would just keep repeating the process? (sorry for the dumb newbie questions!) and to progress or control the tooltip just call $fPerc += 0.15? i don't know how "smooth" the increments would be, would kind of spoil your hard work :-(
UEZ Posted April 15, 2014 Author Posted April 15, 2014 The examples are examples. That means real "life" wouldn't probably so smooth. What you can do is to count all your steps and increase the steps so that the percentage will fit to your needs. E.g. you have 22 steps -> 1/22, 2/22, 3/22, etc. On some web pages the progress bar fill up the spaces between the progress much more smoothly. e.g. from 10% to 20%. I need to make some thoughts how to implement it into the functions. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Rowlett Posted April 15, 2014 Posted April 15, 2014 thanks for the reply and help UEZ much appreciated!
marko001 Posted October 31, 2014 Posted October 31, 2014 (edited) Hi UEZ and thanks for your work. In the past I never used progres on my project but now it's time to use one. My application has lot of data to load before showing $mainwindow. So i decided to use expandcollapse popup[...] #AutoIt3Wrapper_Res_File_Add=images\RES\Y.jpg, rt_rcdata, Y #AutoIt3Wrapper_Res_File_Add=images\RES\Z.jpg, rt_rcdata, Z #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** SplashImageOn("Gear",@ScriptDir & "\images\gear.gif",83,75,-1,-1) [all vars, array, const declarations] [all includes] _loadsettings() _loadexternalsettings() _loadsettings_restart() _Loaddetails(GUICtrlRead($webdetails)) _startToolTip() _GuiPositioning() ; this enable and shows all GUIS AdlibRegister("_sessioning", 300000) ; 5 mins AdlibRegister("_ontop", 2000) ; 2 sec GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") SplashOff() while 1 _ctrl_keys_activities() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _kill() Case $GUI_EVENT_MINIMIZE _to_tray() [and all cases] Can I use your solution (and how in that case) in substitution of the splashimage() ...splashoff() ? Mainly I want to have a nice loading screen while all "underground" activities run, then finishing loading and showing program windows. Thanks a lot, Marco Edited October 31, 2014 by marko001
UEZ Posted October 31, 2014 Author Posted October 31, 2014 Try something like this here: expandcollapse popup[...] #AutoIt3Wrapper_Res_File_Add=images\RES\Y.jpg, rt_rcdata, Y #AutoIt3Wrapper_Res_File_Add=images\RES\Z.jpg, rt_rcdata, Z #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Timers.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0 Global $iW = 500, $iH = 250 Global Const $hGUI = GUICreate("Gears Animation", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() Global $hHBmp_BG, $hB, $iSleep = 40 _Timer_SetTimer($hGUI, $iSleep, "PlayAnim") [all vars, array, const declarations] [all includes] _loadsettings() _loadexternalsettings() _loadsettings_restart() _Loaddetails(GUICtrlRead($webdetails)) _startToolTip() _GuiPositioning() ; this enable and shows all GUIS AdlibRegister("_sessioning", 300000) ; 5 mins AdlibRegister("_ontop", 2000) ; 2 sec GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") _Timer_KillAllTimers($hGUI_Splash) _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete($hGUI_Splash) while 1 _ctrl_keys_activities() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _kill() Case $GUI_EVENT_MINIMIZE _to_tray() [and all cases] Func PlayAnim($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime $hHBmp_BG = GearsAnim($iW, $iH) $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) EndFunc ;==>PlayAnim Func GearsAnim($iW, $iH, $sText = "Loading...", $fSpeed = 2, $bBgGradient = True, $bHBitmap = True) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 + (@OSBuild > 5999)) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, $GDIP_TEXTRENDERINGHINT_ANTIALIAS) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) If $bBgGradient Then Local Const $hBrush_Bg = _GDIPlus_LineBrushCreate(0,0, $iW / 2, $iH / 2, 0xFF080808, 0xFF606060, 1) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iW, $iH, $hBrush_Bg) EndIf Local Const $iW2 = $iW / 2, $iH2 = $iH / 2 Local Const $hBrush = _GDIPlus_BrushCreateSolid(0) Local Static $f1 = 0, $f2 = 0, $f3 = 0, $f4 = 0, $c = 0 Local $aGears[4], $i, $iW_Gear = 220, $iH_Gear = 150, $iW2_Gear = $iW_Gear / 2, $iH2_Gear = $iH_Gear / 2 Local Const $hBitmap_Gear = _GDIPlus_BitmapCreateFromScan0($iW_Gear, $iH_Gear) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Gear) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 + (@OSBuild > 5999)) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hCtxt, 0xFF121212) $aGears[0] = _GDIPlus_BitmapCreateGear($f1) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[0], 0, 1) $aGears[1] = _GDIPlus_BitmapCreateGear($f2) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[1], 51, 51) $aGears[2] = _GDIPlus_BitmapCreateGear($f3) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[2], 0, 101) $aGears[3] = _GDIPlus_BitmapCreateGear($f4, 12, 60, 48) _GDIPlus_GraphicsDrawImage($hCtxt, $aGears[3], 120, 4) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Gear, $iW2 - $iW2_Gear, $iH2 - $iH2_Gear, $iW_Gear, $iH_Gear) $f1 -= $fSpeed $f2 += $fSpeed $f3 -= $fSpeed $f4 -= $fSpeed / 2 Local $iC = Hex(Int(0x80 - Sin($c) * 0x7F), 2) $c += 0.025 Local $hPath = _GDIPlus_PathCreate() If $sText Then _GDIPlus_BrushSetSolidColor($hBrush, "0x9F" & $iC & $iC & $iC) Local Const $hFamily = _GDIPlus_FontFamilyCreate("Arial Black"), $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) ;~ _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH) $tLayout.Y = $iH2 + $iH2_Gear + 4 _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, $iH / 10, $hFormat) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush) _GDIPlus_PathReset($hPath) EndIf Local Const $iPenSize = 2 Local $tRect = DllStructCreate("float X; float Y; float W; float H;") $tRect.W = $iW_Gear * 1.5 $tRect.H = $iH_Gear Local $hBrush_outline = _GDIPlus_LineBrushCreateFromRectWithAngle($tRect, 0xFF202020, 0xFFA0A0A0, -210, True, 1) _GDIPlus_LineBrushSetSigmaBlend($hBrush_outline, 0, 1) Local Const $hPen = _GDIPlus_PenCreate2($hBrush_outline, $iPenSize) $iW2_Gear += $iPenSize / 2 $iH2_Gear += $iPenSize / 2 Local $aPoints[9][2] = [[8]], $iCorner = 5 $aPoints[1][0] = $iW2 - $iW2_Gear + $iCorner $aPoints[1][1] = $iH2 - $iH2_Gear $aPoints[2][0] = $iW2 + $iW2_Gear - $iCorner $aPoints[2][1] = $iH2 - $iH2_Gear $aPoints[3][0] = $iW2 + $iW2_Gear $aPoints[3][1] = $iH2 - $iH2_Gear + $iCorner $aPoints[4][0] = $iW2 + $iW2_Gear $aPoints[4][1] = $iH2 + $iH2_Gear - $iCorner $aPoints[5][0] = $iW2 + $iW2_Gear - $iCorner $aPoints[5][1] = $iH2 + $iH2_Gear $aPoints[6][0] = $iW2 - $iW2_Gear + $iCorner $aPoints[6][1] = $iH2 + $iH2_Gear $aPoints[7][0] = $iW2 - $iW2_Gear $aPoints[7][1] = $iH2 + $iH2_Gear - $iCorner $aPoints[8][0] = $iW2 - $iW2_Gear $aPoints[8][1] = $iH2 - $iH2_Gear + $iCorner _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.025) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_PathDispose($hPath) _GDIPlus_BrushDispose($hBrush) If $bBgGradient Then _GDIPlus_BrushDispose($hBrush_Bg) _GDIPlus_BrushDispose($hBrush_outline) If $sText Then _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) EndIf For $i = 0 to 3 _GDIPlus_BitmapDispose($aGears[$i]) Next _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BitmapDispose($hBitmap_Gear) _GDIPlus_GraphicsDispose($hGfx) If $bHBitmap Then Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBITMAP EndIf Return $hBitmap EndFunc ;==>GearsAnim Func _GDIPlus_BitmapCreateGear($fAngle = 0, $iTeeth = 6, $fRadius_outer = 30, $fRadius_inner = 18, $fTeethHeight = 10.5, $iColor1 = 0xFF606060, $iColor2 = 0xFF404040) Local Const $iW = 2 * $fRadius_outer + $fTeethHeight * 2, $iH = $iW, $iW2 = $iW / 2, $iH2 = $iW2, $fDeltaAngle = 360 / $iTeeth, $fDeg = 3.14159265358979 / 180 Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_ANTIALIAS8X4 + (@OSBuild > 5999)) Local $tRect = DllStructCreate("float X; float Y; float W; float H;") $tRect.W = $iW $tRect.H = $iH / 2 Local $hBrush_outline = _GDIPlus_LineBrushCreateFromRectWithAngle($tRect, 0x44000000 + BitAND(0x00FFFFFF, $iColor2), 0, -90, True, 1) _GDIPlus_LineBrushSetSigmaBlend($hBrush_outline, 1, 0.95) _GDIPlus_LineBrushSetColors($hBrush_outline, 0, 0xAA989898) Local Const $hPen = _GDIPlus_PenCreate2($hBrush_outline, 2) Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColor1) Local Const $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddEllipse($hPath, $iW2 - $fRadius_outer, $iH2 - $fRadius_outer, $fRadius_outer * 2, $fRadius_outer * 2) Local $aPoints[5][2] = [[4]], $iX, $iY, $i, $j For $i = 1 To $iTeeth $iX = $iW2 + Cos(($fAngle + 0) * $fDeg) * $fRadius_outer $iY = $iH2 + Sin(($fAngle + 0) * $fDeg) * $fRadius_outer For $j = 0 To $aPoints[0][0] $aPoints[1][0] = $iX + Cos(($fAngle + 45) * $fDeg) * $fTeethHeight $aPoints[1][1] = $iY + Sin(($fAngle + 45) * $fDeg) * $fTeethHeight $aPoints[2][0] = $iX + Cos(($fAngle + 135) * $fDeg) * $fTeethHeight $aPoints[2][1] = $iY + Sin(($fAngle + 135) * $fDeg) * $fTeethHeight $aPoints[3][0] = $iX + Cos(($fAngle + 225) * $fDeg) * $fTeethHeight $aPoints[3][1] = $iY + Sin(($fAngle + 225) * $fDeg) * $fTeethHeight $aPoints[4][0] = $iX + Cos(($fAngle + 315) * $fDeg) * $fTeethHeight $aPoints[4][1] = $iY + Sin(($fAngle + 315) * $fDeg) * $fTeethHeight Next _GDIPlus_PathAddPolygon($hPath, $aPoints) $fAngle += $fDeltaAngle Next _GDIPlus_PathWindingModeOutline($hPath) _GDIPlus_PathAddEllipse($hPath, $iW2 - $fRadius_inner, $iH2 - $fRadius_inner, $fRadius_inner * 2, $fRadius_inner * 2) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) _GDIPlus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush_outline) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) Return $hBitmap EndFunc It replaces the gear splash screen. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
marko001 Posted November 3, 2014 Posted November 3, 2014 YOU ARE THE MAN! Works like a charm. So I'll ask you a more difficult thing: what if I would like to use a loading % (or a progress bar)? How can I set from 0% to 100% where 0% is the beginning and 100% is when $mainwindow is released? If possinble using _GDIPlus_StripProgressBar Example1.au3, without background. Thanks again, Marco
UEZ Posted November 3, 2014 Author Posted November 3, 2014 GearsAnim and all others have the possibility to provide some text during animation rendering. That means you can add the percentage of your progress easily to the text. Define a global progress variable and update it. Within PlayAnim function you can use this process variable to display it appropriately. Should be very easy. Regarding the background image: it is just an example and it can be changed very easily. Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
marko001 Posted November 3, 2014 Posted November 3, 2014 Understood, I'll work it out. Thanks again for the great product. M.
mesale0077 Posted November 3, 2014 Posted November 3, 2014 Example of animated Inetget expandcollapse popup;AutoIt v3.3.9.21 or higher needed! #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Math.au3> $_FinalUrl ='http://ftp.opera.com/pub/opera/win/1152/en/Opera_1152_en_Setup.exe' $_TempPath = @ScriptDir & '\Opera_1152_en_Setup.exe' $_FileSize = InetGetSize ( $_FinalUrl ) _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global $iW = 480, $iH = 230 Global $hGui = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0x000000) Global $cPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 20;, $fPower = 0.1 PlayAnim() Exit Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Func PlayAnim() _WinAPI_DeleteObject($hHBmp_BG) $hHBmp_BG = _GDIPlus_DrawingText(0, $iW, $iH,"Downloading..") $hB = GUICtrlSendMsg($cPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) Sleep(200) $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) Local $_InfoData Do $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 105 * $_InetGet ) / $_FileSize ) $hHBmp_BG = _GDIPlus_DrawingText($_DownloadPercent, $iW, $iH,"Downloading..") $hB = GUICtrlSendMsg($cPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) Sleep(200) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) EndIf Until $_InfoData[2] = True Sleep ( 100) _WinAPI_DeleteObject($hHBmp_BG) $hHBmp_BG = _GDIPlus_DrawingText(105, $iW, $iH,"Successfully...") $hB = GUICtrlSendMsg($cPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) Sleep ( 2000 ) EndFunc ;==>PlayAnim Func _GDIPlus_DrawingText($fProgress, $iW, $iH, $sText = "", $iColor = 0xFF00FF33) Local $hBmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 2) _GDIPlus_GraphicsClear($hGfx, 0xFF141414) Local $fCX = $iW * 0.5 Local $fCY = $iH * 0.47 Local Static $tPath = 0, $sTextStore = "" If $sTextStore <> $sText Then $tPath = 0 $sTextStore = $sText EndIf If Not IsDllStruct($tPath) Then Local $hPath_Txt = _GDIPlus_PathCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Impact") Local $tLayout = _GDIPlus_RectFCreate() _GDIPlus_PathAddString($hPath_Txt, $sText, $tLayout, $hFamily, 0, 48, 0) _GDIPlus_FontFamilyDispose($hFamily) Local $aBounds = _GDIPlus_PathGetWorldBounds($hPath_Txt) Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0] - $aBounds[2] * 0.5, -$aBounds[1] - $aBounds[3] * 0.5) _GDIPlus_MatrixTranslate($hMatrix, $fCX, $fCY, True) _GDIPlus_PathTransform($hPath_Txt, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_PathFlatten($hPath_Txt, 0.1) Local $aData = _GDIPlus_PathGetData($hPath_Txt) $aBounds = _GDIPlus_PathGetWorldBounds($hPath_Txt) _GDIPlus_PathDispose($hPath_Txt) Local $fStep = 0.2 Local $iIdx = 0, $fX1, $fY1, $fX2, $fY2, $fX0, $fY0, $fD, $fDX, $fDY Local $aData2[$aData[0][0]][3] = [[0]] For $i = 1 To $aData[0][0] $fX1 = $fX2 $fY1 = $fY2 Select Case $aData[$i][2] = 0 $iIdx += 1 $fX0 = $aData[$i][0] $fY0 = $aData[$i][1] $fX2 = $aData[$i][0] $fY2 = $aData[$i][1] $aData2[$iIdx][0] = $aData[$i][0] $aData2[$iIdx][1] = $aData[$i][1] $aData2[$iIdx][2] = $aData[$i][2] Case Else $fX2 = $aData[$i][0] $fY2 = $aData[$i][1] $fDX = ($fX2 - $fX1) $fDY = ($fY2 - $fY1) $fD = Sqrt($fDX * $fDX + $fDY * $fDY) If $fD > 0 Then For $j = 0 To $fD Step $fStep $iIdx += 1 If $iIdx >= UBound($aData2) Then ReDim $aData2[$iIdx * 2][3] $aData2[$iIdx][0] = $fX1 + $fDX * $j / $fD $aData2[$iIdx][1] = $fY1 + $fDY * $j / $fD $aData2[$iIdx][2] = 1 Next EndIf EndSelect If BitAND($aData[$i][2], 0x80) Then $fX1 = $aData[$i][0] $fY1 = $aData[$i][1] $fX2 = $fX0 $fY2 = $fY0 $fDX = ($fX2 - $fX1) $fDY = ($fY2 - $fY1) $fD = Sqrt($fDX * $fDX + $fDY * $fDY) If $fD > 0 Then For $j = 0 To $fD Step $fStep $iIdx += 1 If $iIdx >= UBound($aData2) Then ReDim $aData2[$iIdx * 2][3] $aData2[$iIdx][0] = $fX1 + $fDX * $j / $fD $aData2[$iIdx][1] = $fY1 + $fDY * $j / $fD $aData2[$iIdx][2] = 1 Next $aData2[$iIdx][2] = 129 EndIf EndIf Next $tPath = DllStructCreate("int Cnt; float Bounds[4]; float Data[" & $iIdx * 2 & "]; byte Type[" & $iIdx & "];") $tPath.Cnt = $iIdx $tPath.Bounds(1) = $aBounds[0] $tPath.Bounds(2) = $aBounds[1] $tPath.Bounds(3) = $aBounds[2] $tPath.Bounds(4) = $aBounds[3] For $i = 0 To $iIdx - 1 $tPath.Data(($i * 2 + 1)) = $aData2[$i + 1][0] $tPath.Data(($i * 2 + 2)) = $aData2[$i + 1][1] $tPath.Type(($i + 1)) = $aData2[$i + 1][2] Next EndIf If Not IsDllStruct($tPath) Then Return $fProgress = $fProgress < 0 ? 0 : ($fProgress > 100 ? 100 : $fProgress) Local $iCnt = Int($tPath.Cnt * $fProgress / 100) If $tPath.Type(($iCnt)) = 0 Then $iCnt += 1 Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePath2", "struct*", DllStructGetPtr($tPath, "Data"), "struct*", DllStructGetPtr($tPath, "Type"), "int", $tPath.Cnt, "int", 0, "handle*", 0) If @error Then Return Local $hPath_Full = $aResult[5] Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePath2", "struct*", DllStructGetPtr($tPath, "Data"), "struct*", DllStructGetPtr($tPath, "Type"), "int", $iCnt, "int", 0, "handle*", 0) If @error Then Return Local $hPath = $aResult[5] Local $hPen = _GDIPlus_PenCreate(0x44FFFFFF, 1) _GDIPlus_GraphicsDrawPath($hGfx, $hPath_Full, $hPen) _GDIPlus_GraphicsDrawRect($hGfx, $tPath.Bounds(1) - 5, $tPath.Bounds(2) + $tPath.Bounds(4) + 5, $tPath.Bounds(3) + 10, 10, $hPen) _GDIPlus_PenSetWidth($hPen, 3) _GDIPlus_PenSetColor($hPen, $iColor) _GDIPlus_GraphicsDrawRect($hGfx, $tPath.Bounds(1) + $tPath.Bounds(3) * $fProgress / 100 - 5, $tPath.Bounds(2) + $tPath.Bounds(4) + 5, 10, 10, $hPen) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Full) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBmp) Return $hHBITMAP EndFunc ;==>_GDIPlus_DrawingText
Jdr Posted May 6, 2016 Posted May 6, 2016 I'm using the 28042014 version of _GDIPlus_Carousel. I know this is a newbie question but I would like to let the animation stop as soon as 2 instances of the same process exist. So eg 2 times calc.exe. I think I can do this with ProcessWait. But where do I put it? My gut feeling says somewhere near: Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Can't figure it out though...
UEZ Posted May 6, 2016 Author Posted May 6, 2016 (edited) @Jdr: you can do something like this here: expandcollapse popup;coded by UEZ build 2014-04-28, idea taken from http://codepen.io/noahblon/pen/KwiFg ;AutoIt v3.3.9.21 or higher needed! #include <Array.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0 Global $iW = 600, $iH = 300 Global Const $hGUI = GUICreate("Carousel", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 10, $iPerc = 0 GUIRegisterMsg($WM_TIMER, "PlayAnim") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0) Global $sProcess = "Notepad.exe", $iDummy = GUICtrlCreateDummy(), $iAmountProcesses = 5 Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iDummy GUIRegisterMsg($WM_TIMER, "") _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch $aPL = ProcessList($sProcess) If IsArray($aPL) Then If $aPL[0][0] > $iAmountProcesses - 1 Then GUICtrlSendToDummy($iDummy) Else $iPerc = $aPL[0][0] / $iAmountProcesses * 100 EndIf EndIf Until False Func PlayAnim() $hHBmp_BG = _GDIPlus_Carousel($iPerc, $iW, $iH) $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) EndFunc ;==>PlayAnim Func _GDIPlus_Carousel($fPerc, $iW, $iH, $bHBitmap = True) Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999)) ;~ _GDIPlus_GraphicsSetTextRenderingHint($hGfx, 3) _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) _GDIPlus_GraphicsClear($hGfx, 0xFFFFFFFF) Local Const $iUB = 4 Local $aColors[$iUB][4] = [[0xD8F4B401, 0xE8CF9902], [0xD8E3746C, 0xE8C1645C], [0xD83A7BF9, 0xE8326AD4], [0xD8109D59, 0xE80E864C]] Local Const $fRadius = 50, $fMid = ($iW - $fRadius) / 2 Local Const $hBrush = _GDIPlus_BrushCreateSolid(), $hPen = _GDIPlus_PenCreate(0x80000000) Local Const $hPath1 = _GDIPlus_PathCreate(), $hPath2 = _GDIPlus_PathCreate() Local $hRegion1, $hRegion2, $fPenSize, $i Local Static $fSpeed For $i = 0 To $iUB - 1 $aColors[$i][2] = -Sin($fSpeed + $i * 1.570796) * 15 ;z coordinate, 1.570796 = Pi/2 = 90° = 360° / 4 $aColors[$i][3] = $fMid + Cos($fSpeed + $i * 1.570796) * 80 ;x coordinate Next _ArraySort($aColors, 0, 0, 0, 2) ;sort z-axis For $i = 0 To $iUB - 1 $fPenSize = $aColors[$i][2] / 20 + 1.1 _GDIPlus_PenSetWidth($hPen, $fPenSize) _GDIPlus_BrushSetSolidColor($hBrush, 0x80E0E0E0) ;shadow color _GDIPlus_GraphicsFillEllipse($hGfx, $aColors[$i][3], ($iH - $fRadius) / 2 + 10 + $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2], ($fRadius + $aColors[$i][2]) / 4, $hBrush) _GDIPlus_PathAddEllipse($hPath1, $aColors[$i][3], ($iH - $fRadius) / 2, $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2]) _GDIPlus_PathAddEllipse($hPath2, $aColors[$i][3] + $fPenSize - 5 - $aColors[$i][2] / 10, ($iH - $fRadius) / 2 - $fPenSize - 5 - $aColors[$i][2] / 10, $fRadius + $aColors[$i][2], $fRadius + $aColors[$i][2]) $hRegion1 = _GDIPlus_RegionCreateFromPath($hPath1) $hRegion2 = _GDIPlus_RegionCreateFromPath($hPath2) _GDIPlus_RegionCombineRegion($hRegion1, $hRegion2, 1) ;combine lighter circle with darker circle _GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i][1]) ;lighter ball color _GDIPlus_GraphicsFillPath($hGfx, $hPath1, $hBrush) _GDIPlus_BrushSetSolidColor($hBrush, $aColors[$i][0]) ;darker ball color _GDIPlus_GraphicsFillRegion($hGfx, $hRegion1, $hBrush) _GDIPlus_GraphicsDrawPath($hGfx, $hPath1, $hPen) ;draw circle frame _GDIPlus_RegionDispose($hRegion1) _GDIPlus_RegionDispose($hRegion2) _GDIPlus_PathReset($hPath1) _GDIPlus_PathReset($hPath2) Next $fSpeed += 0.0261799 Local $iW_Progressbar = $iW / 2 + 4 _GDIPlus_PenSetColor($hPen, 0xD048D1CC) _GDIPlus_GraphicsDrawRect($hGfx, ($iW - $iW_Progressbar) / 2, $iH - 50, $iW_Progressbar, 14, $hPen) _GDIPlus_BrushSetSolidColor($hBrush, 0xFFAFEEEE) _GDIPlus_GraphicsFillRect($hGfx, ($iW - $iW_Progressbar) / 2 + 2, $iH - 48, $fPerc * ($iW_Progressbar - 4) / 100, 10, $hBrush) _GDIPlus_PenSetColor($hPen, 0x20000000) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iW, $iH, $hPen) ;draw window frame _GDIPlus_PathDispose($hPath1) _GDIPlus_PathDispose($hPath2) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) If $bHBitmap Then Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBITMAP EndIf Return $hBitmap EndFunc This will check for Notepad.exe processes. If the amount of processes is more than 5 the animation will be closed. Edited May 6, 2016 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Jdr Posted May 8, 2016 Posted May 8, 2016 One more little thing, or actually 2 I'm using this as a loading screen that covers the desktop during logon. So I need it larger. However if I just change $iW and $iH to 1920 and 1080 the animation scales too. And consumes to many resources. So I changed the "canvas" to 1920 and 1080 and kept the animation at 600 and 300. However I'd also like to change the color of the canvas to a different color than the standard MsgBox light gray. For example white or blue. Couldn't get that to work. A second request would be not to use a fixed resolution of 1920 x 1080 but full screen.
shotiko Posted May 8, 2016 Posted May 8, 2016 Jdr, @DesktopHeight @DesktopWidth should do 2nd trick for you
Jdr Posted May 8, 2016 Posted May 8, 2016 3 hours ago, shotiko said: Jdr, @DesktopHeight @DesktopWidth should do 2nd trick for you Great, works, thanks!
Jdr Posted May 9, 2016 Posted May 9, 2016 I am trying with this code to set the canvas to a different color, eg white: _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0 Global $COLOR_WHITE Global $iW = @DesktopWidth, $iH = @DesktopHeight Global Const $hGUI = GUICreate("Carousel", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) Global Const $iPic = GUICtrlCreatePic("", 400, 350, $iW, $iH) ;Global Const $iPic = GUICtrlCreatePic("", 400, 250, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE)GUISetBkColor($COLOR_WHITE) GUISetState() However GUISetBkColor doesn't seem to work very well, despite color white, it actually gives a black canvas. In fact whatever color I put in, it always gives a black canvas.
UEZ Posted May 9, 2016 Author Posted May 9, 2016 (edited) Global $COLOR_WHITE = 0xFFFFFFF ;you must set the value otherwise $COLOR_WHITE is 0 and thus black Global Const $hGUI = GUICreate("Carousel", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor($COLOR_WHITE) should work to set GUI background white. Edited May 9, 2016 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
DyadyaGenya Posted December 14, 2021 Posted December 14, 2021 Thank you very nice loading screens. But unfortunately I cannot figure out how to use them. I would like several loading screens in one script for different functions: search, copy. I have a window with several buttons, but I don't know how to make your loading screens work with them. If I understand correctly, your loading screens can be connected using #include-once and then used. But what is the right way to do it? Can you see my example and show you how to enable your loading screens? expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> ;#include-once <_GDIPlus_GearsAnim.au3> ;#include-once <_GDIPlus_CogWheels.au3> ;#include-once <_GDIPlus_CloudySpiral.au3> Global $hGUI = GUICreate("Search box", 300, 300) Local $Button_1, $Button_2, $Button_3 GUISetState(@SW_SHOW, $hGUI) $Button_1 = GUICtrlCreateButton("Find file №1", 20, 20, 100, 100) $Button_2 = GUICtrlCreateButton("Find file №2", 20, 140, 100, 100) $Button_3 = GUICtrlCreateButton("Copy file", 140, 20, 100, 100) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button_1 $sPath1 = "D:" $sFileMask1 = "Test1.txt" $aReturn = _FileSearch($sPath1, $sFileMask1) $File1 = $aReturn[1] ConsoleWrite($File1 & @CR) ShellExecute($aReturn[1]) ; While looking for a file, I would like this (_GDIPlus_GearsAnim.au3) loading screen to work. But I don’t know how to do it. Case $Button_2 $sPath2 = "H:" $sFileMask2 = "Test2.txt" $aReturn = _FileSearch($sPath2, $sFileMask2) $File2 = $aReturn[1] ConsoleWrite($File2 & @CR) ShellExecute($File2) ; While looking for a file №2, I would like this (_GDIPlus_CogWheels.au3) loading screen to work. But I don’t know how to do it. Case $Button_3 $sPath2 = "H:" FileCopy($File1, $sPath2) ; While the file is being copied, I would like this (_GDIPlus_CloudySpiral.au3) loading screens to work. But I don’t know how to do it. EndSwitch WEnd Func _FileSearch($sPath, $sFileMask) Local $sOut = StringToBinary("0"& @CRLF, 2), $aOut Local $hDir = Run(@ComSpec & ' /U/C DIR "'& $sPath &'\'& $sFileMask &'" /S/B/A-D', @SystemDir, @SW_HIDE, 6) While 1 $sOut &= StdoutRead($hDir, False, True) If @error Then ExitLoop Wend $aOut = StringRegExp(BinaryToString($sOut,2), "[^\r\n]+", 3) If @error Then Return SetError(1) $aOut[0] = UBound($aOut)-1 Global $IsOrNowFile = $aOut[0] Return $aOut EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now