dynamitemedia

Help with updating lablel

17 posts in this topic

I am using this code to do a basic thumbnail loading counter...  

what i want to do is change the count each time without changing everything else, i think  just the number count flashing would be better than the whole thing flashing. i tried it with the whole label inside the loop but it flashed too much

so i was thinking of just put a label over the top of the blank area...   if its in triple digits it flashes horribly weird when gets to double digits, and then on single digits

and i want to have it do its more like finding the position of where to place label on top of the other label , i know this needs cleaning up a ton but here is what i have which is semi working
 

#include "GUIScrollbars_Ex.au3"
#include <Skin.au3>
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <Process.au3>
#include <Constants.au3>
#include <String.au3>
#include <Date.au3>
#include <GDIplus.au3>
#include <GuiButton.au3>
#Include "Curl.au3"
#include "GUIScrollbars_Ex.au3"
#include <Skin.au3>
#include <GuiButton.au3>
#include <GuiListView.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WinAPIGdi.au3>
#include "StringSize.au3"


Global $iDialog_Width = 1280
Global $iDialog_Depth = 720
Global $blueness = 0xff0066ff

$thumbCount = 110
$folder = "testing"

$hDialog = GUICreate("", $iDialog_Width, $iDialog_Depth, -1, -1)
GUISetState()

_GDIPlus_Startup() ;initialize GDI+
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hDialog)
_GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
Local $hPen = _GDIPlus_PenCreate($blueness, 6)

; Get the size of label needed to hold the text
$aRet = _StringSize("Both vertically" & @CRLF & "and horizontally centered", 30)
$iX = ($iDialog_Width - $aRet[2]) / 2
$iY = ($iDialog_Depth - $aRet[3]) / 2
_GDIPlus_GraphicsDrawRect($hGraphics, $iX - 30, $iY - 30, $aRet[2] + 60, $aRet[3] + 60, $hPen)


$thumbLength = StringLen($thumbCount)

$string2add = "Loading " & "     " & " thumbnail(s) from " & $folder
$paddLblDate = GUICtrlCreateLabel($string2add, $iX, $iY, $aRet[2], $aRet[3], $SS_CENTER)

ConsoleWrite("label Left position : "  & $iX  & @CRLF)

Local $countPosition = StringInStr($string2add, $thumbCount)
ConsoleWrite("count position : "  & $countPosition  & @CRLF)

Local $thumbPosition = StringInStr($string2add, "thumbnail(s)")
ConsoleWrite("thumb position : "  & $thumbPosition  & @CRLF)

GUICtrlSetFont(-1, 22, 600, 0, "Arial")
GUICtrlSetColor($paddLblDate, $COLOR_WHITE)

$labelStart = $iX + 130
ConsoleWrite("labelStart : "  & $labelStart  & @CRLF)

   For $i = 1 To $thumbCount - 1
      $thumbCount = $thumbCount - 1
          $thumbLabel = GUICtrlCreateLabel($thumbCount, $labelStart , $iY + 4, 50, 28, $SS_CENTER)
      GUICtrlSetFont(-1, 20, 700, 0, "Arial")
      GUICtrlSetColor($thumbLabel, $COLOR_RED)
      ConsoleWrite("New count : "  & $thumbCount & @CRLF)
      sleep (600)
   next

GUICtrlDelete($paddLblDate)
GUICtrlDelete($paddLblDate)
GUICtrlDelete($paddLblDate)
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphics)

 

Share this post


Link to post
Share on other sites



Instead of creating $thumbcount - 1 labels, create the label once, then use GUICtrlSetData to update the label's contents. In other words, get the GUICtrlCreateLabel out of your loop and only create it once.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

i had tried that but  wanted to change the color of the number countdown...

i guess i should have made that more obvious in my question,   but i had been trying to do the " GUICtrlSetData" to JUST the numbers to get the color change, i may just have to settle lol..

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Something like that here maybe?

#include <GDIPlus.au3>
#include <GuiConstantsEx.au3>


_GDIPlus_Startup()
Global $iDialog_Width = 1280
Global $iDialog_Depth = 720
Global $blueness = 0xff0066ff

Global Const $hGUI = GUICreate("Test", $iDialog_Width, $iDialog_Depth)
Global Const $iPic = GUICtrlCreatePic("", $iDialog_Width / 4, $iDialog_Depth / 4, $iDialog_Width / 2, $iDialog_Depth / 2), $hPic = GUICtrlGetHandle($iPic)
GUISetState()

Global $iCounter = 0

Do
    _DisplayProgress($iCounter, "c:\Windows\SysWOW64\Resources\", $iPic)
    $iCounter += 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
Until False


Func _DisplayProgress($iNumber, $sPath, $iCtrl, $iColorBorder = 0xff0066ff, $iColorText = 0xFFFFFFFF, $iColorCounter = 0xFFFF0000, $iColorBg = 0xFF808080, $iBorder_Size = 16)
    Local $aSize = ControlGetPos("", "", $iCtrl)
    If @error Then Return SetError(1, 0, 0)
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($aSize[2], $aSize[3])
    Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx, 4)
    _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 2)
    _GDIPlus_GraphicsClear($hGfx, $iColorBg)
    Local Const $hPath = _GDIPlus_PathCreate()
    Local Const $hPen_Border = _GDIPlus_PenCreate($iColorBorder, $iBorder_Size), $hBrush_Txt = _GDIPlus_BrushCreateSolid($iColorText), _
                $hBrush_Counter = _GDIPlus_BrushCreateSolid($iColorCounter)
    Local Const $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI"), $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $aSize[2], $aSize[3])
    _GDIPlus_PathAddString($hPath, "Loading " & StringFormat(" %" & StringLen($iNumber)& "i ", $iNumber) & " thumbnail(s) from " & @CRLF & $sPath, $tLayout, $hFamily, 0, 24, $hFormat)
    _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush_Txt)

    _GDIPlus_GraphicsDrawRect($hGfx, $iBorder_Size, $iBorder_Size, $aSize[2] - 2 * $iBorder_Size, $aSize[3] - 2 * $iBorder_Size, $hPen_Border)
    Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, $IMAGE_BITMAP, $hHBitmap))

    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PenDispose($hPen_Border)
    _GDIPlus_BrushDispose($hBrush_Txt)
    _GDIPlus_BrushDispose($hBrush_Counter)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_BitmapDispose($hBitmap)
