Jump to content
Sign in to follow this  
ParSalian

RunWait / ShellExecuteWait problem: Waiting beyond end

Recommended Posts

ParSalian

Hello.

I'm trying a little utility to "archive" files. The environment is a server wich generates literally thousands of files, and we shouldn't delete them in some time. But managing files manually (you know, open folder and try to navigate) were becoming impossible. So i did a little app which classifies files into subfolders, depending on the file date. That's done. But i'd like to go beyond that and rchive them into ZIP or so.

This is the problem: When i call Runwait or ShellExecuteWait it works, but the autoit script stalls until I move the mouse over the Tray Icon. No need to click nowhere, just moving cursor on icon works. Then it continues on ne┬║xt file, working perfectly until some other file repeats the problem: program stalled, move cursor, everything ok.

There are some inits, and some interface, and then a function:

$search = FileFindFirstFile("*.*")
  If $search = -1 Then
    return -1
    EndIf
  While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    if StringInStr(FileGetAttrib($file),"D") then ContinueLoop
    $total = $Resul[0][0]+1
    $Resul[0][0] = $total
    $Resul[1][0] = $file
    $Resul[1][1] = FileGetTime($file)
    $temp = $Resul[1][1]
    GUICtrlSetData($Progreso,$per)
    $LimiteFechaTxt = GUICtrlRead($LimiteFecha)
    $LimiteHoraTxt  = TAF("0" & GUICtrlRead($LimiteHora),8)
    $LimitarAntig   = (GUICtrlRead($B_Limitar) == $GUI_CHECKED)
    If $LimitarAntig and ($temp[0]&$temp[1]&$temp[2]&$temp[3]&$temp[4]&$temp[5] > StringRight($LimiteFechaTxt,4)&StringMid($LimiteFechaTxt,4,2)&StringLeft($LimiteFechaTxt,2)&StringMid($LimiteHoraTxt,1,2)&StringMid($LimiteHoraTxt,4,2)&StringMid($LimiteHoraTxt,7,2)) Then
      $r = -42
    Else
      if (not ($Comprimir)) then
        $r = FileMove($file, $sub & "\" & $file, 9)
      else
        $Comando7z  = '"' & @ScriptDir & '\7za.exe"'
        $Parametros7z = ' a ' & $Sub & $Extension & ' "' & @WorkingDir & "\" & $file &'"'
        $r =  RunWait($Comando7z & $Parametros7z,"",@SW_HIDE)
        ;r = ShellExecuteWait($Comando7z,$Parametros7z,@ScriptDir,"",@SW_HIDE)
        if (@error == 0) Then
          if ($r == 0) Then
            FileDelete($file)
            EndIf
          $r = 1 - $r ; NOTE: FileMove and RunWait differ on return values... this is in order to equal both of them
          EndIf
        EndIf
      EndIf
    if ($Log) Then
      If ($r == 1) then
        $z = @YEAR & @MON & @MDAY & " " & @HOUR & @MIN & "  [OK] "
      else
        $z = @YEAR & @MON & @MDAY & " " & @HOUR & @MIN & "  [--] "
        EndIf
      $z &= "Destino: " & $sub & "; Fichero: " & $file
      FileWriteLine($Fichero,$z)
      EndIf
    WEnd
  FileClose($search)
  FileChangeDir(@ScriptDir)

As you can see there is some checking: if the file is older than a datetime, return -42, else do it. (TAF is a function that cuts texts based on lenght, with options)

Not sure if my problem is due to 7ZA.Exe forking in subprocesses and autoit losing its track... but the fact is that i need to be in front of app for it to not hang (or create another script for moving mouse over icon ^^)

Any idea?

thanks id advance (and sorry if I've mistaken my english... spaniard learning chinese here)

[EDIT: ]

The function is slightly different from the real one, i've tried to remove some extra code dedicated to GUI / TrayIcon messaging, not sure if I've deleted ore than I should. Script is still unfinished, so there will be bugs - you know, undocumented features :graduated:)

Edited by ParSalian

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  

×