Jump to content
Sign in to follow this  
webmedic

DELETE GUI help with stop

Recommended Posts

webmedic

I liked the dirms gui so muach nad found another autoit script by this-is-me that did system clean up but was not as complete as I wnated that i combined both of them and came up with a nice little gui app.

I'm only having issues with two little parts that i have not been able to figure out yet.

1) The stop button does not work. I have tired to place it one of the main loops that gets lots of trafic but it still does not stop the current action.

2) This is most likely easy but i have not found it yet. How to update the drive info after the clean function is complete.

Thanks for any help with this.

; ====================================================================================================


=====
; To Do:
;  - remaining timers
;  - TreeList still not resizing correctly
;  - network drive support
; How?
;  - return multiple TreeViewItem selections
; ====================================================================================================


=====

; ======================
; VARIABLES
; ======================
#include <Array.au3>
#include <GUIConstants.au3>
#include <math.au3>
Opt("GUICloseOnESC", 0)
Opt("TrayIconHide", 1)
Opt("WinTitleMatchMode", 4)
If WinExists("%_DELETE_GUI") Then Exit
AutoItWinSetTitle("%_DELETE_GUI_%")
DIM $a, $b, $c, $d, $DriveListing, $fixed_ary, $fixed_name, $fixed_list, $fixed_labels, $fixed_lblsto, $ViewItem, $msg
DIM $fixed_ary = DriveGetDrive("FIXED")
DIM $fixed_ary_upper[1], $fixed_labels[1], $fixed_status[1], $fixed_filesystem[1], $fixed_capacity[1], $fixed_free[1], $time_start[3]
DIM Const $v_title = "DELETE GUI v0.1"
DIM Const $helpfile = "http://www.webmedic.net/delete-gui-vt25254.html"