EndFunc

Tested only on Win10 x64.

Edited by UEZ
1 person likes this

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

wow that is pretty impressive!  i may have to see if that will look good in my gui...

 

Share this post


Link to post
Share on other sites

wow seems like forever since i was working with this...   @UEZ  

this works great by itself, but  when trying to use this in my gui it wont work till i click on the gui and then it displays... i have tried several things like even faking the mouse click..  

i know it has something to do with being ui and maybe using gui switch but just wondering before i made this a popup you had any info i prefer it inside my gui as a child

Share this post


Link to post
Share on other sites

You can use e.g. AdlibRegister to display the progressbar which runs "multi threaded".

 

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


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

awesome thanks...  i was looking at the loading spinner ... is that possible to add right inside a gui as a child?  and one other question... i want it to start on a button click so i made it another function.  

if i called this by  using "downloadingSpinner()" in a for loop how would i break and delete the gui then?

also any chance it can countdown the number instead of  just "loading"?

;coded by UEZ build 2014-02-08, idea taken from http://codepen.io/Fahrenheit/pen/Kbyxu
;AutoIt v3.3.9.21 or higher needed!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

downloadingSpinner()


func downloadingSpinner()

   _GDIPlus_Startup()
   Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
   Global $iW = 400, $iH = 250
   Global Const $spinGUI = GUICreate("Loading Spinner", $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 = 30, $s = 0, $t, $m = 0
   GUIRegisterMsg($WM_TIMER, "PlayAnim")
   DllCall("user32.dll", "int", "SetTimer", "hwnd", $spinGUI, "int", 0, "int", $iSleep, "int", 0)

   Do
       Switch GUIGetMsg()
           Case $GUI_EVENT_CLOSE
               GUIRegisterMsg($WM_TIMER, "")
               _WinAPI_DeleteObject($hHBmp_BG)
               _GDIPlus_Shutdown()
               GUIDelete($spinGUI)
               Exit
       EndSwitch
   Until False
EndFunc


Func PlayAnim()
    $hHBmp_BG = _GDIPlus_MultiColorLoader($iW, $iH, "LOADING")
    $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
    If $hB Then _WinAPI_DeleteObject($hB)
    _WinAPI_DeleteObject($hHBmp_BG)
EndFunc   ;==>PlayAnim


Func _GDIPlus_MultiColorLoader($iW, $iH, $sText = "LOADING", $sFont = "Arial", $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, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx, 0xFF464655)

    Local $iRadius = ($iW > $iH) ? $iH * 0.6 : $iW * 0.6

    Local Const $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, ($iW - ($iRadius + 24)) / 2, ($iH - ($iRadius + 24)) / 2, $iRadius + 24, $iRadius + 24)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0x08101010)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aBlend[4][2] = [[3]]
    $aBlend[1][0] = 0 ;0% center color
    $aBlend[1][1] = 0 ;position = boundary
    $aBlend[2][0] = 0.33 ;70% center color
    $aBlend[2][1] = 0.1 ;10% of distance boundary->center point
    $aBlend[3][0] = 1 ;100% center color
    $aBlend[3][1] = 1 ;center point
    _GDIPlus_PathBrushSetBlend($hBrush, $aBlend)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGfx, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)

    Local Const $hBrush_Black = _GDIPlus_BrushCreateSolid(0xFF464655)
    _GDIPlus_GraphicsFillEllipse($hGfx, ($iW - ($iRadius + 10)) / 2, ($iH - ($iRadius + 10)) / 2, $iRadius + 10, $iRadius + 10, $hBrush_Black)

    Local Const $hBitmap_Gradient = _GDIPlus_BitmapCreateFromScan0($iRadius, $iRadius)
    Local Const $hGfx_Gradient = _GDIPlus_ImageGetGraphicsContext($hBitmap_Gradient)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Gradient, 4 + (@OSBuild > 5999))
    Local Const $hMatrix = _GDIPlus_MatrixCreate()
    Local Static $r = 0
    _GDIPlus_MatrixTranslate($hMatrix, $iRadius / 2, $iRadius / 2)
    _GDIPlus_MatrixRotate($hMatrix, $r)
    _GDIPlus_MatrixTranslate($hMatrix, -$iRadius / 2, -$iRadius / 2)
    _GDIPlus_GraphicsSetTransform($hGfx_Gradient, $hMatrix)
    $r += 10
    Local Const $hBrush_Gradient = _GDIPlus_LineBrushCreate($iRadius, $iRadius / 2, $iRadius, $iRadius, 0xFF000000, 0xff0066ff, 1)
    _GDIPlus_LineBrushSetGammaCorrection($hBrush_Gradient)
    _GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 0, 0, $iRadius, $iRadius, $hBrush_Gradient)
    _GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 4, 4, $iRadius - 8, $iRadius - 8, $hBrush_Black)
    _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Gradient, ($iW - $iRadius) / 2, ($iH - $iRadius) / 2, $iRadius, $iRadius)
    _GDIPlus_BrushDispose($hBrush_Gradient)
    _GDIPlus_BrushDispose($hBrush_Black)
    _GDIPlus_GraphicsDispose($hGfx_Gradient)
    _GDIPlus_BitmapDispose($hBitmap_Gradient)
    _GDIPlus_MatrixDispose($hMatrix)

    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iRadius / 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    Local Static $iColor = 0x00, $iDir = 13
    Local $hBrush_txt = _GDIPlus_BrushCreateSolid(0xFF000000 + 0x010000 * $iColor + 0x0100 * $iColor + $iColor)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $sText, $hFont, $tLayout, $hFormat, $hBrush_txt)
    $iColor += $iDir
    If $iColor > 0xFF Then
        $iColor = 0xFF
        $iDir *= -1
    ElseIf $iColor < 0x16 Then
        $iDir *= -1
        $iColor = 0x16
    EndIf
    _GDIPlus_BrushDispose($hBrush_txt)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($hGfx)

    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc

 

