AutoHotkey: Auto-Delete BAK-files created by TC's File-Compare-Editor: Difference between revisions
Jump to navigation
Jump to search
(v0.11: added a little support for multiple instances) |
m (re-added handling for TC 7.50 early betas) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
; //////////////////////////////////////////////////////////////////////////// | ; //////////////////////////////////////////////////////////////////////////// | ||
; // TC_CompareEditor_AutoDelBak.ahk v0. | ; // TC_CompareEditor_AutoDelBak.ahk v0.13 | ||
; // (W) StatusQuo 2008 for TC 7. | ; // (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 | ; // 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 | |||
# | ; #Persistent | ||
; SetTimer, l_TC_AutoDelBak | |||
; Return | |||
Loop | Loop | ||
l_TC_AutoDelBak: | |||
{ | { | ||
WinWaitActive, ahk_class TFileCompForm | WinWaitActive, ahk_class TFileCompForm | ||
ControlGetText, sFNLeft , TEdit2 | ControlGetText, sFNLeft , TAltEdit2 ; TC7.50 public beta 7 | ||
ControlGetText, sFNRight, | ControlGetText, sFNRight, TAltEdit1 ; TC7.50 public beta 7 | ||
sBakLeft | if ( (sFNLeft = "") and (sFNRight = "") ) | ||
sBakRight := sFNRight . ".bak" | { | ||
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 | 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") | ||
f_DelBak( | 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 | if not (boFileDeleted = "0") ; no reread if nothing was deleted | ||
{ | { | ||
Line 56: | Line 80: | ||
Back to [[AutoHotkey]] | Back to [[AutoHotkey]] | ||
[[Category:AutoHotkey scripts|Auto-Delete BAK-files created by TC's File-Compare-Editor]] |
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