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

From TotalcmdWiki
Jump to navigation Jump to search
(Added category AutoHotkey scripts)
(updated for TC 7.50 (tested up to beta 10))
Line 1: Line 1:
<pre>
<pre>
; ////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////
; // TC_CompareEditor_AutoDelBak.ahk v0.11
; // TC_CompareEditor_AutoDelBak.ahk v0.12
; // (W) StatusQuo 2008 for TC 7.03
; // (W) StatusQuo 2008-2009 for TC 7.0x, TC 7.50 (tested up to beta 10)
; //--------------------------------------------------------------------------
; //--------------------------------------------------------------------------
; // Auto-deletes *.bak-files created by TC's File-Compare-Editor  
; // Auto-deletes *.bak-files created by TC's File-Compare-Editor  
Line 12: Line 12:
; // (first close the one which was opened first).
; // (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


#SingleInstance, Force
; #Persistent
; SetTimer, l_TC_AutoDelBak
; Return


Loop
Loop
l_TC_AutoDelBak:
{
{
WinWaitActive, ahk_class TFileCompForm
WinWaitActive, ahk_class TFileCompForm
ControlGetText, sFNLeft , TEdit2
ControlGetText, sFNLeft , TAltEdit.UnicodeClass2 ; TC7.50
ControlGetText, sFNRight, TEdit1
ControlGetText, sFNRight, TAltEdit.UnicodeClass1 ; TC7.50
if ( (sFNLeft = "") and (sFNRight = "") )
{
ControlGetText, sFNLeft , TEdit2 ; TC7.0x up to 7.04a
ControlGetText, sFNRight, TEdit1 ; TC7.0x up to 7.04a
}
sBakLeft  := sFNLeft  . ".bak"
sBakLeft  := sFNLeft  . ".bak"
sBakRight := sFNRight . ".bak"
sBakRight := sFNRight . ".bak"
SetTitleMatchMode, Slow ; needed for TC 7.50
Loop ; wait for compare-editor to close
Loop ; wait for compare-editor to close
{
{
Sleep, 500 ; save CPU time
Sleep, 500 ; save CPU time
IfWinNotExist, ahk_class TFileCompForm, %sFNLeft%,
IfWinNotExist, ahk_class TFileCompForm, %sFNLeft%
IfWinNotExist, ahk_class TFileCompForm, %sFNRight%
Break
Break
}
}
SetTitleMatchMode, Fast ; back to standard; needed for TC 7.50
boFileDeleted := "0"
boFileDeleted := "0"
if not ( f_DelBak( sBakLeft  ) = "10")
if not ( f_DelBak( sBakLeft  ) = "10")

Revision as of 21:23, 23 February 2009

	; ////////////////////////////////////////////////////////////////////////////
	; // TC_CompareEditor_AutoDelBak.ahk v0.12
	; // (W) StatusQuo 2008-2009 for TC 7.0x, TC 7.50 (tested up to beta 10)
	; //--------------------------------------------------------------------------
	; // 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 , TAltEdit.UnicodeClass2	; TC7.50
		ControlGetText, sFNRight, TAltEdit.UnicodeClass1	; TC7.50
		if ( (sFNLeft = "") and (sFNRight = "") )
		{
			ControlGetText, sFNLeft , TEdit2	; TC7.0x up to 7.04a
			ControlGetText, sFNRight, TEdit1	; TC7.0x up to 7.04a
		}
		sBakLeft  := sFNLeft  . ".bak"
		sBakRight := sFNRight . ".bak"
		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")
			f_DelBak( sBakRight )
		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