FileInstall( "img_about.jpg", @scriptdir & "\")

; ======================
; GUI - Formatting
; ======================
$gui_main = GuiCreate($v_title, 500, 194,(@DesktopWidth-500)/2, (@DesktopHeight-194)/2 , $WS_CLIPSIBLINGS + $WS_OVERLAPPEDWINDOW)
WinSetOnTop($v_title, "", 1)

    GUICtrlDelete($DriveListing)
    $DriveListing = GUICtrlCreateListView("Volume   | Status|File System|Capacity|Free Space|% Free Space", 0, 0, 500, 97, $LVS_NOSORTHEADER + $LVS_SHOWSELALWAYS)
    
;//adds drive information to arrays
    For $a = 1 to $fixed_ary[0]
       _ArrayInsert($fixed_ary_upper, $a, StringUpper($fixed_ary[$a]))
       _ArrayInsert($fixed_labels, $a, DriveGetlabel($fixed_ary[$a]))
       _ArrayInsert($fixed_status, $a, DriveStatus($fixed_ary[$a]))
       _ArrayInsert($fixed_filesystem, $a, DriveGetFileSystem($fixed_ary[$a]))
       _ArrayInsert($fixed_capacity, $a, DriveSpaceTotal($fixed_ary[$a]))
       _ArrayInsert($fixed_free, $a, DriveSpaceFree($fixed_ary[$a]))
    Next
;//end drive information arrays
    
;//fixed drive formatting
    For $b = 2 to $fixed_ary[0]
       If $fixed_labels[1] = "" Then
          $fixed_list = $fixed_list & @LF & $fixed_labels[1] & "(" & StringUpper($fixed_ary[1]) & ")"
       Else
          $fixed_list = $fixed_list & @LF & $fixed_labels[1] & " (" & StringUpper($fixed_ary[1]) & ")"
       EndIf
    Next
    $fixed_list = StringSplit($fixed_list, @LF)
    
    For $c = 1 to $fixed_ary[0]   
        If $fixed_labels[$c] = "" Then
            GUICtrlCreateListViewItem($fixed_labels[$c] & "(" & $fixed_ary_upper[$c] & ")" & "|" & $fixed_status[$c]_
            & "|" & $fixed_filesystem[$c] & "|" & Round($fixed_capacity[$c]/1000, 2) & " GB" & "|" & Round($fixed_free[$c]/1000, 2)_
            & " GB" & "|" & Round(100*($fixed_free[$c]/$fixed_capacity[$c]), 0) & " %", $Drivelisting)
        Else
            GUICtrlCreateListViewItem($fixed_labels[$c] & " (" & $fixed_ary_upper[$c] & ")" & "|" & $fixed_status[$c]_
            & "|" & $fixed_filesystem[$c] & "|" & Round($fixed_capacity[$c]/1000, 2) & " GB" & "|" & Round($fixed_free[$c]/1000, 2)_
            & " GB" & "|" & Round(100*($fixed_free[$c]/$fixed_capacity[$c]), 0) & " %", $Drivelisting)
        EndIf
    Next
;//end fixed drive formatting
    
    GUICtrlSetData($DriveListing, $fixed_list)

; ======================
; GUI - Main - Controls
; ======================
$file_menu = GUICtrlCreateMenu ("&File")
    $file_options = GUICtrlCreateMenuitem ("Options", $file_menu)
    $file_seperator = GUICtrlCreateMenuitem ("", $file_menu)
    $file_exit = GUICtrlCreateMenuitem ("Exit     (CTRL+Q)", $file_menu)
$action_menu = GUICtrlCreateMenu ("&Action")
    $action_run = GUICtrlCreateMenuitem ("&Run",$action_menu)
    $action_stop = GUICtrlCreateMenuitem ("&Stop",$action_menu)
    GUICtrlSetState($action_stop, $GUI_DISABLE)
    $action_seperator = GUICtrlCreateMenuitem ("", $action_menu)
    $action_schedule = GUICtrlCreateMenuitem ("&Schedule", $action_menu)
$help_menu = GUICtrlCreateMenu ("&Help")
    $help_topics = GUICtrlCreateMenuitem ("&DELETE GUI Help", $help_menu)
    $help_seperator = GUICtrlCreateMenuitem ("", $help_menu)
    $help_about = GUICtrlCreateMenuitem ("&About", $help_menu)
    
$gui_run = GuiCtrlCreateButton("Run", 10, 110, 100, 30)
$gui_stop = GuiCtrlCreateButton("Stop", 120, 110, 100, 30)
GUICtrlSetState($gui_stop, $GUI_DISABLE)    

$Label_status = GuiCtrlCreateLabel("Status: " & "Idle", 5, 157, 265, 15)
$Label_elapsed = GuiCtrlCreateLabel("Elapsed: ", 280, 157, 220, 15)
$Label_background = GuiCtrlCreateLabel("", 0, 154, 500, 20,BitOr($SS_SIMPLE,$SS_SUNKEN))

$group1 = GuiCtrlCreateGroup("", 0, 95, 500, 55)

$dock_settings = BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKSIZE, $GUI_DOCKVCENTER)
$stat_settings = BitOR($GUI_DOCKLEFT, $GUI_DOCKBOTTOM, $GUI_DOCKHEIGHT, $GUI_DOCKVCENTER)

GUICtrlSetResizing($gui_run, $dock_settings)
GUICtrlSetResizing($gui_stop, $dock_settings)
GUICtrlSetResizing($group1, $stat_settings)
GUICtrlSetResizing($Label_status, $stat_settings)
GUICtrlSetResizing($Label_elapsed, $stat_settings)
GUICtrlSetResizing($Label_background, $stat_settings)

GUISetState()

; ========================================
; GUI - About
; ========================================
$gui_about = GuiCreate('About', 300+51, 161, -1, -1, BitOr($WS_CAPTION, $WS_SYSMENU), -1, $gui_Main)

GUICtrlCreatePic("img_about.jpg", 0, 0, 51, 161)