Share this post


Link to post
Share on other sites

i was able to get inside the gui no problem  but i see that it does not play well with a for loop i already have in place... it will only go thru the loop once and stop but the animation keeps going ... when i un comment the "dllcall"   ....it will go thru the loop no problem but wont show the animation...

i thought it was the iSleep but its not.

i have it all outside the for loop as you do in your example

_GDIPlus_Startup()
;GUICtrlSetState(-1, $GUI_DISABLE)
Global Const $STM_SETIMAGE = 0x0172; $IMAGE_BITMAP = 0
Global $iW = $iDialog_Width, $iH = $iDialog_Depth
Global Const $spinGUI = GUICreate("Loading", $iDialog_Width, $iDialog_Depth, 0,100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 30, $s = 0, $t, $m = 0

GUISetState (@SW_SHOW, $spinGUI)
GUISetState(@SW_ENABLE, $hGUI)
WinActivate($hGUI)
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $spinGUI, "int", 0, "int", $iSleep, "int", 0)

      $iCounter = 0
      For $i = 1 To $thumbCount - 1
         $thumbCount -= 1
         ConsoleWrite("Count Down : "  & $thumbCount & @CRLF)
         $var = StringSplit ($image2load, "/")
         Local $sOldImage = $var[UBound ($var) - 1]
         Local $imgLabel = $aTitle[$i]
         Local $sNewImage =  $sImagePath & "\" & $imgLabel & ".bmp"
         ConsoleWrite("New Image : "  & $sNewImage & @CRLF)

         sleep (500)
      next

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

You can do something like this here:

;coded by UEZ build 2014-02-08, idea taken from http://codepen.io/Fahrenheit/pen/Kbyxu
;AutoIt v3.3.9.21 or higher needed!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Global $hGUI_Main = GUICreate("Main GUI", 300, 200)
Global $iBtn = GUICtrlCreateButton("Start", 200, 150, 50, 30)
GUISetState()

Global $iTimer, $iW = 400, $iH = 250, $iPic, $hHBmp_BG, $hB, $STM_SETIMAGE = 0x0172, $fTimer, $iTimer_Stop = 15 * 1000, $bFinished = False

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            Exit
        Case $iBtn
            $fTimer = TimerInit()
            downloadingSpinner()
            $bFinished = False
    EndSwitch
Until False


downloadingSpinner()


Func downloadingSpinner()

    _GDIPlus_Startup()
    Local Const $spinGUI = GUICreate("Loading Spinner", $iW, $iH, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
    $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW, $spinGUI)

    Global $iSleep = 30, $s = 0, $t, $m = 0
    GUIRegisterMsg($WM_TIMER, "PlayAnim")
    DllCall("user32.dll", "int", "SetTimer", "hwnd", $spinGUI, "int", 0, "int", $iSleep, "int", 0)

    Do
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
        If $bFinished Then ExitLoop
    Until Not Sleep(50)

    GUIRegisterMsg($WM_TIMER, "")
    _WinAPI_DeleteObject($hHBmp_BG)
    _GDIPlus_Shutdown()
    GUIDelete($spinGUI)
    Return
EndFunc   ;==>downloadingSpinner


Func PlayAnim()
    Local $iTimeDiff = $iTimer_Stop - TimerDiff($fTimer)
    If $iTimeDiff < 0 Then
        GUIRegisterMsg($WM_TIMER, "")
        $bFinished = True
    Else
        $hHBmp_BG = _GDIPlus_MultiColorLoader($iW, $iH, StringFormat("%.2f sec", $iTimeDiff / 1000))
        $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
        If $hB Then _WinAPI_DeleteObject($hB)
        _WinAPI_DeleteObject($hHBmp_BG)
    EndIf
EndFunc   ;==>PlayAnim


Func _GDIPlus_MultiColorLoader($iW, $iH, $sText = "LOADING", $sFont = "Arial", $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, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx, 0xFF464655)

    Local $iRadius = ($iW > $iH) ? $iH * 0.6 : $iW * 0.6

    Local Const $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, ($iW - ($iRadius + 24)) / 2, ($iH - ($iRadius + 24)) / 2, $iRadius + 24, $iRadius + 24)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0x08101010)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aBlend[4][2] = [[3]]
    $aBlend[1][0] = 0 ;0% center color
    $aBlend[1][1] = 0 ;position = boundary
    $aBlend[2][0] = 0.33 ;70% center color
    $aBlend[2][1] = 0.1 ;10% of distance boundary->center point
    $aBlend[3][0] = 1 ;100% center color
    $aBlend[3][1] = 1 ;center point
    _GDIPlus_PathBrushSetBlend($hBrush, $aBlend)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGfx, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)

    Local Const $hBrush_Black = _GDIPlus_BrushCreateSolid(0xFF464655)
    _GDIPlus_GraphicsFillEllipse($hGfx, ($iW - ($iRadius + 10)) / 2, ($iH - ($iRadius + 10)) / 2, $iRadius + 10, $iRadius + 10, $hBrush_Black)

    Local Const $hBitmap_Gradient = _GDIPlus_BitmapCreateFromScan0($iRadius, $iRadius)
    Local Const $hGfx_Gradient = _GDIPlus_ImageGetGraphicsContext($hBitmap_Gradient)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Gradient, 4 + (@OSBuild > 5999))
    Local Const $hMatrix = _GDIPlus_MatrixCreate()
    Local Static $r = 0
    _GDIPlus_MatrixTranslate($hMatrix, $iRadius / 2, $iRadius / 2)
    _GDIPlus_MatrixRotate($hMatrix, $r)
    _GDIPlus_MatrixTranslate($hMatrix, -$iRadius / 2, -$iRadius / 2)
    _GDIPlus_GraphicsSetTransform($hGfx_Gradient, $hMatrix)
    $r += 10
    Local Const $hBrush_Gradient = _GDIPlus_LineBrushCreate($iRadius, $iRadius / 2, $iRadius, $iRadius, 0xFF000000, 0xff0066ff, 1)
    _GDIPlus_LineBrushSetGammaCorrection($hBrush_Gradient)
    _GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 0, 0, $iRadius, $iRadius, $hBrush_Gradient)
    _GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 4, 4, $iRadius - 8, $iRadius - 8, $hBrush_Black)
    _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Gradient, ($iW - $iRadius) / 2, ($iH - $iRadius) / 2, $iRadius, $iRadius)
    _GDIPlus_BrushDispose($hBrush_Gradient)
    _GDIPlus_BrushDispose($hBrush_Black)
    _GDIPlus_GraphicsDispose($hGfx_Gradient)
    _GDIPlus_BitmapDispose($hBitmap_Gradient)
    _GDIPlus_MatrixDispose($hMatrix)

    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iRadius / 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    Local Static $iColor = 0x00, $iDir = 13
    Local $hBrush_txt = _GDIPlus_BrushCreateSolid(0xFF000000 + 0x010000 * $iColor + 0x0100 * $iColor + $iColor)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $sText, $hFont, $tLayout, $hFormat, $hBrush_txt)
    $iColor += $iDir
    If $iColor > 0xFF Then
        $iColor = 0xFF
        $iDir *= -1
    ElseIf $iColor < 0x16 Then
        $iDir *= -1
        $iColor = 0x16
    EndIf
    _GDIPlus_BrushDispose($hBrush_txt)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($hGfx)

    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_MultiColorLoader

 

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

