AutoHotkey: Auto-Delete BAK-files created by TC's File-Compare-Editor: Difference between revisions

From TotalcmdWiki
Jump to navigation Jump to search
(Updated new control names and double backup files (tested up to public beta 7))
m (re-added handling for TC 7.50 early betas)
 
Line 31: Line 31:
ControlGetText, sFNLeft , TEdit2 ; TC7.0x up to 7.04a
ControlGetText, sFNLeft , TEdit2 ; TC7.0x up to 7.04a
ControlGetText, sFNRight, TEdit1 ; TC7.0x up to 7.04a
ControlGetText, sFNRight, TEdit1 ; TC7.0x up to 7.04a
}
if ( (sFNLeft = "") and (sFNRight = "") )
{
ControlGetText, sFNLeft , TAltEdit.UnicodeClass2 ; TC7.50 early betas
ControlGetText, sFNRight, TAltEdit.UnicodeClass1 ; TC7.50 early betas
}
}
sBakLeft  := sFNLeft  . ".bak"
sBakLeft  := sFNLeft  . ".bak"

Latest revision as of 20:44, 9 July 2009

	; ////////////////////////////////////////////////////////////////////////////
	; // TC_CompareEditor_AutoDelBak.ahk v0.13
	; // (W) StatusQuo 2008-2009 for TC 7.0x, TC 7.50 (tested up to public beta 7)
	; //--------------------------------------------------------------------------
	; // Auto-deletes *.bak-files created by TC's File-Compare-Editor 
	; // (after confirmation)
	; //
	; // Full support is only included for a single instance of TC's compare window -
	; // for now, to have the BAK files of multiple instances deleted, you have to 
	; // close the compare windows in the same order you opened them
	; // (first close the one which was opened first).
	; ////////////////////////////////////////////////////////////////////////////
	
	; http://www.ghisler.ch/wiki/index.php?title=AutoHotkey:_Auto-Delete_BAK-files_created_by_TC%27s_File-Compare-Editor
	
	#SingleInstance, Force

	; #Persistent
	; SetTimer, l_TC_AutoDelBak
	; Return

	Loop
l_TC_AutoDelBak:
	{
		WinWaitActive, ahk_class TFileCompForm
		ControlGetText, sFNLeft , TAltEdit2	; TC7.50 public beta 7
		ControlGetText, sFNRight, TAltEdit1	; TC7.50 public beta 7
		if ( (sFNLeft = "") and (sFNRight = "") )
		{
			ControlGetText, sFNLeft , TEdit2	; TC7.0x up to 7.04a
			ControlGetText, sFNRight, TEdit1	; TC7.0x up to 7.04a
		}
		if ( (sFNLeft = "") and (sFNRight = "") )
		{
			ControlGetText, sFNLeft , TAltEdit.UnicodeClass2	; TC7.50 early betas
			ControlGetText, sFNRight, TAltEdit.UnicodeClass1	; TC7.50 early betas
		}
		sBakLeft   := sFNLeft  . ".bak"
		sBakRight  := sFNRight . ".bak"
		sBakLeft2  := sFNLeft  . ".bk2"
		sBakRight2 := sFNRight . ".bk2"
		SetTitleMatchMode, Slow	; needed for TC 7.50
		Loop	; wait for compare-editor to close
		{
			Sleep, 500	; save CPU time
			IfWinNotExist, ahk_class TFileCompForm, %sFNLeft%
			IfWinNotExist, ahk_class TFileCompForm, %sFNRight%
				Break
		}
		SetTitleMatchMode, Fast	; back to standard; needed for TC 7.50
		boFileDeleted := "0"
		if not ( f_DelBak( sBakLeft  ) = "10")
		if not ( f_DelBak( sBakLeft2 ) = "10")
		if not ( f_DelBak( sBakRight ) = "10")
			f_DelBak( sBakRight2 )
		if not (boFileDeleted = "0")	; no reread if nothing was deleted
		{
			; Sleep, 200
			PostMessage, 1075, 540,,, ahk_class TTOTAL_CMD	; cm_RereadSource
		}
	}
	Return
	
f_DelBak( sFNBak )
{
	global boFileDeleted
	IfNotExist, %sFNBak%
		Return
	MsgBox, 35,, Delete Backup file?`n`n%sFNBak%
	IfMsgBox, Cancel
		Return, 10
	IfMsgBox, Yes
	{
		FileRecycle, %sFNBak%
		boFileDeleted := "1"
	}
}

Back to AutoHotkey