GuiCtrlCreateLabel($v_title & @LF &_
                   @LF &_
                   'This application provides a GUI interface for ' &_
                   'deleteing temp folders under windows' & @LF & @LF &_
                   'DELETE GUI was created with AutoIt v3 .', 5+51, 5, 290, 85)

$about_visit = GuiCtrlCreateLabel('Visit AutoIt Website', 5+51, 85, 145, 15)
GuiCtrlSetFont(-1, 8, 400, 4)
GuiCtrlSetColor(-1, 0x0000ff)
GuiCtrlSetCursor(-1, 0)
GuiCtrlSetTip(-1, 'http://www.autoitscript.com')
$about_deletegui = GuiCtrlCreateLabel('Visit My Website', 5+51, 100, 125, 15)
GuiCtrlSetFont(-1, 8, 400, 4)
GuiCtrlSetColor(-1, 0x0000ff)
GuiCtrlSetCursor(-1, 0)
GuiCtrlSetTip(-1, 'http://www.webmedic.net')
$about_thread = GuiCtrlCreateLabel('Official DELETE GUI Thread', 5+51, 115, 165, 15)
GuiCtrlSetFont(-1, 8, 400, 4)
GuiCtrlSetColor(-1, 0x0000ff)
GuiCtrlSetCursor(-1, 0)
GuiCtrlSetTip(-1, 'http://www.webmedic.net/delete-gui-vt25254.html')
$about_pethread = GuiCtrlCreateLabel('bart pe DELETE GUI Thread', 5+51, 130, 165, 15)
GuiCtrlSetFont(-1, 8, 400, 4)
GuiCtrlSetColor(-1, 0x0000ff)
GuiCtrlSetCursor(-1, 0)
GuiCtrlSetTip(-1, 'http://www.webmedic.net/delete-gui-vt25254.html')

$about_close = GuiCtrlCreateButton('&Close', 220+51, 130, 75, 25)

; ========================================
; GUI - Options
; ========================================
GLOBAL $StoreTime = FileGetTime(@ScriptDir & "\config.ini", 0, 1)

$gui_options = GuiCreate("Options", 331, 171, -1, -1, BitOr($WS_CAPTION, $WS_SYSMENU), -1, $gui_Main)
    
$action_group = GuiCtrlCreateGroup("Delete folders and files", 2, 0, 147, 140)
    $action_user_files = GuiCtrlCreateCheckbox("User files", 10, 20, 100, 20)
    $action_sys_files = GuiCtrlCreateCheckbox("System files", 10, 40, 100, 20)
    $action_recycler = GuiCtrlCreateCheckbox("Recycle Bin", 10, 60, 100, 20)
    $action_sys_restore = GuiCtrlCreateCheckbox("System Restore", 10, 80, 100, 20)
    
$option_group = GuiCtrlCreateGroup("", 151, 0, 178, 140)
    $option_log = GuiCtrlCreateCheckbox("Write Log", 160, 20, 70, 20)
    $option_shutdown = GuiCtrlCreateCheckbox("Automatic Shutdown", 160, 40, 130, 20)
    $option_status = GuiCtrlCreateCheckbox("Status Bar", 160, 60, 130, 20)
    $option_stop = GuiCtrlCreateCheckbox("Allow Stop", 160, 80, 130, 20)

$option_close = GuiCtrlCreateButton('&Close', 251, 142, 75, 25)

GuiCtrlSetState($action_user_files, INIRead("config.ini", "actions", "User files", $GUI_CHECKED))
GuiCtrlSetState($action_sys_files, INIRead("config.ini", "actions", "Sys files", $GUI_CHECKED))
GuiCtrlSetState($action_recycler, INIRead("config.ini", "actions", "Recycle Bin", $GUI_CHECKED))
GuiCtrlSetState($action_sys_restore, INIRead("config.ini", "actions", "System Restore", $GUI_UNCHECKED))
GuiCtrlSetState($option_log, INIRead("config.ini", "options", "Write Log", $GUI_UNCHECKED))
GuiCtrlSetState($option_shutdown, INIRead("config.ini", "options", "Automatic Shutdown", $GUI_UNCHECKED))
GuiCtrlSetState($option_status, INIRead("config.ini", "options", "Status Bar", $GUI_CHECKED))
GuiCtrlSetState($option_stop, INIRead("config.ini", "options", "Allow Stop", $GUI_CHECKED))

Call("_SetConfigVar")


Func _SetConfigVar()
    
    iniwrite("config.ini", "Actions", "User files", GUICtrlRead($action_sys_files))
    iniwrite("config.ini", "Actions", "Sys files", GUICtrlRead($action_sys_files))
    iniwrite("config.ini", "Actions", "Recycle Bin", GUICtrlRead($action_recycler))
    iniwrite("config.ini", "Actions", "System Restore", GUICtrlRead($action_sys_restore))
    iniwrite("config.ini", "Options", "Write Log", GUICtrlRead($option_log))
    iniwrite("config.ini", "Options", "Automatic Shutdown", GUICtrlRead($option_shutdown))
    iniwrite("config.ini", "Options", "Status Bar", GUICtrlRead($option_status))
    iniwrite("config.ini", "Options", "Allow Stop", GUICtrlRead($option_stop))
    
    GLOBAL $StoreTime = FileGetTime(@ScriptDir & "\config.ini", 0, 1)
        
EndFunc


; ==========================
; GUI - Loop
; ==========================
While 1
    
    If WinActive($v_title) Then
        Hotkeyset("^q", "ExitScript")
    Else
        Hotkeyset("^q")
    EndIf
    
    If $StoreTime <> FileGetTime(@ScriptDir & "\config.ini", 0, 1) Then Call("_SetConfigVar")
    
    $msg = GUIGetMsg(1)
        
    If $msg[1] = $gui_main Then
        
        Select
        
            Case $msg[0] = $file_exit
                Return -3
        
            Case $msg[0] = -3
                ExitScript()
                    
            Case $msg[0] = $action_run
                _BtnRun()               
                
            Case $msg[0] = $gui_run
                _BtnRun()
                
                
            Case $msg[0] = $help_topics
                _Start($helpfile)
                
            Case $msg[0] = $help_about
                $gui_pos = WinGetPos($v_title, "")
                ControlMove ("About", "", $gui_about, $gui_pos[0] + (($gui_pos[2] / 2) - 165) - 300, $gui_pos[1] + (($gui_pos[3] / 2) - 90) - 110)
                GuiSetState(@SW_SHOW, $gui_about)
                
            Case $msg[0] = $file_options
                $gui_pos = WinGetPos($v_title, "")
                ControlMove ("About", "", $gui_options, $gui_pos[0] + (($gui_pos[2] / 2) - 150) - 300, $gui_pos[1] + (($gui_pos[3] / 2) - 100) - 110)
                GuiSetState(@SW_SHOW, $gui_options)
            
        EndSelect
            
    ElseIf $msg[1] = $gui_about Then
            
        Select
            
            Case $msg[0] = -3
                GuiSetState(@SW_HIDE, $gui_about)
        
            Case $msg[0] = $about_close
                GuiSetState(@SW_HIDE, $gui_about)
                
            Case $msg[0] = $about_visit
                _Start('http://www.autoitscript.com')
            
            Case $msg[0] = $about_deletegui
                _Start('http://www.webmedic.net')
                
            Case $msg[0] = $about_thread
                _Start('http://www.webmedic.net/delete-gui-vt25254.html')

            Case $msg[0] = $about_pethread
                _Start('http://www.webmedic.net/delete-gui-vt25254.html')

        EndSelect
        
    ElseIf $msg[1] = $gui_options Then
        
        Select
            
            Case $msg[0] = -3 
                GuiSetState(@SW_HIDE, $gui_options)
                
            Case $msg[0] = $option_close
                GuiSetState(@SW_HIDE, $gui_options)
                
            Case $msg[0] <> -3 OR <> $option_close
                _SetConfigVar()
                
        EndSelect
            
    EndIf
        
WEnd

Exit

; ==========================
; Functions
; ==========================
Func _BtnRun()
    If GUICtrlRead($DriveListing) = 0 Then Return
    GLOBAL $d_drive_ary = StringSplit(GUICtrlRead(GUICtrlRead($DriveListing)), "()")
;   GLOBAL $d_letter = StringTrimRight($d_drive_ary[2], 1)
    GLOBAL $d_letter = $d_drive_ary[2]
    BeginDelete()
EndFunc

func BeginDelete()
    GLOBAL $elapsed_start = TimerStart()
    GUICtrlSetState($gui_run, $GUI_DISABLE)
    GUICtrlSetState($gui_stop, $GUI_ENABLE)
    GUICtrlSetState($action_run, $GUI_DISABLE)
    GUICtrlSetState($action_stop, $GUI_ENABLE)

  GLOBAL $tmptotal = 0
  if DriveStatus($d_letter & "\") = "READY" then

    if GUICtrlRead($action_sys_files) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Deleting Users temp files - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      if FileExists($d_letter & "\Documents And Settings\") then
        $users = FileFindFirstFile($d_letter & "\Documents And Settings\*.*")
        If $users <> -1 Then
          while 1
            $cuser = FileFindNextFile($users)
            If @error Then ExitLoop
            if $cuser = "All Users" or $cuser = "Default User" or $cuser = "LocalService" or $cuser = "NetworkService" or $cuser = "." or $cuser = ".." then ContinueLoop
            delcont($d_letter & "\Documents And Settings\" & $cuser & "\Local Settings\Temp", "", 0)
            delcont($d_letter & "\Documents And Settings\" & $cuser & "\Local Settings\Temporary Internet Files\Content.IE5", ".txt", 0)
          wend
        endif
        FileClose($users)
      endif
      if FileExists($d_letter & "\WINNT\Profiles\") then
        $users = FileFindFirstFile($d_letter & "\WINNT\Profiles\*.*")
        If $users <> -1 Then
          while 1
            $cuser = FileFindNextFile($users)
            If @error Then ExitLoop
            if $cuser = "All Users" or $cuser = "Default User" or $cuser = "LocalService" or $cuser = "NetworkService" or $cuser = "." or $cuser = ".." then ContinueLoop
            delcont($d_letter & "\WINNT\Profiles\" & $cuser & "\Local Settings\Temp", "", 0)
            delcont($d_letter & "\WINNT\Profiles\" & $cuser & "\Local Settings\Temporary Internet Files\Content.IE5", ".txt", 0)
          wend
        endif
        FileClose($users)
      endif
    endif

    if GUICtrlRead($action_sys_files) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Deleting system temp files - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      delcont($d_letter & "\Windows\Temp", "", 0)
      delcont($d_letter & "\Windows\msdwnload.dir", "", 0)
      delcont($d_letter & "\WINNT\Temp", "", 0)
      delcont($d_letter & "\WINNT\msdwnload.dir", "", 0)
      delcont($d_letter & "\Temp", "", 0)
      delcont($d_letter & "\Windows\Temporary Internet Files\Content.IE5", ".txt", 0)
    endif
    
    if GUICtrlRead($action_recycler) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Empty recycle bin - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      delcont($d_letter & "\RECYCLER", "", 0)
    endif

    if GUICtrlRead($action_sys_restore) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Deleting System Restore - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      delcont($d_letter & "\System Volume Information", "", 0)
    endif
  endif
  GUICtrlSetState($gui_run, $GUI_ENABLE)
    GUICtrlSetState($gui_stop, $GUI_DISABLE)
    GUICtrlSetState($action_run, $GUI_ENABLE)
    GUICtrlSetState($action_stop, $GUI_DISABLE)
    GUICtrlSetData($Label_status, "Status: " & "Deleted a total of " & $tmptotal & " temporary files")
EndFunc


func delcont($folder, $filespec, $dlfldr)
 if not FileExists($folder) then return
 if StringInStr(FileGetAttrib($folder), "D") then
  $cur = FileFindFirstFile($folder & "\*")
  While 1
      Select

            Case $msg = $gui_stop
                GUICtrlSetState($gui_run, $GUI_ENABLE)
                GUICtrlSetState($gui_stop, $GUI_DISABLE)
                GUICtrlSetState($action_run, $GUI_ENABLE)
                GUICtrlSetState($action_stop, $GUI_DISABLE)
                GUICtrlSetData($Label_status, "Status: " & "Idle")
                SetError(1)

            Case $msg = $action_stop
                GUICtrlSetState($gui_run, $GUI_ENABLE)
                GUICtrlSetState($gui_stop, $GUI_DISABLE)
                GUICtrlSetState($action_run, $GUI_ENABLE)
                GUICtrlSetState($action_stop, $GUI_DISABLE)
                GUICtrlSetData($Label_status, "Status: " & "Idle")
                SetError(1)

            Case $msg = $GUI_EVENT_CLOSE
                ExitScript()

        EndSelect
        Sleep(10)
   $curfile = FileFindNextFile($cur)
   If @error Then ExitLoop
   if $curfile = "." or $curfile = ".." then ContinueLoop
   if StringInStr(FileGetAttrib($folder & "\" & $curfile), "D") then
    delcont($folder & "\" & $curfile, $filespec, 1)
   else
    if $filespec = "" then
     mydel($folder & "\" & $curfile)
    else
     if not StringInStr($curfile, $filespec) then
      mydel($folder & "\" & $curfile)
     endif
    endif
   endif
  WEnd
  FileClose($cur)
  if $dlfldr = 1 then rmifempty($folder)
 endif
endfunc

func mydel($fl)
 if StringInStr(FileGetAttrib($fl), "R") then FileSetAttrib($fl, "-R")
 $tst = FileDelete($fl)
 if $tst <> 0 then $tmptotal = $tmptotal + 1
; ToolTip("Files Deleted: " & $tmptotal); & @LF & "Current File: " & $fl
  ;// elapsed time
    GLOBAL $elapsed_end = TimerDiff($elapsed_start)/1000;elapsed time in seconds
    $elapsed_hour = Int($elapsed_end / 3600)
    $elapsed_min = Int(($elapsed_end - ($elapsed_hour * 3600)) / 60)
    $elapsed_sec = Round($elapsed_end - Int($elapsed_end / 60) * 60, 0)
  If $elapsed_end < 60 Then
        $elapsed_calc = $elapsed_sec & " seconds";Int displays smallest integer only
    ElseIf $elapsed_end < 3600 Then
        $elapsed_calc = $elapsed_min & " min " & $elapsed_sec & " seconds"
    Else
        $elapsed_calc = $elapsed_hour & " hour " & $elapsed_min & " min " & $elapsed_sec & " seconds"
        $msg = GuiGetMsg()
    EndIf
    If $elapsed_hour > 999 Then $elapsed_calc = "Out of range"

    GUICtrlSetData($Label_elapsed, "Elapsed: " & $elapsed_calc)
;// end elapsed time


endfunc

func rmifempty($fl)
 $fld = FileFindFirstFile($fl & "\*")
  While 1
   $fldr = FileFindNextFile($fld)
   If @error Then ExitLoop
   if $fldr = "." or $fldr = ".." then ContinueLoop
   return
  WEnd
 FileClose($fld)
DirRemove($fl)
endfunc

Func Timer()
    $time_current = @HOUR & ":" &@MIN & ":" & @SEC
EndFunc

Func _Start($s_StartPath)
    If @OSType = 'WIN32_NT' Then
        $s_StartStr = @ComSpec & ' /c start "" '
    Else
        $s_StartStr = @ComSpec & ' /c start '
    EndIf
    
    Run($s_StartStr & $s_StartPath, '', @SW_HIDE)
EndFunc

Func ExitScript()
    GUIDelete()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
webmedic

thanks for looking at any rate I'll try

ok I have these functions

func delcont($folder, $filespec, $dlfldr)
 if not FileExists($folder) then return
 if StringInStr(FileGetAttrib($folder), "D") then
  $cur = FileFindFirstFile($folder & "\*")
  While 1
      Select

            Case $msg = $gui_stop
                GUICtrlSetState($gui_run, $GUI_ENABLE)
                GUICtrlSetState($gui_stop, $GUI_DISABLE)
                GUICtrlSetState($action_run, $GUI_ENABLE)
                GUICtrlSetState($action_stop, $GUI_DISABLE)
                GUICtrlSetData($Label_status, "Status: " & "Idle")
                SetError(1)

            Case $msg = $action_stop
                GUICtrlSetState($gui_run, $GUI_ENABLE)
                GUICtrlSetState($gui_stop, $GUI_DISABLE)
                GUICtrlSetState($action_run, $GUI_ENABLE)
                GUICtrlSetState($action_stop, $GUI_DISABLE)
                GUICtrlSetData($Label_status, "Status: " & "Idle")
                SetError(1)

            Case $msg = $GUI_EVENT_CLOSE
                ExitScript()

        EndSelect
        Sleep(10)
   $curfile = FileFindNextFile($cur)
   If @error Then ExitLoop
   if $curfile = "." or $curfile = ".." then ContinueLoop
   if StringInStr(FileGetAttrib($folder & "\" & $curfile), "D") then
    delcont($folder & "\" & $curfile, $filespec, 1)
   else
    if $filespec = "" then
     mydel($folder & "\" & $curfile)
    else
     if not StringInStr($curfile, $filespec) then
      mydel($folder & "\" & $curfile)
     endif
    endif
   endif
  WEnd
  FileClose($cur)
  if $dlfldr = 1 then rmifempty($folder)
 endif
endfunc

that get called from the main function. In the delcont function I would like to be able to use the stop button to stop what it is currently working on but for some reason the stop button is completely ignored. Is this becasue it is cycleing so fast that there is bascily no way for me to be able to use the stop button? That covers teh fisrt question.

For the second I'm trying to get the free space on the drive to autoupdate itself after the maun function is done with it's work.

func BeginDelete()
    GLOBAL $elapsed_start = TimerStart()
    GUICtrlSetState($gui_run, $GUI_DISABLE)
    GUICtrlSetState($gui_stop, $GUI_ENABLE)
    GUICtrlSetState($action_run, $GUI_DISABLE)
    GUICtrlSetState($action_stop, $GUI_ENABLE)

  GLOBAL $tmptotal = 0
  if DriveStatus($d_letter & "\") = "READY" then

    if GUICtrlRead($action_sys_files) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Deleting Users temp files - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      if FileExists($d_letter & "\Documents And Settings\") then
        $users = FileFindFirstFile($d_letter & "\Documents And Settings\*.*")
        If $users <> -1 Then
          while 1
            $cuser = FileFindNextFile($users)
            If @error Then ExitLoop
            if $cuser = "All Users" or $cuser = "Default User" or $cuser = "LocalService" or $cuser = "NetworkService" or $cuser = "." or $cuser = ".." then ContinueLoop
            delcont($d_letter & "\Documents And Settings\" & $cuser & "\Local Settings\Temp", "", 0)
            delcont($d_letter & "\Documents And Settings\" & $cuser & "\Local Settings\Temporary Internet Files\Content.IE5", ".txt", 0)
          wend
        endif
        FileClose($users)
      endif
      if FileExists($d_letter & "\WINNT\Profiles\") then
        $users = FileFindFirstFile($d_letter & "\WINNT\Profiles\*.*")
        If $users <> -1 Then
          while 1
            $cuser = FileFindNextFile($users)
            If @error Then ExitLoop
            if $cuser = "All Users" or $cuser = "Default User" or $cuser = "LocalService" or $cuser = "NetworkService" or $cuser = "." or $cuser = ".." then ContinueLoop
            delcont($d_letter & "\WINNT\Profiles\" & $cuser & "\Local Settings\Temp", "", 0)
            delcont($d_letter & "\WINNT\Profiles\" & $cuser & "\Local Settings\Temporary Internet Files\Content.IE5", ".txt", 0)
          wend
        endif
        FileClose($users)
      endif
    endif

    if GUICtrlRead($action_sys_files) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Deleting system temp files - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      delcont($d_letter & "\Windows\Temp", "", 0)
      delcont($d_letter & "\Windows\msdwnload.dir", "", 0)
      delcont($d_letter & "\WINNT\Temp", "", 0)
      delcont($d_letter & "\WINNT\msdwnload.dir", "", 0)
      delcont($d_letter & "\Temp", "", 0)
      delcont($d_letter & "\Windows\Temporary Internet Files\Content.IE5", ".txt", 0)
    endif
    
    if GUICtrlRead($action_recycler) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Empty recycle bin - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      delcont($d_letter & "\RECYCLER", "", 0)
    endif

    if GUICtrlRead($action_sys_restore) = $GUI_CHECKED then
      GUICtrlSetData($Label_status, "Status: " & "Deleting System Restore - " & $d_drive_ary[1] & "(" &$d_drive_ary[2] & ")")
      delcont($d_letter & "\System Volume Information", "", 0)
    endif
  endif
  GUICtrlSetState($gui_run, $GUI_ENABLE)
    GUICtrlSetState($gui_stop, $GUI_DISABLE)
    GUICtrlSetState($action_run, $GUI_ENABLE)
    GUICtrlSetState($action_stop, $GUI_DISABLE)
    GUICtrlSetData($Label_status, "Status: " & "Deleted a total of " & $tmptotal & " temporary files")
    For $c = 1 to $fixed_ary[0]
      If $fixed_labels[$c] = "" Then
            GUICtrlSetData($fixed_labels[$c] & "(" & $fixed_ary_upper[$c] & ")" & "|" & $fixed_status[$c]_
            & "|" & $fixed_filesystem[$c] & "|" & Round($fixed_capacity[$c]/1000, 2) & " GB" & "|" & Round($fixed_free[$c]/1000, 2)_
            & " GB" & "|" & Round(100*($fixed_free[$c]/$fixed_capacity[$c]), 0) & " %", $Drivelisting)
        Else
            GUICtrlSetData($fixed_labels[$c] & " (" & $fixed_ary_upper[$c] & ")" & "|" & $fixed_status[$c]_
            & "|" & $fixed_filesystem[$c] & "|" & Round($fixed_capacity[$c]/1000, 2) & " GB" & "|" & Round($fixed_free[$c]/1000, 2)_
            & " GB" & "|" & Round(100*($fixed_free[$c]/$fixed_capacity[$c]), 0) & " %", $Drivelisting)
        EndIf
    Next

EndFunc

This is waht I currently hav eand it differes from my first post. At teh very bottom of the function if I use GUICtrlCreateListViewItem then it does indeed creat a new item but I dont want a new item i jsut want to update the info that is already there so that the new free space ammount will be shown. For now I'm trying to use GUICtrlSetData but that does not seem to be updateing the displayed data. I have also set the variables in use at the top of the script to global.

Share this post


Link to post
Share on other sites
webmedic

Hm that did not solve it though. ALthough i can press on teh stop button it does not stop the action from continuing.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.