ok i have tried changing this up a bit , i want to be able to stop it and delete that child gui but its not working...  thanks for your help thus far 

you can see i changed it to a child of the main gui...  but it does not let me stop it... if i click the x  first it will delete the spinner  then second close the entire thing

;coded by UEZ build 2014-02-08, idea taken from http://codepen.io/Fahrenheit/pen/Kbyxu
;AutoIt v3.3.9.21 or higher needed!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Global $hGUI= GUICreate("Main GUI", 600, 500)
Global $cGo = GUICtrlCreateButton("Start", 100, 450, 50, 30)
Global $cStop = GUICtrlCreateButton("Stop", 400, 450, 50, 30)
GUISetState()

Global $spinGUI,$iTimer, $iW = 400, $iH = 250, $iPic, $hHBmp_BG, $hB, $STM_SETIMAGE = 0x0172, $fTimer, $iTimer_Stop = 15 * 1000, $bFinished = False

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete($spinGUI)
            Exit
        Case $cGo
            $fTimer = TimerInit()
            downloadingSpinner()
            $bFinished = False
            GUISetState(@SW_ENABLE, $hGUI)
            WinActivate($hGUI)
         Case $cStop
            $bFinished = True
            GUIDelete($spinGUI)
            ExitLoop
    EndSwitch
Until False


downloadingSpinner()


Func downloadingSpinner()

    _GDIPlus_Startup()
    Local Const $spinGUI = GUICreate("Loading Spinner", $iW, $iH, 100, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
    $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
    GUICtrlSetState(-1, $GUI_DISABLE)
    GUISetState(@SW_SHOW, $spinGUI)

    Global $iSleep = 30, $s = 0, $t, $m = 0
    GUIRegisterMsg($WM_TIMER, "PlayAnim")
    DllCall("user32.dll", "int", "SetTimer", "hwnd", $spinGUI, "int", 0, "int", $iSleep, "int", 0)

    Do
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
        If $bFinished Then ExitLoop
    Until Not Sleep(50)

    GUIRegisterMsg($WM_TIMER, "")
    _WinAPI_DeleteObject($hHBmp_BG)
    _GDIPlus_Shutdown()
    GUIDelete($spinGUI)
    Return
EndFunc   ;==>downloadingSpinner


Func PlayAnim()
    Local $iTimeDiff = $iTimer_Stop - TimerDiff($fTimer)
    If $iTimeDiff < 0 Then
        GUIRegisterMsg($WM_TIMER, "")
        $bFinished = True
     Else


        $hHBmp_BG = _GDIPlus_MultiColorLoader($iW, $iH, StringFormat("%.2f sec", $iTimeDiff / 1000))



        $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
        If $hB Then _WinAPI_DeleteObject($hB)
        _WinAPI_DeleteObject($hHBmp_BG)
    EndIf
EndFunc   ;==>PlayAnim


Func _GDIPlus_MultiColorLoader($iW, $iH, $sText = "LOADING", $sFont = "Arial", $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, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx, 0xFF464655)

    Local $iRadius = ($iW > $iH) ? $iH * 0.6 : $iW * 0.6

    Local Const $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, ($iW - ($iRadius + 24)) / 2, ($iH - ($iRadius + 24)) / 2, $iRadius + 24, $iRadius + 24)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
    _GDIPlus_PathBrushSetSurroundColor($hBrush, 0x08101010)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)

    Local $aBlend[4][2] = [[3]]
    $aBlend[1][0] = 0 ;0% center color
    $aBlend[1][1] = 0 ;position = boundary
    $aBlend[2][0] = 0.33 ;70% center color
    $aBlend[2][1] = 0.1 ;10% of distance boundary->center point
    $aBlend[3][0] = 1 ;100% center color
    $aBlend[3][1] = 1 ;center point
    _GDIPlus_PathBrushSetBlend($hBrush, $aBlend)

    Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
    _GDIPlus_GraphicsFillRect($hGfx, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)

    _GDIPlus_PathDispose($hPath)
    _GDIPlus_BrushDispose($hBrush)

    Local Const $hBrush_Black = _GDIPlus_BrushCreateSolid(0xFF464655)
    _GDIPlus_GraphicsFillEllipse($hGfx, ($iW - ($iRadius + 10)) / 2, ($iH - ($iRadius + 10)) / 2, $iRadius + 10, $iRadius + 10, $hBrush_Black)

    Local Const $hBitmap_Gradient = _GDIPlus_BitmapCreateFromScan0($iRadius, $iRadius)
    Local Const $hGfx_Gradient = _GDIPlus_ImageGetGraphicsContext($hBitmap_Gradient)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Gradient, 4 + (@OSBuild > 5999))
    Local Const $hMatrix = _GDIPlus_MatrixCreate()
    Local Static $r = 0
    _GDIPlus_MatrixTranslate($hMatrix, $iRadius / 2, $iRadius / 2)
    _GDIPlus_MatrixRotate($hMatrix, $r)
    _GDIPlus_MatrixTranslate($hMatrix, -$iRadius / 2, -$iRadius / 2)
    _GDIPlus_GraphicsSetTransform($hGfx_Gradient, $hMatrix)
    $r += 10
    Local Const $hBrush_Gradient = _GDIPlus_LineBrushCreate($iRadius, $iRadius / 2, $iRadius, $iRadius, 0xFF000000, 0xff0066ff, 1)
    _GDIPlus_LineBrushSetGammaCorrection($hBrush_Gradient)
    _GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 0, 0, $iRadius, $iRadius, $hBrush_Gradient)
    _GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 4, 4, $iRadius - 8, $iRadius - 8, $hBrush_Black)
    _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Gradient, ($iW - $iRadius) / 2, ($iH - $iRadius) / 2, $iRadius, $iRadius)
    _GDIPlus_BrushDispose($hBrush_Gradient)
    _GDIPlus_BrushDispose($hBrush_Black)
    _GDIPlus_GraphicsDispose($hGfx_Gradient)
    _GDIPlus_BitmapDispose($hBitmap_Gradient)
    _GDIPlus_MatrixDispose($hMatrix)

    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iRadius / 10)
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
    Local Static $iColor = 0x00, $iDir = 13
    Local $hBrush_txt = _GDIPlus_BrushCreateSolid(0xFF000000 + 0x010000 * $iColor + 0x0100 * $iColor + $iColor)
    _GDIPlus_GraphicsDrawStringEx($hGfx, $sText, $hFont, $tLayout, $hFormat, $hBrush_txt)
    $iColor += $iDir
    If $iColor > 0xFF Then
        $iColor = 0xFF
        $iDir *= -1
    ElseIf $iColor < 0x16 Then
        $iDir *= -1
        $iColor = 0x16
    EndIf
    _GDIPlus_BrushDispose($hBrush_txt)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_GraphicsDispose($hGfx)

    If $bHBitmap Then
        Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBITMAP
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_MultiColorLoader

 

