Jump to content

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

Link to post
Share on other sites
  • Replies 98
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

mesale0077 asked me whether I could code some CSS loading animations from different web sites. These are the results using GDI+ (AutoIt v3.3.12.0+ required!): _GDIPlus_MonochromaticBlinker.au3 / _GD

;coded by UEZ build 2013-08-14 #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172;, $IMAGE_B

Added some more examples and more will follow...  Just look to the 1st post for screenshots and download link. Br, UEZ

Posted Images

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

Link to post
Share on other sites
  • 6 months later...

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

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

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

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
Link to post
Share on other sites
  • 1 year later...

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

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

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. 

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.

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

Link to post
Share on other sites
  • 9 months later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By CYBRIX
      So I am a person who has learned programming off the internet, without structured courses, and I'm trying to create a UI element that can be used like "GUICtrlCreate...".

      I'd like to get some kind of insight on how to improve the code of a Graph element that I have created.
      I am unfamiliar on the standards for creating such UI elements, and assume I'll get some valuable insight here.
       
      Here's some sample code: (I tried to make it look a bit less upsetting to those who know better, but be warned: not pretty.)
      #include <WinAPISys.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> Local $hWnd = GUICreate("Test", 200, 200) GUISetState(@SW_SHOW, $hWnd) Local $hGraph = _GraphStartUp($hWnd, 10, 30, 180, 180) Local $nData, $nDataMax = 1000, $hDataTimer = TimerInit() While GUIGetMsg() <> $GUI_EVENT_ClOSE If TimerDiff($hDataTimer) >= 150 Then $nData = Random(0, $nDataMax) _UpdateGraph($nData) $hDataTimer = TimerInit() EndIf Sleep(20) WEnd _GraphShutDown($hWnd, $hGraph) Exit Func _GraphStartUp($hWnd, $x, $y, $w, $h, $nUpdateTimes = 1000, $nResolution = 60) Global $hBluePen = _WinAPI_CreatePen($PS_SOLID, 2, _WinAPI_RGB(220, 0, 0)) Global $hGreyPen = _WinAPI_CreatePen($PS_DASH, 1, _WinAPI_RGB(100, 100, 100)) Global $hBlackPen = _WinAPI_CreatePen($PS_SOLID, 1, _WinAPI_RGB(0, 0, 0)) Global $hWhitePen = _WinAPI_CreatePen($PS_SOLID, 1, _WinAPI_RGB(255, 255, 255)) Global $nGraphRes = $nResolution Global $aGraphData[$nGraphRes + 1] For $i = 2 To $nGraphRes $aGraphData[$i] = 0 Next Global $hWinDC = _WinAPI_GetWindowDC($hWnd) Global $nGraphX = $x Global $nGraphY = $y Global $nGraphWidth = $w Global $nGraphHeight = $h Global $nGraphXUnit = $nGraphWidth / ($nGraphRes - 1) Global $nGraphBottomY = $nGraphY + $nGraphHeight Global $nGraphMaxX = $nGraphX + $nGraphWidth Global $aUpdateArea[4][2] = [[$nGraphX - 1, $nGraphY - 1], [$nGraphX - 1, $nGraphBottomY + 1], [$nGraphMaxX + 1, $nGraphBottomY + 1], [$nGraphMaxX + 1, $nGraphY - 1]] Global $pUpdateAreaRgn = _WinAPI_CreatePolygonRgn($aUpdateArea) Global $pTextRect = _WinAPI_CreateRectEx($nGraphX + 1, $nGraphY + 1, $nGraphWidth / 2, $nGraphHeight / 4) Global $nGreatestValue = 1 GLobal $pGraphArea = _WinAPI_CreateRectEx($nGraphX - 7, $nGraphY - 26, $nGraphWidth + 14, $nGraphHeight + 2) Global $pDrawCall = DllCallbackRegister('_DrawGraph', 'none', '') Global $pGraphTimer = _WinAPI_SetTimer($hWnd, 567891234, $nUpdateTimes, DllCallbackGetPtr($pDrawCall)) _DrawGraph() Return $pGraphTimer EndFunc Func _DrawGraph() Global $hPen $nGreatestValue = _ArrayMax($aGraphData, 1, 1) $hPen = _WinAPI_SelectObject($hWinDC, $hWhitePen) _WinAPI_PaintRgn($hWinDC, $pUpdateAreaRgn) $hPen = _WinAPI_SelectObject($hWinDC, $hGreyPen) _WinAPI_DrawLine($hWinDC, $nGraphX, $nGraphY, $nGraphMaxX, $nGraphY) _WinAPI_DrawLine($hWinDC, $nGraphX, $nGraphY + ($nGraphHeight / 2), $nGraphMaxX, $nGraphY + ($nGraphHeight / 2)) _WinAPI_DrawLine($hWinDC, $nGraphMaxX, $nGraphY, $nGraphMaxX, $nGraphBottomY) $hPen = _WinAPI_SelectObject($hWinDC, $hBluePen) For $i = 1 To $nGraphRes - 1 _WinAPI_DrawLine($hWinDC, $nGraphX + (($i - 1) * $nGraphXUnit), $nGraphBottomY - ($aGraphData[$i] / $nGreatestValue * $nGraphHeight), $nGraphX + ($i * $nGraphXUnit), $nGraphBottomY - ($aGraphData[$i + 1] / $nGreatestValue * $nGraphHeight)) Next $hPen = _WinAPI_SelectObject($hWinDC, $hBlackPen) _WinAPI_DrawLine($hWinDC, $nGraphX, $nGraphBottomY, $nGraphMaxX, $nGraphBottomY) _WinAPI_DrawLine($hWinDC, $nGraphX, $nGraphY, $nGraphX, $nGraphBottomY) _WinAPI_DrawText($hWinDC, Round($aGraphData[$nGraphRes], 2), $pTextRect, $DT_LEFT) EndFunc Func _UpdateGraph($nData) _ArrayAdd($aGraphData, $nData) _ArrayDelete($aGraphData, 1) EndFunc Func _GraphShutDown($hWnd, $pGraphTimer) _WinAPI_SelectObject($hWinDC, $hPen) _WinAPI_DeleteObject($hBlackPen) _WinAPI_DeleteObject($hGreyPen) _WinAPI_DeleteObject($hBluePen) _WinAPI_DeleteObject($hWhitePen) _WinAPI_ReleaseDC($hWnd, $hWinDC) _WinAPI_KillTimer($hWnd, $pGraphTimer) DllCallbackFree($pDrawCall) _WinAPI_RedrawWindow($hWnd, $pGraphArea) EndFunc  
    • By mLipok
      I check this snippet:
      https://www.autoitscript.com/wiki/Snippets_(_GUI_)#GUI_With_Scrollable_TabItem
      Modified them and I refactored. That's because I needed to adapt it to my needs (I'll write later).
      I thought I understood how it works.
      But I was wrong.
       
      This is my example which is showing what I want to achieve.
      #include <AutoItConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiScrollBars.au3> #include <GUIScrollbars_Ex.au3> #include <StringConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> GUIRegisterMsg($WM_VSCROLL, WM_VSCROLL) _Example() Func _Example() Local $i_Count = 30 Local $a_Options_List[$i_Count + 1] $a_Options_List[0] = $i_Count For $i = 1 To $i_Count $a_Options_List[$i] = 'Test #' & $i Next ConsoleWrite("- " & _my_gui_Wybierz('Testing', $a_Options_List) & @CRLF) EndFunc ;==>_Example Func _my_gui_Wybierz($s_Description, $a_Options_List = "", $i_Left = Default, $i_Top = Default, $i_Width = Default, $hWnd_Parent = 0) ;~ WinSetOnTop($ACROBAT_TITLE, "", $WINDOWS_NOONTOP ) If $i_Left = Default Then $i_Left = -1 If $i_Top = Default Then $i_Top = -1 If $i_Width = Default Then $i_Width = 400 #Region _my_gui_Wybierz - GUI Creation Local $i_Height = 600 Local $hWND_DateForm = GUICreate("", $i_Width, $i_Height, $i_Left, $i_Top, BitOR(0, $WS_SIZEBOX), -1, $hWnd_Parent) WinSetOnTop($hWND_DateForm, "", $WINDOWS_ONTOP) Local $hChild = GUICreate("Scroll area", $i_Width - 15, $i_Height - 40, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $hWND_DateForm) _GUIScrollBars_Init($hChild, -1) _GUIScrollBars_ShowScrollBar($hChild, $SB_HORZ, False) _GUIScrollBars_ShowScrollBar($hChild, $SB_VERT, True) ;~ _GUIScrollBars_SetScrollRange($hChild, $SB_VERT, 3, 30) GUICtrlCreateLabel("", 10, 7, $i_Width - 45, 80) Local $id_Label1 = GUICtrlCreateLabel("", 10, 7 + 5, $i_Width - 45, 80 - 5) GUICtrlSetBkColor(-1, 0x88AABB) Local $a_List_of_Button_ID[$a_Options_List[0] + 1] For $IDX_Item = 1 To $a_Options_List[0] If $IDX_Item > 0 And $IDX_Item < 10 Then $a_List_of_Button_ID[$IDX_Item] = GUICtrlCreateButton( _ $IDX_Item & ". " & $a_Options_List[$IDX_Item], _ 10, 90 + ($IDX_Item - 1) * 21, $i_Width - 45, 20, BitOR($BS_LEFT, $WS_GROUP)) Else $a_List_of_Button_ID[$IDX_Item] = GUICtrlCreateButton( _ Chr(Asc('A') + $IDX_Item - 10) & ". " & $a_Options_List[$IDX_Item], _ 10, 90 + ($IDX_Item - 1) * 21, $i_Width - 45, 20, BitOR($BS_LEFT, $WS_GROUP)) EndIf Next Local $temp_var = $a_Options_List[0] Local $a_accelerators[($temp_var * 2) + 1][2] Local $i_Accelerators_Counter = 0 Local $i_Accelerator_Char1 = '' Local $i_Accelerator_Char2 = '' For $IDX_Item = 1 To $a_Options_List[0] If $IDX_Item > 9 Then $i_Accelerator_Char1 = Chr(Asc('A') + $IDX_Item - 10) $i_Accelerator_Char2 = Chr(Asc('a') + $IDX_Item - 10) Else $i_Accelerator_Char1 = "{NUMPAD" & $IDX_Item & "}" ;Chr(48 + $IDX_Item) $i_Accelerator_Char2 = $IDX_Item EndIf $a_accelerators[($IDX_Item * 2) - 1][0] = $i_Accelerator_Char1 $a_accelerators[($IDX_Item * 2) - 1][1] = $a_List_of_Button_ID[$IDX_Item] $a_accelerators[($IDX_Item * 2) - 1 + 1][0] = $i_Accelerator_Char2 $a_accelerators[($IDX_Item * 2) - 1 + 1][1] = $a_List_of_Button_ID[$IDX_Item] $i_Accelerators_Counter += 2 Next $a_accelerators[0][0] = $i_Accelerators_Counter GUISetAccelerators($a_accelerators, $hChild) GUICtrlSetData($id_Label1, $s_Description) GUISetState(@SW_SHOW, $hWND_DateForm) GUISetState(@SW_SHOW, $hChild) #EndRegion _my_gui_Wybierz - GUI Creation #Region - _my_gui_Wybierz - Handling messages Local $i_Selected_item = 0 Local $v_Return_Value = "" Local $a_GUI_Messages While 1 $a_GUI_Messages = GUIGetMsg($GUI_EVENT_ARRAY) If $a_GUI_Messages[0] = $GUI_EVENT_NONE Then ; do nothing ElseIf $a_GUI_Messages[1] = $hWND_DateForm Then If $a_GUI_Messages[0] = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $a_GUI_Messages[1] <> $hChild Then ; .... Else For $IDX_Check = 1 To $a_Options_List[0] If $a_List_of_Button_ID[$IDX_Check] = $a_GUI_Messages[0] Then $v_Return_Value = GUICtrlRead($a_List_of_Button_ID[$IDX_Check]) $i_Selected_item = $IDX_Check $v_Return_Value = _RegExpFirstMatch($v_Return_Value, '.+?\. (.+)') ExitLoop 2 ; exit from ForNext and also from WhileWend EndIf Next EndIf WEnd #EndRegion - _my_gui_Wybierz - Handling messages GUIDelete($hChild) GUIDelete($hWND_DateForm) Return SetError(0, $i_Selected_item, $v_Return_Value) EndFunc ;==>_my_gui_Wybierz Func WM_VSCROLL($hWnd, $msg, $wParam, $lParam) #forceref $msg, $wParam, $lParam Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Local $index = -1, $yChar, $yPos Local $Min, $Max, $Page, $Pos, $TrackPos For $x = 0 To UBound($aSB_WindowInfo) - 1 If $aSB_WindowInfo[$x][0] = $hWnd Then $index = $x $yChar = $aSB_WindowInfo[$index][3] ExitLoop EndIf Next If $index = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO, "nMin") $Max = DllStructGetData($tSCROLLINFO, "nMax") $Page = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $yPos = DllStructGetData($tSCROLLINFO, "nPos") $Pos = $yPos $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $nScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Min) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $Max) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $TrackPos) EndSwitch ; Set the position and then retrieve it. Due to adjustments ; by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ; If the position has changed, scroll the window and update it $Pos = DllStructGetData($tSCROLLINFO, "nPos") If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos)) $yPos = $Pos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL Func _RegExpFirstMatch($s_Data, $s_Pattern) Local $a_Results = StringRegExp($s_Data, $s_Pattern, $STR_REGEXPARRAYGLOBALMATCH) If @error Then Return SetError(@error, @extended, '') Return SetError(0, UBound($a_Results), $a_Results[0]) EndFunc ;==>_RegExpFirstMatch  
      I have few problems with this code, and many question related to them.
      Question 1:
      How to make the Scrollbars to work ?
      I mean to scroll buttons.
      Question 2:
      Do I must to ues Child Window, or is it possible to scroll buttons without using Child Window ?
      Question 3:
      Why after uncommenting this following line:
      ;~ _GUIScrollBars_SetScrollRange($hChild, $SB_VERT, 3, 30) the ScrollBar disapears ?
    • By Mo0C0w
      Hey guys!
      I just started working with the GUI yesterday and it has only brought more fun to the Autoit adventure  
      Basically I have a GUI windows that opens and based on the selection of the combo box the button will do something different. This specific scenario I am talking about the Client Update Verification  combo selection. When selected and the button is pressed my second gui window opens. As of now if I only paste comp1 or comp2 by itself it works correctly, but if I paste both, it has a fit.
      What would the correct way to do this be? Any help or examples, would be greatly appreciated! Thank you in advance
       
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Client_List.au3> #Region ### START Koda GUI section ### Form=c:\users\dnoble\pictures\plexiibox v4.kxf Global $Form1_1 = GUICreate("Plexii", 336, 419, 1548, 586) GUISetBkColor(0xFFFFFF) Global $Pic1 = GUICtrlCreatePic("C:\Users\dnoble\Pictures\plexii.jpg", 41, 0, 252, 268, BitOR($GUI_SS_DEFAULT_PIC,$SS_CENTERIMAGE)) Global $Label2 = GUICtrlCreateLabel("Select Test", 125, 280, 95, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") Global $Combo2 = GUICtrlCreateCombo("Select Test", 39, 312, 257, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Client Update Verification|Bids") GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Global $Button1 = GUICtrlCreateButton("Proceed", 111, 352, 129, 33) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If GUICtrlRead($Combo2) = "Client Update Verification" Then _Form2() ;clientupdateverification() EndSwitch WEnd Func _Form2() #Region ### START Koda GUI section ### Form=c:\users\dnoble\pictures\plexiiboxclientupdate verification.kxf $Form1_1 = GUICreate("Plexii", 336, 521, 866, 454) GUISetBkColor(0xFFFFFF) $Edit1 = GUICtrlCreateEdit("", 57, 72, 241, 345) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Execute", 95, 440, 145, 41) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If GUICtrlRead($Edit1) = "comp1" Then comp1() If GUICtrlRead($Edit1) = "comp2" Then comp2() EndSwitch WEnd EndFunc  

    • By XGamerGuide
      I'm trying to assign a faint text in the background to an input field that disappears after the input has started. This should have a certain color such as gray.
    • By Bruceway
      Hi All, 
      I am trying to mark out the middle square of this Magnify Routine "window on right" (stolen from M23 - Thanks) - I assume the DllCall is overwriting the boxes. But wherever I try and redraw, they won't stay on the Magnify Window. Can anyone advise, bet way to keep boxes around the middle square.
      Please be kind with my code, it is ripped from a MUCH bigger exe.
      The "half" transparent window, is for dragging to where you want it, and the buttons are for more precise placement.
      #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> Global $hMag_GUI, $hMagDC, $hDeskDC, $hPen, $oObj, $aWinPos[2], $iLast_Mouse_X = 0, $iLast_Mouse_Y = 0 Global $pWindowCaptureX, $pWindowCaptureY Global $pWindowMagWinX, $pWindowMagWinY #Region - GUI3 ; *** Grabber/Picker Window Global $hGUI3 = GUICreate("Capture", 150, 150, $pWindowCaptureX, $pWindowCaptureY, $WS_EX_TOOLWINDOW) Global $Pic1 = GUICtrlCreatePic("", 70, 40, 10, 10, BitOR($GUI_SS_DEFAULT_PIC,$WS_BORDER)) Global $hButtonUp = GUICtrlCreateButton("U", 65, 60, 20, 20) Global $hButtonDown = GUICtrlCreateButton("D", 65, 100, 20, 20) Global $hButtonLeft = GUICtrlCreateButton("L", 40, 80, 20, 20) Global $hButtonRight = GUICtrlCreateButton("R", 90, 80, 20, 20) Global $hButtonOK = GUICtrlCreateButton("OK", 60, 80, 30, 20) #EndRegion - GUI3 #Region - GUI4 Global $hGUI4 = GUICreate("MagWin", 250, 250, 325, 195) Global $hButtonMOK = GUICtrlCreateButton("OK", 45, 140, 30, 20) Global $hButtonMUp = GUICtrlCreateButton("U", 50, 120, 20, 20) Global $hButtonMDown = GUICtrlCreateButton("D", 50, 160, 20, 20) Global $hButtonMLeft = GUICtrlCreateButton("L", 25, 140, 20, 20) Global $hButtonMRight = GUICtrlCreateButton("R", 75, 140, 20, 20) Global $hLabelWindow = GUICtrlCreateLabel("Window", 5, 185, 44, 15) Global $hLabelWindowText = GUICtrlCreateLabel("", 60, 185, 176, 15) Global $hLabelCheck = GUICtrlCreateLabel("Check", 5, 205, 44, 15) Global $hLabelCheckText = GUICtrlCreateLabel("", 60, 205, 176, 15) Global $hLabelScreen = GUICtrlCreateLabel("Screen", 5, 225, 44, 15) Global $hLabelScreenText = GUICtrlCreateLabel("", 60, 225, 176, 15) #EndRegion - GUI4 ;GUISetState(@SW_HIDE, $hGUI1) GUISetState(@SW_SHOW, $hGUI3) GUISetState(@SW_SHOW, $hGUI4) WinSetTrans($hGUI3, "", 100) $hMag_GUI = WinGetHandle("MagWin") ; Get device context for Mag GUI $hMagDC = _WinAPI_GetDC($hMag_GUI) If @error Then Exit ; Get device context for desktop $hDeskDC = _WinAPI_GetDC(0) If @error Then _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) Exit EndIf ; Create pen $hPen = _WinAPI_CreatePen($PS_SOLID, 5, 0x7E7E7E) $oObj = _WinAPI_SelectObject($hMagDC, $hPen) ; Loop until the user exits. ; *** Static Window While 1 ; Reset position Local $aWinPos = WinGetPos("Capture") If $aWinPos[0] <> $iLast_Mouse_X Or $aWinPos[1] <> $iLast_Mouse_Y Then ; Redraw Mag GUI _FOEA_Loupe($aWinPos) ;~ Local $TWPx = $aWinPos[0]+81 ;+81 Top Left Corner; +85 Middle ;~ Local $TWPy = $aWinPos[1]+75 ;+75 Top Left Corner; +80 Middle ;~ ;*** WINDOW COORDS = x+81 & y+75 (top left of picker square) GUISetState(@SW_HIDE, $hGUI3) Local $output1 = PixelCheckSum($aWinPos[0]+81, $aWinPos[1]+75, $aWinPos[0]+91, $aWinPos[1]+85) Local $output2 = PixelCheckSum($aWinPos[0]+73, $aWinPos[1]+66, $aWinPos[0]+83, $aWinPos[1]+76) If $aWinPos[0] < 1440 Then GUICtrlSetData($hLabelWindowText, $aWinPos[0]+81 & "(" & $aWinPos[0]+81+1440 &")," & $aWinPos[1]+75 & " : " & $output1) GUICtrlSetData($hLabelCheckText, $aWinPos[0]+73 & "(" & $aWinPos[0]+73+1440 & ")," & $aWinPos[1]+66 & " : " & $output2) GUICtrlSetData($hLabelScreenText, "W: " & $aWinPos[0]+73 & "(" & $aWinPos[0]+73+1440 &")," & $aWinPos[1]+66 & " C: " & $aWinPos[0]+81 & "," & $aWinPos[1]+75) Else GUICtrlSetData($hLabelWindowText, $aWinPos[0]+81-1440 & "(" & $aWinPos[0]+81 &")," & $aWinPos[1]+75 & " : " & $output1) GUICtrlSetData($hLabelCheckText, $aWinPos[0]+89-1440 & "(" & $aWinPos[0]+89 &")," & $aWinPos[1]+84 & " : " & $output2) GUICtrlSetData($hLabelScreenText, "W: " & $aWinPos[0]+73-1440 & "(" & $aWinPos[0]+73 & ")," & $aWinPos[1]+66 & " C: " & $aWinPos[0]+81 & "," & $aWinPos[1]+75) ;GUICtrlSetData($hLabel2, $aWinPos[1]+75) EndIf GUISetState(@SW_SHOW, $hGUI3) $iLast_Mouse_X = $aWinPos[0] $iLast_Mouse_Y = $aWinPos[1] $pWindowCaptureX = $aWinPos[0] $pWindowCaptureY = $aWinPos[1] ; *** Box ; Tried it here - doesn't work ;~ Global $Graphic = GUICtrlCreateGraphic(176, 55, 2, 20) ;~ Global $Graphic = GUICtrlCreateGraphic(194, 55, 2, 20) ;~ Global $Graphic = GUICtrlCreateGraphic(176, 55, 20, 2) ;~ Global $Graphic = GUICtrlCreateGraphic(176, 73, 20, 2) ;~ Global $Graphic = GUICtrlCreateGraphic(0, 0, 1, 1) EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Local $aWinPos = WinGetPos("MagWin") $pWindowMagWinX = $aWinPos[0] $pWindowMagWinY = $aWinPos[1] ;GUISetState(@SW_HIDE, $hGUI3) GUIDelete($hGUI3) ; Clear up Mag GUI _WinAPI_SelectObject($hMagDC, $oObj) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDeskDC) _WinAPI_ReleaseDC($hMag_GUI, $hMagDC) ;GUISetState(@SW_HIDE, $hMag_G GUIDelete($hGUI4) GUIDelete($hMag_GUI) ExitLoop Case $hButtonMOK GUISetState(@SW_HIDE, $hGUI3) Local $aWinPos = WinGetPos("Capture") Local $TWPx = $aWinPos[0]+81 ;+81 Top Left Corner; +85 Middle Local $TWPy = $aWinPos[1]+75 ;+75 Top Left Corner; +80 Middle ;*** WINDOW COORDS = x+81 & y+75 (top left of picker square) If $aWinPos[0] > 1440 Then $aWinPos[0] = $aWinPos[0]-1440 $TWPx = $TWPx-1440 EndIf Local $output0 = PixelCheckSum($TWPx-8, $TWPy-9, $TWPx-8+10, $TWPy+1) ;_FOEA_WinAPI_DrawRect(LRChecksum($TWPx-8), $TWPy-9, LRChecksum($TWPx-8)+10, $TWPy+1, 0xFFFFFF, 50) MsgBox($MB_SYSTEMMODAL, "Results ", _ "Window Coords" & @CRLF & _ $TWPx & "(" & $TWPx+1440 & "), " & $TWPy & @CRLF & _ "Checksum0: " & $output0 & @CRLF) GUISetState(@SW_SHOW, $hGUI3) WinActivate($hGUI3, "Capture") Case $hButtonMUp _FOEA_ButtonMUp() Case $hButtonMDown _FOEA_ButtonMDown() Case $hButtonMRight _FOEA_ButtonMRight() Case $hButtonMLeft _FOEA_ButtonMLeft() EndSwitch WEnd Func _FOEA_Loupe($aWinPos) Local $iX, $iY DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $hMagDC, "int", 10, "int", 10, "int", 110, "int", 110, _ "int", $hDeskDC, "int", $aWinPos[0]+68, "int", $aWinPos[1]+61, "int", 20, "int", 20, _ "long", $SRCCOPY) DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $hMagDC, "int", 130, "int", 10, "int", 110, "int", 110, _ "int", $hDeskDC, "int", $aWinPos[0]+70, "int", $aWinPos[1]+63, "int", 7, "int", 7, _ "long", $SRCCOPY) ; Appears initially - then disappears... Global $Graph1 = GUICtrlCreateGraphic(170, 57, 8, 16, $SS_WHITERECT) Global $Graph2 = GUICtrlCreateGraphic(170, 73, 31, 8, $SS_WHITERECT) Global $Graph3 = GUICtrlCreateGraphic(193, 57, 8, 16, $SS_WHITERECT) Global $Graph4 = GUICtrlCreateGraphic(170, 49, 31, 8, $SS_WHITERECT) ; This apears to be needed to stop the Magnify window moving Global $Graph5 = GUICtrlCreateGraphic(0, 0, 1, 1) ;Tried this too - no difference GUISetState(@SW_SHOW, $Graph1) GUISetState(@SW_SHOW, $Graph2) GUISetState(@SW_SHOW, $Graph3) GUISetState(@SW_SHOW, $Graph4) EndFunc ;==>Loupe Func _FOEA_ButtonMUp() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0], $aWinPos[1]-1) EndFunc Func _FOEA_ButtonMDown() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0], $aWinPos[1]+1) EndFunc Func _FOEA_ButtonMRight() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0]+1, $aWinPos[1]) EndFunc Func _FOEA_ButtonMLeft() Local $aWinPos = WinGetPos("Capture") WinMove($hGUI3, "Capture", $aWinPos[0]-1, $aWinPos[1]) EndFunc  
×
×
  • Create New...