Jump to content

Progress issue


Recommended Posts

Hello everyone

I have been trying to figure out creating progress bar, which is designed around checking if a process exists then switch off when process has terminated.

This is what i have thus far it doesn't really poll the progress bar for the entire duration of when the process exists. it flashes on then closes down. I have tested it by launching notepad then activating the script, the script finishes along with the progress bar. but i would like the progress bar to remain and continue to scroll the progress bar until notepad has been closed, then display complete and close off the progress bar.

$notepad = ProcessExists("notepad.exe")
$bnotepad = $notepad ==0
ProgressOn("Running","")
For $i = 1 To $notepad
   ProgressSet($i/$bnotepad*100,"","Running " & $bnotepad)
Next
ProgressSet($i/$bnotepad*100,"","Notepad closed down")
Sleep(3000)
ProgressOff()

Is there a better way such as using some form of an animated .gif to simplify it? and if so could a small demo be provided if possible.

Any assistance would be great

thanks is advance

ftc

Edited by failedtocompile
Link to comment
Share on other sites

Surely instead of the For loop you want a While loop?

Currently, the For loop doesnt actually loop because $i=1 and so does $notepad...so it just exits the loops..

If you had...

$notepad=ProcessExists("notepad.exe")
$bnotepad = $notepad ==0
ProgressOn("Running","")
While ProcessExists("notepad.exe")>0
   ProgressSet(100,"","Running " & $bnotepad)
   Sleep(20)
WEnd
ProgressSet(0,"","Notepad closed down")
Sleep(3000)
ProgressOff()

EDIT: I have just tested this and it works, altho im not sure what you mean about the animating the progress, so i just put it as 100, so you can see what i mean.

Edited by furrycow
Instant Lockerz Invite - www.instantlockerzinvite.co.uk
Link to comment
Share on other sites

Hi ! If I were you, I would go with animated GIFs ...

Take a look at this,

http://www.autoitscript.com/forum/index.php?showtopic=96132&st=0&p=691115&hl=animated%20gif%20GDI&fromsearch=1&#entry691115

:)

THE FOLLOWING CODE BELONGS TO "trancexx" ... I think .... anyway, I have tried it, and it work JUST FINE !

#include <WindowsConstants.au3>
#include "GIFAnimation.au3"

Opt("MustDeclareVars", 1)


Global $hGui = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW)

Global $sFile = FileOpenDialog("Choose gif", "", "(*.gif)", -1, "", $hGui)
If @error Then Exit

Global $aGIFArrayOfIconHandles
Global $hGIFThread
Global $iGIFTransparent
Global $tFrameCurrent

Global $hGIF = _GUICtrlCreateGIF($sFile, 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent)
GUICtrlSetTip($hGIF, "GIF")


Global $hButton = GUICtrlCreateButton("Stop animation", 50, 450, 100, 25)
Global $hButton1 = GUICtrlCreateButton("Delete GIF", 200, 450, 100, 25)
Global $hButton2 = GUICtrlCreateButton("Open GIF", 350, 450, 100, 25)


GUIRegisterMsg(15, "_Refresh"); WM_PAINT; don't forget this. It's needed only for non-transparent gifs though, but still.

Global $iPlay = 1

GUISetState()



While 1

    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $hButton
            If $iPlay Then
                If _StopGIFAnimation($hGIFThread) Then
                    $iPlay = 0
                    GUICtrlSetData($hButton, "Resume animation")
                EndIf
            Else
                If _ResumeGIFAnimation($hGIFThread) Then
                    $iPlay = 1
                    GUICtrlSetData($hButton, "Stop animation")
                EndIf
            EndIf
        Case $hButton1
            _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent)
        Case $hButton2
            $sFile = FileOpenDialog("Choose gif", "", "(*.gif)", -1, "", $hGui)
            If Not @error Then
                _GUICtrlDeleteGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $tFrameCurrent); if already there
                $hGIF = _GUICtrlCreateGIF($sFile, 10, 10, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent)
                GUICtrlSetTip($hGIF, "GIF")
                $iPlay = 1
                GUICtrlSetData($hButton, "Stop animation")
            EndIf
    EndSwitch

WEnd




Func _Refresh($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam, $lParam

    _RefreshGIF($hGIF, $aGIFArrayOfIconHandles, $hGIFThread, $iGIFTransparent, $tFrameCurrent)

EndFunc;==>_Refresh

[s][font="Impact"]░▒▓▓►DrKovra◄▓▓▒░[/font][/s]The only thing I [sup]know [/sup]is that I don't know [sub]nothing[/sub]--------------- __________------------------------------ __________---------------

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...