Share this post


Link to post
Share on other sites

Just add $cStop to the check of GUIGetMsg() in function downloadingSpinner()

DllCall("user32.dll", "int", "SetTimer", "hwnd", $spinGUI, "int", 0, "int", $iSleep, "int", 0)

    Do
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $cStop
                ExitLoop
        EndSwitch
        If $bFinished Then ExitLoop
    Until Not Sleep(50)

and it should work.

1 person likes this

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

no matter how i get this in my gui it wont work :(  sorry and i really appreciate your help

it seems that it will start when i hit go , but just spin wont start loading images... if i hit stop it will then delte that gui and then start loading  the thumbnail

 is it because of the loops or something in your code?   i really like that spinner but man is it just not fitting.. is  there a way to put this into an existing for loop and still work?

like just be able to toss in this fort loop? like so

$iCounter = 0
      For $i = 1 To $thumbCount - 1
         $thumbCount -= 1
         ConsoleWrite("Count Down : "  & $thumbCount & @CRLF)
         $var = StringSplit ($image2load, "/")
         Local $sOldImage = $var[UBound ($var) - 1]
         Local $imgLabel = $aTitle[$i]
         Local $sNewImage =  $sImagePath & "\" & $imgLabel & ".bmp"
         ConsoleWrite("New Image : "  & $sNewImage & @CRLF)


        downloadingSpinner()

         sleep (500)
      next

and then delete it after the loop is done

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Just check your code:

Case $cStop
            $bFinished = True
            GUIDelete($spinGUI)
            ExitLoop
    EndSwitch
Until False


downloadingSpinner()

When you push the stop button it will delete the spinner GUI and exit the loop and start the spinner GUI again.

I assume that's not what you want.

 

The spinner it self is called every 30 milli seconds initiated by

GUIRegisterMsg($WM_TIMER, "PlayAnim")
    DllCall("user32.dll", "int", "SetTimer", "hwnd", $spinGUI, "int", 0, "int", $iSleep, "int", 0)

You have to pass the values in a global variable within the function PlayAnim()!

$hHBmp_BG = _GDIPlus_MultiColorLoader($iW, $iH, StringFormat("%.2f sec", $iTimeDiff / 1000))

The bold red entry is the parameter for the text. That means for your scenario you have to pass a value within your loop 

For $i = 1 To $thumbCount - 1

to the call above _GDIPlus_MultiColorLoader.

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

 

so like this

For $i = 1 To $thumbCount - 1
         $thumbCount -= 1
         ConsoleWrite("Count Down : "  & $thumbCount & @CRLF)
         $var = StringSplit ($image2load, "/")
         Local $sOldImage = $var[UBound ($var) - 1]
         Local $imgLabel = $aTitle[$i]
         Local $sNewImage =  $sImagePath & "\" & $imgLabel & ".bmp"
         ConsoleWrite("New Image : "  & $sNewImage & @CRLF)

        Global $txt2load = $thumbCount
        downloadingSpinner()

         sleep (500)
      next
$hHBmp_BG = _GDIPlus_MultiColorLoader($iW, $iH, $txt2load)

 

Share this post


Link to post
Share on other sites

Why are you calling downloadingSpinner() in a loop? You have to display the spinner GUI and start the loop afterward. That means you have to modify the function downloadingSpinner() not to wait for GUI close rather start the GUI and return afterwards. When the loop above is finished then close the spinner GUI.


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

ok and how do i get it to notify the   downloadingSpinner()   that the loop is finished and to stop it?

something like this 

downloadingSpinner()
 
      For $i = 1 To $thumbCount - 1
         $thumbCount -= 1
         ConsoleWrite("Count Down : "  & $thumbCount & @CRLF)
         $var = StringSplit ($image2load, "/")
         Local $sOldImage = $var[UBound ($var) - 1]
         Local $imgLabel = $aTitle[$i]
         Local $sNewImage =  $sImagePath & "\" & $imgLabel & ".bmp"
         ConsoleWrite("New Image : "  & $sNewImage & @CRLF)

        Global $txt2load = $thumbCount
        stopDownloadingSpinner()

         sleep (500)
      next

then to stop it?

Func stopDownloadingSpinner()
    GUIRegisterMsg($WM_TIMER, "")
    _WinAPI_DeleteObject($hHBmp_BG)
    _GDIPlus_Shutdown()
    GUIDelete($spinGUI)
 EndFunc

then to get the text to playanim()

Func PlayAnim($text2load)
    Local $iTimeDiff = $iTimer_Stop - TimerDiff($fTimer)
    If $iTimeDiff < 0 Then
        GUIRegisterMsg($WM_TIMER, "")
        $bFinished = True
     Else

        ;$text2load = StringFormat("%.2f sec", $iTimeDiff / 1000)
        $hHBmp_BG = _GDIPlus_MultiColorLoader($iW, $iH, $text2load)

        $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
        If $hB Then _WinAPI_DeleteObject($hB)
        _WinAPI_DeleteObject($hHBmp_BG)
    EndIf
EndFunc   ;==>PlayAnim

sorry i am not at home to test...  thank you!

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

  • Similar Content

    • KenNichols
      By KenNichols
      I am trying to create a GUI Simulator and feel there must be a better way to do it than the way I'm doing it now.

      I am loading a .jpg and enabling/disabling transparent(made black for this example) labels which load a different picture when clicked.

      See my code below. It works but I will be working with about 100 pictures total.

      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ico\control_panel.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\knichols\Desktop\frmMain.kxf $frmMain = GUICreate("Simulator", 1024, 643) $Picture = GUICtrlCreatePic("C:\Simulator\ScreenShots\Image1.jpg", 0, 0,1024,643,$SS_BITMAP) $lblCopy = GUICtrlCreateLabel("", 73, 169, 220, 280) GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT GUICtrlSetCursor(-1, 0) $lblPrintFrom = GUICtrlCreateLabel("", 328, 169, 220, 280) GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT GUICtrlSetCursor(-1, 0) $lblScanTo = GUICtrlCreateLabel("", 583, 169, 220, 280) GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT GUICtrlSetCursor(-1, 0) $lblServicesHome = GUICtrlCreateLabel("", 223, 553, 42, 42) GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT GUICtrlSetCursor(-1, 0) $lblJobStatus = GUICtrlCreateLabel("", 473, 553, 42, 42) GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT GUICtrlSetCursor(-1, 0) $lblMachineStatus = GUICtrlCreateLabel("", 600, 553, 42, 42) GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT GUICtrlSetCursor(-1, 0) $lblOK = GUICtrlCreateLabel("", 733, 124, 94, 34) GUICtrlSetBkColor(-1, 000000);$GUI_BKCOLOR_TRANSPARENT GUICtrlSetCursor(-1, 0) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $bFileInstall = False Local $sFldr = "C:\Simulator\ScreenShots\" If DirGetSize($sFldr) <> -1 Then Local $bFileInstall = False Else DirCreate($sFldr) FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image1.jpg", $sFldr & "Image1.jpg") FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image3.jpg", $sFldr & "Image3.jpg") FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image21.jpg", $sFldr & "Image21.jpg") FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image21.jpg", $sFldr & "Image22.jpg") FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image43.jpg", $sFldr & "Image43.jpg") FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image68.jpg", $sFldr & "Image68.jpg") FileInstall("C:\Users\knichols\Desktop\ScreenShots\Image69.jpg", $sFldr & "Image69.jpg") EndIf While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $lblJobStatus GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image69.jpg") DisableLabels() Case $lblServicesHome GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image1.jpg") EnableLabels() Case $lblMachineStatus GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image43.jpg") DisableLabels() Case $lblCopy GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image3.jpg") DisableLabels() Case $lblPrintFrom GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image68.jpg") DisableLabels() Case $lblScanTo GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image21.jpg") GUICtrlSetState($lblOK, $GUI_ENABLE) DisableLabels() Case $lblOK GUICtrlSetImage($Picture, "C:\Simulator\ScreenShots\Image22.jpg") GUICtrlSetState($lblOK, $GUI_DISABLE) EndSwitch WEnd Func DisableLabels() GUICtrlSetState($lblCopy,$GUI_DISABLE) GUICtrlSetState($lblScanTo,$GUI_DISABLE) GUICtrlSetState($lblPrintFrom,$GUI_DISABLE) EndFunc Func EnableLabels() GUICtrlSetState($lblCopy,$GUI_ENABLE) GUICtrlSetState($lblScanTo,$GUI_ENABLE) GUICtrlSetState($lblPrintFrom,$GUI_ENABLE) EndFunc
    • drbyte
      By drbyte
      Hello all,
       
      I have to print a lot pdf labels during a day at work.
      One of our customers delivers them as a pdf file on a single A4 page.
       
      Every time when i need to print a specific label, i need to do the handling below to print
      the selected label to our Dymo printer.
      Can this be automated in a simple way?
       
      1. Zoom opened pdf to 350%
      2. Resize the window to fit the label
      3. Select print
      4. Choose printer
      5. Select properties
      6. Select left roll
      7. Select the correct label size
      8. Select current view
      9. Press print......
       
      If found the code below in the forum, is this, with some adjustments of course usable?
      (Thanks to M23)
       
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Install a custom error handler Global $oMyError = ObjEvent("AutoIt.Error","_ComErrFunc") Global $iGUIWidth = 800, $iGUIHeight = 570, $fResized = False _Show_PDF() Func _Show_PDF()     ; Get file to display     Local $sFile = FileOpenDialog("Choose PDF", "C:\Temp", "PDF Files(*.pdf)", 3) ; put your own start folder here     If @error Then         MsgBox(0, "Error", "No file selected")         Return     EndIf     ; Declare objects     Local $oPDF = ObjCreate("AcroPDF.PDF.1");     $oPDF.src = $sFile     ; Create GUI     GUICreate("Label Printer", 1580, 590, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_MAXIMIZEBOX))     Local $GUI_ActiveX = GUICtrlCreateObj($oPDF, 10, 10, 1560, 570)     GUICtrlSetStyle($GUI_ActiveX, $WS_VISIBLE)     GUICtrlSetResizing($GUI_ActiveX, $GUI_DOCKAUTO) ; Auto Resize Object     GUISetState()     ; When window is resized, run this function     GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")     While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 ExitLoop         EndSwitch         If $fResized = True Then             ConsoleWrite($iGUIWidth & " - " & $iGUIHeight & @CRLF)             $fResized = False             WinMove($GUI_ActiveX, "", Default, Default, $iGUIWidth - 20, $iGUIHeight - 20)         EndIf     WEnd     ; Clear up     $oPDF = ""     $GUIActiveX = ""     Exit EndFunc Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)     $iGUIWidth = BitAND($lParam, 0xFFFF)     $iGUIHeight = BitShift($lParam, 16)     $fResized = True     Return $GUI_RUNDEFMSG EndFunc   ;==>MY_WM_SIZE Func _ComErrFunc()   Local $HexNumber = Hex($oMyError.number,8)   Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _              "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _              "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _              "err.number is: "         & @TAB & $HexNumber              & @CRLF & _              "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _              "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _              "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _              "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _              "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _             )   SetError(1) EndFunc
    • islandspapand
      By islandspapand
      Hi
      i have some problemes in gettings my Lables and icons to be transperent,
      i can make my labels transperent with guictrlsetbgkcolor(-1,"-2") but then the texts look weird. As it is to thick
      i can't get my icons to be transpent either Plz Plz Plz some help me
      Ps. is there any way i can change the default push button to the currenly active button?
      #cs***************************************** Proxy_Switch.au3 by Krabbe Created with ISN AutoIt Studio v. 0.94 BETA Created with ISN Form Studio 2 for ISN AutoIt Studio Script Version: 1.0 Last Modified: 21-11-2013 Script Function: Enable and Disable proxy settings in IE as user don't normaly know the path #ce***************************************** #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstants.au3> #include <Constants.au3> #Include <GuiButton.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <Array.au3> #include <IE.au3> Global $WlanInf[7] Global $LanInf[7] Global $PXYSVR = "proxy.intranet.ap" Global $PXYPRT = "80" Global $RegKeyLoc = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" Global $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Global $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2") Global $hImage = @Scriptdir& "\Images\hGUI1.png" Global $cImage = @Scriptdir& "\Images\cGUI.gif" Global $hGUI, $cGUI, $BtnEnableDisable, $BtnExit Global $LblCurrentConnect, $LblCurrentState, $LblSuggestSetting Global $RegGetProxyCurAdr, $RegGetProxyState #cs==========$WlanInf============ #cs==========$LanInf============= | [0] = Name | | [0] = Name | | [1] = MacAdress | | [1] = MacAdress | | [2] = Connect True/False | | [2] = Connect True/False | | [3] = Connected 2 Domain name | | [3] = Connected 2 Domain name | | [4] = Your Computer Domain | | [4] = Your Computer Domain | | [5] = IpAdress | | [5] = IpAdress | | [6] = Gateway | | [6] = Gateway | #ce============================== #ce============================== ;====================================== Start GDI Magic ================================ _GDIPlus_Startup() ; Initialize GDI+ library $hImage = _GDIPlus_ImageLoadFromFile($hImage) ; Main GUI Bckg Img $width = _GDIPlus_ImageGetWidth($hImage) ; Img Width | GUI Width $height = _GDIPlus_ImageGetHeight($hImage) ; Img Height | GUI Height _MainUI() Func _MainUI() Global $hGUI = GUICreate("MSI Recovery Image Finder", $width, $height, -1, -1, $WS_POPUP,$WS_EX_LAYERED) GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") GUISetState(@SW_SHOW,$hGUI) For $i = 0 To 240 Step 10 SetBitmap($hGUI, $hImage, $i) Sleep(10) Next Global $cGUI = GUICreate('childgui', $width, $height, 4, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD,$GUI_WS_EX_PARENTDRAG), $hGUI) $ChildBckg = GUICtrlCreatePic($cImage, 0, 0, $width, $height) GUICtrlSetBkColor($ChildBckg, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetState($ChildBckg, $GUI_DISABLE) Global $BtnEnable = GUICtrlCreateButton("Enable",75,85,60,20,$BS_DEFPUSHBUTTON,-1) GUICtrlSetFont(-1,8,400,0,"Constantia") Global $BtnDisable = GUICtrlCreateButton("Disable",165,85,60,20,$BS_DEFPUSHBUTTON,-1) GUICtrlSetFont(-1,8,400,0,"Constantia") Global $LblCurrentSetting = GUICtrlCreateLabel("",226,35,42,15,-1,-1) GUICtrlSetFont($LblCurrentSetting,8,400,0,"Constantia") Global $LblSuggestSetting = GUICtrlCreateLabel("",226,50,42,15,-1,-1) GUICtrlSetFont($LblSuggestSetting,8,400,0,"Constantia") Global $LblCurrentConnect = GUICtrlCreateLabel("proxy.intranet.ap:80",173,65,95,15,-1,-1) GUICtrlSetFont($LblCurrentConnect,8,100,0,"Constantia") ;~ GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) Global $IcnExit = GUICtrlCreateIcon("imageres.dll",98,267,10,16,16,-1,-1) GUICtrlSetBkColor($IcnExit,$GUI_BKCOLOR_TRANSPARENT) Global $IcnHelp = GUICtrlCreateIcon("imageres.dll",99,249,10,16,16,-1,-1) GUICtrlSetBkColor($IcnHelp,0x373737) _GetCurrentProxyState() _GetActiveSSID() GUISetState(@SW_SHOW,$cGUI) While 1 _ChkIfProxyStateChanged() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $IcnExit Exit Case $IcnHelp MsgBox(16,"Help","Coming Soon") Case $BtnEnable $RegWriteProxyEnable = RegWrite($RegKeyLoc, "ProxyEnable", "REG_DWORD", "1") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer") If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") = Failed >Error code: ' & @error & @crlf) ;### Debug Console BitAND(GUICtrlSetState($BtnDisable,$GUI_ENABLE),GUICtrlSetState($BtnEnable,$GUI_DISABLE)) BitAND(GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr),GUICtrlSetData($LblCurrentSetting,"Enabled")) Case $BtnDisable $RegWriteProxyDisable = RegWrite($RegKeyLoc, "ProxyEnable", "REG_DWORD", "0") DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer") If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") = Failed >Error code: ' & @error & @crlf) ;### Debug Console BitAND(GUICtrlSetState($BtnDisable,$GUI_DISABLE),GUICtrlSetState($BtnEnable,$GUI_ENABLE)) BitAND(GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr),GUICtrlSetData($LblCurrentSetting,"Disabled")) EndSwitch WEnd EndFunc Func _GetCurrentProxyState() $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer") If BitOr($RegGetProxyCurAdr = -1,@error > 0,$RegGetProxyCurAdr = "") Then ConsoleWrite('RegRead($RegKeyLoc,"ProxyServer") = Failed >Error code: ' & @error & @crlf) ;### Debug Console ConsoleWrite('$RegGetProxyCurAdr = ' & $RegGetProxyCurAdr & ' >Error code: ' & @error & @crlf) ;### Debug Console ;~ If $RegGetProxyCurAdr <> "proxy.intranet.ap:80" Then ;~ $RegWriteProxyAdr = RegWrite($RegKeyLoc, "ProxyServer", "REG_SZ", $PXYSVR & ":" & $PXYPRT) ;~ DllCall('WININET.DLL', 'long', 'InternetSetOption', 'int', 0, 'long', 39, 'str', 0, 'long', 0) ;~ $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer") ;~ GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr) ;~ Else ;~ $RegGetProxyCurAdr = RegRead($RegKeyLoc,"ProxyServer") ;~ GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr) ;~ EndIf $RegGetProxyState = RegRead($RegKeyLoc,"ProxyEnable") ConsoleWrite('$RegGetProxyState = ' & $RegGetProxyState & ' >Error code: ' & @error & @crlf) ;### Debug Console If $RegGetProxyState = 0 Then BitAND(GUICtrlSetData($LblCurrentState,"Disabled"),GUICtrlSetState($BtnEnable,$GUI_ENABLE),GUICtrlSetState($BtnDisable,$GUI_DISABLE)) If $RegGetProxyState = 1 Then BitAND(GUICtrlSetData($LblCurrentState,"Enabled"),GUICtrlSetState($BtnEnable,$GUI_DISABLE),GUICtrlSetState($BtnDisable,$GUI_ENABLE)) EndFunc Func _ChkIfProxyStateChanged() $RegGetProxyState = RegRead($RegKeyLoc,"ProxyEnable") ConsoleWrite('Current Proxy State = ' & $RegGetProxyState & ' >Error code: ' & @error & @crlf) ; If user changes proxy manualy while the prg is running If GUICtrlRead($LblCurrentSetting)="Enabled" And $RegGetProxyState = 0 Then GUICtrlSetState($BtnDisable,$GUI_DISABLE) GUICtrlSetState($BtnEnable,$GUI_ENABLE) GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr) GUICtrlSetData($LblCurrentSetting,"Disabled") EndIf ; If user changes proxy manualy while the prg is running If GUICtrlRead($LblCurrentSetting)="Disabled" And $RegGetProxyState = 1 Then GUICtrlSetState($BtnDisable,$GUI_ENABLE) GUICtrlSetState($BtnEnable,$GUI_DISABLE) GUICtrlSetData($LblCurrentConnect,$RegGetProxyCurAdr) GUICtrlSetData($LblCurrentSetting,"Enabled") EndIf EndFunc Func _GetActiveSSID() Global $Output = "", $colItems = "", $colItems1 = "" $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If StringInStr($objItem.Caption,"Intel") Then If $objItem.NetConnectionID = "Wireless Network Connection" Then $WlanInf[0] = $objItem.Description $WlanInf[1] = $objItem.MACAddress $WlanInf[2] = $objItem.NetEnabled ElseIf $objItem.NetConnectionID = "Local Area Connection" Then $LanInf[0] = $objItem.Description $LanInf[1] = $objItem.MACAddress $LanInf[2] = $objItem.NetEnabled EndIf $Output="" EndIf Next Else Msgbox(0,"WMI Output ERROR","No WMI Objects Found for class: " & "Win32_NetworkAdapter",2) SetError(1,0,"Error in WMI Win32_NetworkAdapter") Endif $colItems1 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems1) then For $objItem In $colItems1 If StringInStr($objItem.Caption,"Intel") <> 0 Then If BitAND($WlanInf[1] = $objItem.MACAddress, $WlanInf[0] = $objItem.Description) Then $WlanInf[3] = $objItem.DNSDomain $WlanInf[4] = $objItem.DNSDomainSuffixSearchOrder(0) $WlanInf[5] = $objItem.IPAddress(0) $WlanInf[6] = $objItem.DefaultIPGateway(0) ElseIf BitAND($LanInf[1] = $objItem.MACAddress, $LanInf[0] = $objItem.Description) Then $LanInf[3] = $objItem.DNSDomain $LanInf[4] = $objItem.DNSDomainSuffixSearchOrder(0) $LanInf[5] = $objItem.IPAddress(0) $LanInf[6] = $objItem.DefaultIPGateway(0) EndIf EndIf Next Else Msgbox(0,"WMI Output ERROR","No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration",2) SetError(2,0,"Error in WMI Win32_NetworkAdapterConfiguration") Endif If $LanInf[3] <> "intranet.ap" Then GUICtrlSetData($LblSuggestSetting,"Disabled") Else GUICtrlSetData($LblSuggestSetting,"Enabled") EndIf EndFunc Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) If ($hWnd = $hGUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc