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

From TotalcmdWiki
Jump to navigation Jump to search
No edit summary
 
(v0.11: added a little support for multiple instances)
Line 1: Line 1:
<pre>
<pre>
; ////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////
; // TC_CompareEditor_AutoDelBak.ahk v0.1
; // TC_CompareEditor_AutoDelBak.ahk v0.11
; // (W) StatusQuo 2008 for TC 7.03
; // (W) StatusQuo 2008 for TC 7.03
; //--------------------------------------------------------------------------
; //--------------------------------------------------------------------------
; // Auto-deletes *.bak-files created by TC's File-Compare-Editor  
; // Auto-deletes *.bak-files created by TC's File-Compare-Editor  
; // (after confirmation)
; // (after confirmation)
; // Only works with a single instance of TC's compare window for now.
; //
; // 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).
; ////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////


Line 21: Line 25:
{
{
Sleep, 500 ; save CPU time
Sleep, 500 ; save CPU time
IfWinNotExist, ahk_class TFileCompForm
IfWinNotExist, ahk_class TFileCompForm, %sFNLeft%,
Break
Break
}
}
boFileDeleted := "0"
if not ( f_DelBak( sBakLeft  ) = "10")
if not ( f_DelBak( sBakLeft  ) = "10")
f_DelBak( sBakRight )
f_DelBak( sBakRight )
Sleep, 200
if not (boFileDeleted = "0") ; no reread if nothing was deleted
PostMessage, 1075, 540,,, ahk_class TTOTAL_CMD ; cm_RereadSource
{
; Sleep, 200
PostMessage, 1075, 540,,, ahk_class TTOTAL_CMD ; cm_RereadSource
}
}
}
Return
Return
Line 33: Line 41:
f_DelBak( sFNBak )
f_DelBak( sFNBak )
{
{
global boFileDeleted
IfNotExist, %sFNBak%
IfNotExist, %sFNBak%
Return
Return
Line 39: Line 48:
Return, 10
Return, 10
IfMsgBox, Yes
IfMsgBox, Yes
{
FileRecycle, %sFNBak%
FileRecycle, %sFNBak%
boFileDeleted := "1"
}
}
}
</pre>
</pre>


Back to [[AutoHotkey]]
Back to [[AutoHotkey]]

Revision as of 23:03, 30 May 2008

	; ////////////////////////////////////////////////////////////////////////////
	; // TC_CompareEditor_AutoDelBak.ahk v0.11
	; // (W) StatusQuo 2008 for TC 7.03
	; //--------------------------------------------------------------------------
	; // 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).
	; ////////////////////////////////////////////////////////////////////////////

	#SingleInstance, Force

	Loop
	{
		WinWaitActive, ahk_class TFileCompForm
		ControlGetText, sFNLeft , TEdit2
		ControlGetText, sFNRight, TEdit1
		sBakLeft  := sFNLeft  . ".bak"
		sBakRight := sFNRight . ".bak"
		Loop	; wait for compare-editor to close
		{
			Sleep, 500	; save CPU time
			IfWinNotExist, ahk_class TFileCompForm, %sFNLeft%,
				Break
		}
		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