Jump to content

Progresson, cancelbutton


rehnmark
 Share

Recommended Posts

Hi!

I need some help getting a cancel button on the progresson-window

this is my code:

ProgressOn("Ominstallation", "Kopierar Filer till " & $ws1)
Run(@COMSPEC & ' /c psexec \\' & $ws1 & ' xcopy /S /E /C /H /R /Y k:\PEPreinstall\1.0.0\00\PreInstall.vbs c:\temp', "", @SW_HIDE)
$PID = Run(@COMSPEC & ' /c psexec \\' & $ws1 & ' xcopy /S /E /C /H /R /Y k:\PEDeploy\1.0.0\00 c:\temp', "", @SW_HIDE)
$x = 0
$Forward = 1
While ProcessExists($PID)
    Sleep(200)
    If $Forward Then
        If $x < 100 Then
            $x = $x + 1
        Else
            $Forward = 0
        EndIf
    Else
        If $x > 80 Then
            $x = $x - 60
        Else
            $Forward = 1
        EndIf
    EndIf
    ProgressSet($x)
WEnd
ProgressOff()

While the progressbar is showing i want to be able to press a "cancelbutton" to cancel the process ...

Anyone have any ideas?

Thanx in advance :P

Edited by rehnmark
Link to comment
Share on other sites

Hi!

I need some help getting a cancel button on the progresson-window

this is my code:

ProgressOn("Ominstallation", "Kopierar Filer till " & $ws1)
Run(@COMSPEC & ' /c psexec \\' & $ws1 & ' xcopy /S /E /C /H /R /Y k:\PEPreinstall\1.0.0\00\PreInstall.vbs c:\temp', "", @SW_HIDE)
$PID = Run(@COMSPEC & ' /c psexec \\' & $ws1 & ' xcopy /S /E /C /H /R /Y k:\PEDeploy\1.0.0\00 c:\temp', "", @SW_HIDE)
$x = 0
$Forward = 1
While ProcessExists($PID)
    Sleep(200)
    If $Forward Then
        If $x < 100 Then
            $x = $x + 1
        Else
            $Forward = 0
        EndIf
    Else
        If $x > 80 Then
            $x = $x - 60
        Else
            $Forward = 1
        EndIf
    EndIf
    ProgressSet($x)
WEnd
ProgressOff()

While the progressbar is showing i want to be able to press a "cancelbutton" to cancel the process ...

Anyone have any ideas?

Thanx in advance :P

You can create a custom GUI with a progress bar and a cancel button. The GUI created by ProgressOn() doesn't have options for buttons, I don't think.

:nuke:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • Moderators

You can create a custom GUI with a progress bar and a cancel button. The GUI created by ProgressOn() doesn't have options for buttons, I don't think.

:P

That's the easy/better way, you could always hack it up with AnyGUI I'm sure though.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

That's the easy/better way, you could always hack it up with AnyGUI I'm sure though.

OK, I'll bite... what's an AnyGUI? :P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

maybe...

ProgressOn("Ominstallation", "Kopierar Filer till " & $ws1)
Run(@COMSPEC & ' /c psexec \\' & $ws1 & ' xcopy /S /E /C /H /R /Y k:\PEPreinstall\1.0.0\00\PreInstall.vbs c:\temp', "", @SW_HIDE)
$PID = Run(@COMSPEC & ' /c psexec \\' & $ws1 & ' xcopy /S /E /C /H /R /Y k:\PEDeploy\1.0.0\00 c:\temp', "", @SW_HIDE)
Dim $x = 0
$Forward = 1
AdlibEnable("pros")
While ProcessExists($PID)
    
    $msg = GUIGetMsg()
    
    If $msg = $CANCEL_BUTTON Then 
        AdlibDisable()
        ; hide/delete progress??
    EndIf
    
    Sleep(200)
    If $Forward Then
        If $x < 100 Then
            $x = $x + 1
        Else
            $Forward = 0
        EndIf
    Else
        If $x > 80 Then
            $x = $x - 60
        Else
            $Forward = 1
        EndIf
    EndIf
    
    
    
WEnd
ProgressOff()

Func pros()
    ProgressSet($x)
EndFunc

8)

NEWHeader1.png

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