Jump to content
Sign in to follow this  
UEZ

GDI+ animated loading screens build 2014-06-20 (32 examples)

Recommended Posts

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 :-(

Share this post


Link to post
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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

[...]
#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 by marko001

Share this post


Link to post
Share on other sites

Try something like this here:

[...]
#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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Example of animated Inetget
 

;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

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

@Jdr: you can do something like this here:

;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 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites
3 hours ago, shotiko said:

Jdr,

@DesktopHeight @DesktopWidth should do 2nd trick for you

Great, works, thanks!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

 

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 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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By UEZ
      This project has been discontinued!
       
      Here a small tool I wrote to update my Sysinternal tools collection without the need to download always the whole package or visiting the site to check for updates. I know that there are several tools available (also some tools written in AutoIt) but here another one for the collection. It was good exercise for me to code it.
       
       
        
       
       
      Some files from cannot be downloaded although they are visible on the web site!
       
      Here the download link of the source code only:  AutoIt Sysinternal Tools Synchronizer v0.99.6 build 2020-09-21 beta.7z (1548 downloads previously)
      -=> Requires AutoIt version 3.3.13.20 or higher / tested on Win8.1 real machine and some VMs: Win7 / Vista / Win10
       
      Compiled exe only: @MediaFire
       
      Just select the Sysinternal Tools folder or create one and press the synchronize button to download the selected items. Click on AutoIt label (near to left upper corner) to open menu.
       
      Special thanks to LarsJ, Melba23 and mesale0077 for their help. 
       
      I've still some ideas to implement which are more gimmick related, so it is not finished yet...
      If you want to add your language please check out #Region Language. Thanks. 
       
      Please report any bug or if you have any suggestions.
       
      The language of the tool tip from each of the executable in the left list view were automatically created using Google translator and weren't checked for correctness.
       
      Br,
      UEZ
    • By TXTechie
      Hello Everyone,
      I've developed my own GUI using AutoIt and I'm allowing users to minimize the GUI, but I also want to include some kind of timer so that it will automatically restore the GUI after something like 30 minutes or an hour. However, I also want them to be able to manually restore the GUI by clicking the application's icon in the taskbar.
      I've searched through the forums, but I'm not sure how to get started.
      Any ideas or functions to research are appreciated!
      Regards,
      TX Techie
    • By UEZ
      Here another example to mark the desktop to get the marked region for capturing. This example is not perfect and not very fast (room for improvements).
      ;Coded by UEZ build 2020-08-07 beta ;Code cleanup up mLipok ; ;Short instruction: mark area on your desktop and press return key to capture. #include <APISysConstants.au3> #include <Array.au3> ;#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> ; enum _PROCESS_DPI_AWARENESS -> https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx Global Enum $DPI_AWARENESS_INVALID = -1, $PROCESS_DPI_UNAWARE = 0, $PROCESS_SYSTEM_DPI_AWARE, $PROCESS_PER_MONITOR_DPI_AWARE ;https://docs.microsoft.com/en-us/windows/desktop/hidpi/dpi-awareness-context Global Enum $Context_UnawareGdiScaled = -5, $Context_PerMonitorAwareV2, $Context_PerMonitorAware, $Context_SystemAware, $Context_Unaware _WinAPI_SetProcessDpiAwarenessContext($Context_PerMonitorAware) Global $__g_hGUI_MarkArea, $__g_hGUI_Bg, $__g_iLabel_TL, $__g_iLabel_TM, $__g_iLabel_TR, $__g_iLabel_LM, $__g_iLabel_RM, $__g_iLabel_BL, $__g_iLabel_BM, _ $__g_iLabel_BR, $__g_iOldCursor, $__g_iW, $__g_iH, $__g_iColor_ResizeDots = 0xFFFFFF, $__g_iBorder = 4, $__g_bSelectionDone = False Global $aRect = _GDIPlus_MarkScreenRegionAnimated() Global $hImage_Capture = _ScreenCapture_Capture(@TempDir & "\Test.png", $aRect[0], $aRect[1], $aRect[0] + $aRect[2] - 1, $aRect[1] + $aRect[3] - 1, False) ShellExecute(@TempDir & "\Test.png") ;_ArrayDisplay($aRect, "Marked area coordinates") Func _GDIPlus_MarkScreenRegionAnimated($bAnim = True) _GDIPlus_Startup() Local Const $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Local Const $aFullScreen = WinGetPos($hFullScreen) $__g_hGUI_Bg = GUICreate("", $aFullScreen[2], $aFullScreen[3], $aFullScreen[0], $aFullScreen[1], BitOR($WS_CLIPCHILDREN, $WS_POPUP), $WS_EX_TOPMOST) ;to avoid cursor flickering and for proper control read WinSetTrans($__g_hGUI_Bg, "", 0x01) $__g_hGUI_MarkArea = GUICreate("", 1, 1, -1, -1, $bAnim ? $WS_POPUP : BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED), $__g_hGUI_Bg) GUISetBkColor(0xABCDEF, $__g_hGUI_MarkArea) If Not $bAnim Then $__g_iColor_ResizeDots = 0xFF0000 $__g_iLabel_TL = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;top left GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_TM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;top mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_TR = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;top right GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_LM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;left mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_RM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;right mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_BL = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;bottom left GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_BM = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;bottom mid GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) $__g_iLabel_BR = GUICtrlCreateLabel("", 0, 0, $__g_iBorder, $__g_iBorder) ;bottom right GUICtrlSetResizing(-1, $GUI_DOCKSIZE) GUICtrlSetBkColor(-1, $__g_iColor_ResizeDots) GUISetState(@SW_SHOWNA, $__g_hGUI_Bg) GUISetState(@SW_SHOW, $__g_hGUI_MarkArea) $__g_iOldCursor = MouseGetCursor() GUISetCursor(3, 1, $__g_hGUI_Bg) GUISetCursor(3, 1, $__g_hGUI_MarkArea) _WinAPI_SetLayeredWindowAttributes($__g_hGUI_MarkArea, 0xABCDEF, 0xF0) Local $aMPos, $aPrevMPos[2] = [MouseGetPos(0) + 1, MouseGetPos(1) + 1], $iID, $aCI, $iX, $iY, $aOldWinPos, $aOldMPos, $bMoved Local $aGUIStartPos, $iKey_Exit = GUICtrlCreateButton("", $aFullScreen[0] - 10, $aFullScreen[1] - 10, 1, 1), $aAccelKeys[1][2] = [["{ENTER}", $iKey_Exit]] GUISetAccelerators($aAccelKeys, $__g_hGUI_Bg) GUISetAccelerators($aAccelKeys, $__g_hGUI_MarkArea) #forceref $bMoved Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $iKey_Exit If $bAnim Then GUIRegisterMsg($WM_TIMER, "") DllCall("user32.dll", "bool", "KillTimer", "hwnd", $__g_hGUI_MarkArea, "uint_ptr", $iID) GUIRegisterMsg($WM_ERASEBKGND, "") EndIf _GDIPlus_Shutdown() Local $aResult = WinGetPos($__g_hGUI_MarkArea) $aResult[2] = WinGetClientSize($__g_hGUI_MarkArea)[0] $aResult[3] = WinGetClientSize($__g_hGUI_MarkArea)[1] GUIDelete($__g_hGUI_MarkArea) GUIDelete($__g_hGUI_Bg) If Not $__g_bSelectionDone Then $aResult = 0 Return $aResult EndSwitch $aMPos = MouseGetPos() If ($aMPos[0] <> $aPrevMPos[0] Or $aMPos[1] <> $aPrevMPos[1]) And (Not $__g_bSelectionDone) Then WinMove($__g_hGUI_MarkArea, "", $aMPos[0], $aMPos[1]) $aPrevMPos = $aMPos EndIf $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) If $aCI[2] And (Not $__g_bSelectionDone) Then $aGUIStartPos = WinGetPos($__g_hGUI_MarkArea) If $bAnim Then GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND") GUIRegisterMsg($WM_TIMER, "PlayBorderAnim") $iID = DllCall("User32.dll", "uint_ptr", "SetTimer", "hwnd", $__g_hGUI_MarkArea, "uint_ptr", 1, "uint", 50, "ptr", 0)[0] EndIf While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) $aMPos = MouseGetPos() $__g_iW = Abs($aMPos[0] - $aGUIStartPos[0]) + 1 $__g_iH = Abs($aMPos[1] - $aGUIStartPos[1]) + 1 If $aMPos[0] < $aGUIStartPos[0] Then $iX = $aMPos[0] Else $iX = $aGUIStartPos[0] EndIf If $aMPos[1] < $aGUIStartPos[1] Then $iY = $aMPos[1] Else $iY = $aGUIStartPos[1] EndIf WinMove($__g_hGUI_MarkArea, "", $iX, $iY, $__g_iW, $__g_iH) UpdateCtrlPos($bAnim) WEnd $__g_bSelectionDone = True GUISetCursor(3, 1, $__g_hGUI_MarkArea) ElseIf $aCI[3] And $__g_bSelectionDone Then $aGUIStartPos = WinGetPos($__g_hGUI_MarkArea) If _WinAPI_PtInRectEx(MouseGetPos(0), MouseGetPos(1), $aGUIStartPos[0], $aGUIStartPos[1], $aGUIStartPos[0] + $aGUIStartPos[2], $aGUIStartPos[1] + $aGUIStartPos[3]) Then $aMPos = MouseGetPos() $aGUIStartPos = WinGetPos($__g_hGUI_MarkArea) While $aCI[3] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", $aGUIStartPos[0] - ($aMPos[0] - MouseGetPos(0)), $aGUIStartPos[1] - ($aMPos[1] - MouseGetPos(1)), $__g_iW, $__g_iH) GUISetCursor(0, 1, $__g_hGUI_Bg) GUISetCursor(0, 1, $__g_hGUI_MarkArea) WEnd GUISetCursor(3, 1, $__g_hGUI_Bg) GUISetCursor(3, 1, $__g_hGUI_MarkArea) EndIf EndIf If $__g_bSelectionDone Then $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) If @error Then ContinueLoop Switch $aCI[4] Case $__g_iLabel_TL GUISetCursor(12, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", MouseGetPos(0), MouseGetPos(1), $aOldWinPos[2] + ($aOldMPos[0] - MouseGetPos(0)), $aOldWinPos[3] + ($aOldMPos[1] - MouseGetPos(1))) WEnd UpdateCtrlPos($bAnim) EndIf Case $__g_iLabel_BR GUISetCursor(12, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", $aOldWinPos[0], $aOldWinPos[1], $aOldWinPos[2] - ($aOldMPos[0] - MouseGetPos(0)), $aOldWinPos[3] - ($aOldMPos[1] - MouseGetPos(1))) WEnd UpdateCtrlPos($bAnim) EndIf Case $__g_iLabel_TR GUISetCursor(10, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", $aOldWinPos[0], MouseGetPos(1), $aOldWinPos[2] - ($aOldMPos[0] - MouseGetPos(0)), $aOldWinPos[3] + ($aOldMPos[1] - MouseGetPos(1))) WEnd UpdateCtrlPos($bAnim) EndIf Case $__g_iLabel_BL GUISetCursor(10, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", MouseGetPos(0), $aOldWinPos[1], $aOldWinPos[2] + ($aOldMPos[0] - MouseGetPos(0)), $aOldWinPos[3] - ($aOldMPos[1] - MouseGetPos(1))) WEnd UpdateCtrlPos($bAnim) EndIf Case $__g_iLabel_LM GUISetCursor(13, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", MouseGetPos(0), $aOldWinPos[1], $aOldWinPos[2] + ($aOldMPos[0] - MouseGetPos(0)), $aOldWinPos[3]) WEnd UpdateCtrlPos($bAnim) EndIf Case $__g_iLabel_RM GUISetCursor(13, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", $aOldWinPos[0], $aOldWinPos[1], $aOldWinPos[2] - ($aOldMPos[0] - MouseGetPos(0)), $aOldWinPos[3]) WEnd UpdateCtrlPos($bAnim) EndIf Case $__g_iLabel_TM GUISetCursor(11, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", $aOldWinPos[0], MouseGetPos(1), $aOldWinPos[2], $aOldWinPos[3] + ($aOldMPos[1] - MouseGetPos(1))) WEnd UpdateCtrlPos($bAnim) EndIf Case $__g_iLabel_BM GUISetCursor(11, 1, $__g_hGUI_MarkArea) If $aCI[2] Then $aOldWinPos = WinGetPos($__g_hGUI_MarkArea) $aOldMPos = MouseGetPos() While $aCI[2] * Sleep(10) $aCI = GUIGetCursorInfo($__g_hGUI_MarkArea) WinMove($__g_hGUI_MarkArea, "", $aOldWinPos[0], $aOldWinPos[1], $aOldWinPos[2], $aOldWinPos[3] - ($aOldMPos[1] - MouseGetPos(1))) WEnd UpdateCtrlPos($bAnim) EndIf Case Else GUISetCursor(3, 1, $__g_hGUI_MarkArea) EndSwitch EndIf Until False EndFunc ;==>_GDIPlus_MarkScreenRegionAnimated Func UpdateCtrlPos($bAnim = True) Local Const $aGUIStartPos = WinGetPos($__g_hGUI_MarkArea) If $__g_bSelectionDone And $bAnim Then GUIRegisterMsg($WM_TIMER, "") $__g_iW = $aGUIStartPos[2] $__g_iH = $aGUIStartPos[3] ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_TL, 0, 0, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_TM, ($__g_iW - $__g_iBorder) / 2, 0, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_TR, ($__g_iW - $__g_iBorder - $__g_iBorder / 2), 0, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_LM, 0, ($__g_iH - $__g_iBorder) / 2, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_RM, ($__g_iW - $__g_iBorder - $__g_iBorder / 2), ($__g_iH - $__g_iBorder) / 2, $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_BL, 0, ($__g_iH - $__g_iBorder - $__g_iBorder / 2), $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_BM, ($__g_iW - $__g_iBorder) / 2, ($__g_iH - $__g_iBorder - $__g_iBorder / 2), $__g_iBorder, $__g_iBorder) ControlMove($__g_hGUI_MarkArea, "", $__g_iLabel_BR, ($__g_iW - $__g_iBorder - $__g_iBorder / 2), ($__g_iH - $__g_iBorder - $__g_iBorder / 2), $__g_iBorder, $__g_iBorder) If $__g_bSelectionDone And $bAnim Then GUIRegisterMsg($WM_TIMER, "PlayBorderAnim") EndFunc ;==>UpdateCtrlPos Func PlayBorderAnim() Local $aWinPos = WinGetClientSize($__g_hGUI_MarkArea), $iW = $aWinPos[0], $iH = $aWinPos[1] Local Static $fOffset = 0 Local Const $iSize = $__g_iBorder / 2 Local Const $hDC = _WinAPI_GetDC($__g_hGUI_MarkArea) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) Local Const $hPen = _GDIPlus_PenCreate(0xFF0178D7, $iSize), $hPen2 = _GDIPlus_PenCreate(0xFFFFFFFF, $iSize), _ $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $__g_iColor_ResizeDots), $hPen3 = _GDIPlus_PenCreate(0xFF000000) _GDIPlus_PenSetDashStyle($hPen, $GDIP_DASHSTYLEDASHDOT) _GDIPlus_GraphicsClear($hCanvas, 0xFFABCDEF) ;for faster performance direct dll calls DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen2, "float", 1 + $iSize, "float", 1 + $iSize, "float", $iW - 2 * $iSize - 2, "float", $iH - 2 * $iSize - 2) DllCall($__g_hGDIPDll, "int", "GdipSetPenDashOffset", "handle", $hPen, "float", $fOffset) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen, "float", 1 + $iSize, "float", 1 + $iSize, "float", $iW - 2 * $iSize - 2, "float", $iH - 2 * $iSize - 2) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", 0, "float", 0, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", 0, "float", 0, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", ($iW - $__g_iBorder) / 2, "float", 0, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", ($iW - $__g_iBorder) / 2, "float", 0, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", ($iW - $__g_iBorder) - 2, "float", 0, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", ($iW - $__g_iBorder) - 2, "float", 0, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", 0, "float", ($iH - $__g_iBorder) / 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", 0, "float", ($iH - $__g_iBorder) / 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", ($iW - $__g_iBorder) - 2, "float", ($iH - $__g_iBorder) / 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", ($iW - $__g_iBorder) - 2, "float", ($iH - $__g_iBorder) / 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", 0, "float", ($iH - $__g_iBorder) - 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", 0, "float", ($iH - $__g_iBorder) - 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", ($iW - $__g_iBorder) / 2, "float", ($iH - $__g_iBorder) - 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", ($iW - $__g_iBorder) / 2, "float", ($iH - $__g_iBorder) - 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush, "float", ($iW - $__g_iBorder) - 2, "float", ($iH - $__g_iBorder) - 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) DllCall($__g_hGDIPDll, "int", "GdipDrawRectangle", "handle", $hCanvas, "handle", $hPen3, "float", ($iW - $__g_iBorder) - 2, "float", ($iH - $__g_iBorder) - 2, "float", $__g_iBorder + 1, "float", $__g_iBorder + 1) _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_backbuffer, 0, 0, $SRCCOPY) $fOffset += 0.5 _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($__g_hGUI_MarkArea, $hDC) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_PenDispose($hPen3) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>PlayBorderAnim Func WM_ERASEBKGND($hWnd, $iMsgm, $wParam, $lParam) ;suppress repainting to avoid flickering but causes some other side effects #forceref $iMsgm, $wParam, $lParam, $hWnd Local Const $hBrush = _WinAPI_CreateSolidBrush(0xEFCDAB) ;BGR format ;~ _WinAPI_RedrawWindow($__g_hGUI_MarkArea, 0, 0, BitOR($RDW_NOERASE, $RDW_NOCHILDREN, $RDW_NOFRAME, $RDW_VALIDATE)) _WinAPI_SetClassLongEx($__g_hGUI_MarkArea, $GCL_HBRBACKGROUND, $hBrush) _WinAPI_DeleteObject($hBrush) Return 0 EndFunc ;==>WM_ERASEBKGND ;https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setprocessdpiawarenesscontext Func _WinAPI_SetProcessDpiAwarenessContext($DPIAwareContext = $Context_PerMonitorAware, $hGUI = 0, $iMode = 3) ;https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setprocessdpiawarenesscontext $DPIAwareContext = ($DPIAwareContext < -5) ? -5 : ($DPIAwareContext > -1) ? -1 : $DPIAwareContext $iMode = ($iMode < 1) ? 1 : ($iMode > 3) ? 3 : $iMode Switch $iMode Case 1 Local $hDC = _WinAPI_GetDC($hGUI) Local $aResult1 = DllCall("user32.dll", "ptr", "GetDpiFromDpiAwarenessContext", "ptr", $hDC) If @error Or Not IsArray($aResult1) Then Return SetError(11, 0, 0) _WinAPI_ReleaseDC(0, $hDC) Local $aResult = DllCall("user32.dll", "Bool", "SetProcessDpiAwarenessContext", "int", $aResult1[0] + $DPIAwareContext) If @error Or Not IsArray($aResult) Then Return SetError(12, 0, 0) Case 2 ;~ If Not $hGUI Then $hGUI = WinGetHandle(AutoItWinGetTitle()) Local $aResult2 = DllCall("user32.dll", "int", "GetWindowDpiAwarenessContext", "ptr", $hGUI) If @error Or Not IsArray($aResult2) Then Return SetError(21, 0, 0) Local $aResult = DllCall("user32.dll", "Bool", "SetProcessDpiAwarenessContext", "int", $aResult2[0] + $DPIAwareContext) If @error Or Not IsArray($aResult) Then Return SetError(22, 0, 0) Case 3 Local $aResult31 = DllCall("user32.dll", "ptr", "GetThreadDpiAwarenessContext") If @error Or Not IsArray($aResult31) Then Return SetError(31, 0, 0) Local $aResult32 = DllCall("user32.dll", "ptr", "GetAwarenessFromDpiAwarenessContext", "ptr", $aResult31[0]) If @error Or Not IsArray($aResult32) Then Return SetError(32, 0, 0) Local $aResult = DllCall("user32.dll", "Bool", "SetThreadDpiAwarenessContext", "int", $aResult32[0] + $DPIAwareContext) If @error Or Not IsArray($aResult) Then Return SetError(33, 0, 0) EndSwitch Return 1 EndFunc ;==>_WinAPI_SetProcessDpiAwarenessContext  
      Just press the lmb and move your mouse. When lmb is released you can adjust the size of the window by dragging the white rectangle to any direction. Rmb will move the marked area.
      Press ESC to get the coordinates of the marked region.
      If you have any improvements, please post it here.
       
      Tested on Win10 x64 only.
       
    • By Rskm
      Hi, recently i created a GUI for some calculations in AutoIT.  The GUI has 2 tabs and on the first tab, it has few inputboxes where i use to click with mouse and start entering the inputs. i recently made some changes in the position of these textboxes. I made this by changing the autoit code file instead of making changes in KODA. Now i cannot click inside these textboxes with mouse. However, i can use TAB key to cycle through/enter input in these input boxes. what could have made the inputboxes not responding to mouseclicks. thanks
    • By TheDcoder
      Hi everyone,
      I am bit stumped as to why I am not able to set the time in the Date control
      #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("My GUI get date", 200, 200, 800, 200) Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20, $DTS_TIMEFORMAT) ; to select a specific default format Local $sStyle = "HH:mm:ss" GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle) ; Set time Local $iRet = GUICtrlSetData($idDate, '13:33:37') ConsoleWrite('GUICtrlSetData returned ' & ($iRet = 1 ? 'success' : 'failure') & @CRLF) GUISetState(@SW_SHOW) ; Loop until the user exits. While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate)) EndFunc ;==>Example The documentation for GUICtrlSetData clearly mentions that it uses the same format as GUICtrlRead:
      But I get failure
      What gives?
      Thanks for the help in advance!
×
×
  • Create New...