Sign in to follow this  
Followers 0
hellogoodbye

Auto does whats in the window

4 posts in this topic

ok i just figured out how to make 2 windows open at the same time (with help from smoke) but how can i make it where a progres bar in one of the windows automaticly starts counting down from 100%. This progress bar can not be paused in anyway or messed with. Just is there to count down with a delay inbettwen each bar in the progress. I was looking at the help menu and i saw one but it has a button that is used to start it and i just want to to start with one of my windows and not have to do anything.

This is probley a really nooby question but idk

heres my core example (i want this without button, cant pause, and cant do anything to it (in the program)):

#include <GUIConstants.au3>

Global $progressbar1


GUICreate("My GUI  main",300,300, 100,200)
$button = GUICtrlCreateButton (10,40,200,20)
GUISetState ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            fun1()
            fun2()
    EndSelect
WEnd

$wait = 20

Func fun1()
    GUIDelete()
    GUICreate("My GUI fun1",220,100, 100,200)
    GUISetState ()
    
    While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    ExitLoop
WEnd
EndFunc

Func fun2()
    GUICreate("My GUI fun2",220,100, 100,200)
    $progressbar1 = GUICtrlCreateProgress(10, 10, 70, 20)
    $button = GUICtrlCreateButton("start", 10, 50, 70, 20)
    GUISetState ()
    GUICtrlSetData($progressbar1, 100)
    

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
    While 1
    $msg = GUIGetMsg()
do
$msg = GUIGetMsg()
If $msg = $button Then
    GUICtrlSetData ($button,"Stop")
    For $i = $s To 100
    $m = GUIGetMsg ()
    
    If $m = -3 Then ExitLoop
    
    If $m = $button Then
      GUICtrlSetData ($button,"Next")
      $s = $i;save the current bar-position to $s
      ExitLoop
    Else
        $s=0
      GUICtrlSetData ($progressbar1,(100 - $i))
      Sleep($wait)
    EndIf
    Next
    if $i >100 then
;       $s=0
        GUICtrlSetData ($button,"Start")
    endif
EndIf
until $msg = $GUI_EVENT_CLOSE
WEnd
EndFunc

Share this post


Link to post
Share on other sites



know1 knows :whistle:

Share this post


Link to post
Share on other sites

Well for a starter don't bump after 2 min...


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well if you don't want anything messing with it I guess you mean by exiting or anything like that, so heres a quick very CRUDE example just dropped a progress bar and label into a GUI but simple example of using a For Next loop with Step this won't close if you click the X button and the tray button is gone and the only way to close it is task manager

#NoTrayIcon
#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 633, 447, 193, 115)
$Progress1 = GUICtrlCreateProgress(40, 176, 561, 49)
GUICtrlSetData(-1, 25)
$Label1 = GUICtrlCreateLabel("100", 272, 137, 43, 39)
GUISetState(@SW_SHOW)

For $i = 100 To 0 Step -1
    GUICtrlSetData($Progress1,$i)
    GUICtrlSetData($Label1,$i)
    Sleep(1000)
Next
Exit
Edited by Thatsgreat2345

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0