Announcement: Autohotkey Script for skipping file copy errors

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
User avatar
aviasd
Junior Member
Junior Member
Posts: 66
Joined: 2013-07-02, 18:28 UTC
Location: Israel

Announcement: Autohotkey Script for skipping file copy errors

Post by *aviasd »

Hi,

This is a continuation of viewtopic.php?p=384543#p384543

The following is a very simplistic AutoHotKey script that Detects File copy error dialogs and auto presses skip all.
It monitors F5,F6 inside TC.

Control Disables the functionality
Shift Re-Enables it

Script runs until all Copy/Move confirmation dialogs are closed and no Copy Progress dialogs exist (Foreground/Background)
If anyone has any suggestions on improoving the script, I'd be happy for suggestions...

Code: Select all

#singleinstance,force
#persistent
#NoEnv

TrayTipEnabled:=true
ScriptName=TC AutoSkip
~F5::
~F6::
  If WinActive("ahk_class TTOTAL_CMD")
    AutoSkip()
  return

AutoSkip() {
  global ScriptName
  RunningNotificationInterval:=10
  Tip("Monitoring For File operation errors...")
  loop, 
  {
    winwaitactive, ahk_class TExtMsgForm,,1
    WinGet,ActiveProcess,ProcessName,A
    if (GetKeyState("Shift", "P") and IsTcProcess(ActiveProcess)) {
      Tip("AutoSkip Enabled")
      Ignore:=0
    }
    if (GetKeyState("Control", "P") and Ignore!=1 and IsTcProcess(ActiveProcess)) {
      Tip("AutoSkip Disabled")
      Ignore:=1
    }
    If (WinActive("ahk_class TExtMsgForm") and Ignore!=1) {
      Tip("Skipping All Errors...")
      Sleep,500
      Send,!k
    }

    if (mod(a_index,RunningNotificationInterval)=0 )
      Tip(ScriptName . " still running...")

    ;The following is to prevent endless loop of winwaitactive which causes 0.03 Cpu usage. 
    ;TDLG2FILEACTIONMIN - is Foreground copy progress window, TInpComboDlg - is TC copy/move dialog;
    ;#32770 is a standard window class for file open dialog
    if (!WinExist("ahk_class TDLG2FILEACTIONMIN") and !TcDialogsExist() and !TcDialogsExist("ahk_class TInpComboDlg")) {
      Tip(ScriptName . " Exiting...")
      return
    }
  }
}

Tip(Message) {
  global TrayTipEnabled,ScriptName
  if (TrayTipEnabled)
    TrayTip,%ScriptName%,%Message%
}

IsTcProcess(ProcessName) {
  if (regexmatch(ProcessName,"i)TotalCmd(64)?.exe")>0)
    return true
  return false
}

TcDialogsExist(TC_Copy_Dialog:="ahk_class #32770") {
  if (WinExist(TC_Copy_Dialog)) {
    WinGet, AllMatchingWindows , List, %TC_Copy_Dialog%
    ;;Tip("%AllMatchingWindows%")
    Loop,%AllMatchingWindows% {
      Item := AllMatchingWindows%a_index%
      winGet,ProcessName,ProcessName,ahk_id %item%
      ;Tip("%ProcessName%")
      if IsTcProcess(ProcessName)
        return True
    }
  }
  return false
}

A glance to the future: What will Total commander be like in 10 years from now?
Now: Tc 9.51 Final

Post Reply