Here the AHK script from Balderstrom which is no longer available on the forum link.
Code: Select all
;;
;; TC_SelectSequence.ahk
;; v2.40
;; Balderstrom, Nov.2010
;;
#SingleInstance, Force
#NoEnv
SetBatchLInes, -1
SendMode Input
nArgs=%0%
ReadArgs(nArgs)
return
ReadArgs(nArgs=0)
{
Loop, % nArgs
{
editFindStr:=(editFindStr || %A_Index%=="/edit")
matchAnyNum:=(matchAnyNum || %A_Index%=="/anynum")
locateBrace:=(locateBrace || %A_Index%=="/braces")
}
TC_SelectSequence(editFindStr, matchAnyNum, locateBrace)
return
}
ExitNow(key="")
{
Send, % key ? key : ""
ExitApp
}
TC_SelectSequenceAutoSave()
{
WinWaitActive, ahk_class TSTDTREEDLG
ControlSetText, TAltEdit1, TC_SelectSequence, A
Send, {Enter}
WinWaitActive, ahk_class #32770,,1
if( !ErrorLevel )
Send, {Enter}
WinWaitActive, ahk_class TCOMBOINPUT
ExitNow("{Enter}")
}
TC_SelectSequence(editFindStr="", matchAnyNum="", locateBrace="")
{
aPanel:=QueryActivePanelID( cID1, cID2)
aText:=LB_QueryText(aPanel, cPos:=LB_FindCursorPos( cID1 ))
ControlGetText, aPath, TMyPanel3, A
RegExMatch(aPath aText, "(.*)\>(.*\\)?([^\\]+)(\.[a-zA-Z]+) \>?", aFile)
fileName:=aFile3
fileExt :=aFile4
;partPath:=aFile1 "\" aFile2
;fullPath:=aFile1 "\" aFile2 aFile3 aFile4
;; if there is a number at the end (1) we ignore it,
;; if there is a number before that.
;; unless, the flag /braces is used, then we match
;; all files that are similiar in name ie. "Gallery1_003 (1).jpg"
;; then the match is Gallery1_\d{3}_\(\d\)\.jpg
;; if there is a number at the end (01) and it has more digits than
;; the numbers before it, then we use that number as the sequence.
;; e.g. Gallery1_Set1_(10).jpg
;; match: Gallery1_Set1_\(\d{2}\)\.jpg
;; if /anynum flag is used, then the match would change to:
;; match: Gallery1_Set1_\(\d+\)\.jpg
RegExMatch(fileName, "(.*)(([\(\{\[])(\d+)([\)\}\]]))$", sTmp)
;MsgBox, sTmp1: %sTmp1%`nsTmp3: %sTmp3%`nsTmp4: %sTmp4%`nsTmp5: %sTmp5%
if( sTmp2 )
{
RegExMatch(sTmp1, "(.*\D)?(\d+)(\D+)?$", split)
if( locateBrace || (s4:=strlen(sTmp4)) > (s2:=strlen(split2)) )
{
filter:=RegExReplace(sTmp1, "([\^\$\.\+\{\(\[\]\)\}])", "\$1")
filter.="\" sTmp3 (matchAnyNum ? "\d+\" : "\d{" s4 "}\") sTmp5 "\" fileExt
filter:="^" filter "$"
}
else
{
split1:=RegExReplace(split1, "([\^\$\.\+\{\(\[\]\)\}])", "\$1")
split2:=(matchAnyNum ? "\d+" : "\d{" s2 "}")
split3:=RegExReplace(split3, "([\^\$\.\+\{\(\[\]\)\}])", "\$1")
filter:="^" split1 split2 split3 "(\" sTmp3 "\d+\" sTmp5 ")?\" fileExt "$"
}
}
else
{
RegExMatch(fileName, "(.*\D)?(\d+)(\D+)?$", split)
split1:=RegExReplace(split1, "([\^\$\.\+\{\(\[\]\)\}])", "\$1")
split2:=(matchAnyNum ? "\d+" : "\d{" strlen(split2) "}")
split3:=RegExReplace(split3, "([\^\$\.\+\{\(\[\]\)\}])", "\$1")
filter:="^" split1 split2 split3 "\" fileExt "$"
}
TC_iniWrite( filter,"searches", "TC_SelectSequence_SearchFor" )
TC_iniWrite( "", "searches", "TC_SelectSequence_SearchIn" )
TC_iniWrite( "", "searches", "TC_SelectSequence_SearchText" )
TC_iniWrite( "0|000002001020|||||||||0000| ", "searches", "TC_SelectSequence_SearchFlags" )
PostMessage, 0x433, 521,,, A ; cm_SpreadSelection | Select group
WinWaitActive, ahk_class TCOMBOINPUT
ControlSetText, Edit1, >TC_SelectSequence, A
if( !editFindStr )
ExitNow("{Enter}")
Send, {Tab}{Tab}{Enter} ;Send, !{d}
WinWaitActive, ahk_class TFindFile
aWinDefine:=WinExist("A")
while( (aWin:=WinActive("A")) == aWinDefine )
{
Sleep, 250
}
WinGetClass, aClass, ahk_id %aWin%
if( aClass=="TCOMBOINPUT" )
ExitNow("{Esc}")
TC_SelectSequenceAutoSave()
return
}
;;
;; Included AHK Library File:
;; TC.ahk
;;
TC_CheckINIRedirect( iniSection )
{
EnvGet, wincmd, COMMANDER_INI
iniRead, iniRedirect, %wincmd%, %iniSection%, RedirectSection, %wincmd%
SplitPath, iniRedirect, iniFile, iniPath
if( !iniPath )
SplitPath, wincmd, tmpFile, iniPath
return iniPath "\" iniFile
}
TC_iniRead( iniSection, iniKey )
{
iniFile := TC_CheckINIRedirect( iniSection )
IniRead, keyValue, %iniFile%, %iniSection%, %iniKey%, %A_Space%
return keyValue
}
TC_iniWrite( value, iniSection, iniKey )
{
iniFile := TC_CheckINIRedirect( iniSection )
IniWrite, %value%, %iniFile%, %iniSection%, %iniKey%
return
}
;;
;; Included AHK Library File:
;; LB.ahk
;;
ControlGetID( byRef cID, cName, wID="" )
{
if( wID=="" )
wID:=WinExist("A")
ControlGet, cID, HWND,, %cName%, ahk_id %wID%
return cID
}
Swap( byRef v1, byRef v2, dx="" )
{
v3:=v1,v1:=v2,v2:=v3
return (dx=="" ? TRUE : v%dx%)
}
QueryActivePanelID( byRef cID2, byRef cID1="", absolute=FALSE, force=FALSE )
{
if(!winID:=WinActive("ahk_class TTOTAL_CMD"))
return !(ErrorLevel:=2)
dx:=( ControlGetID(cID3, "TMyListBox3", winID) ? 2 : 1)
cID1:=ControlGetID(cID1, "TMyListBox" dx, winID)
cID2:=ControlGetID(cID2, "TMyListBox" (++dx), winID)
Loop, 2
{
ControlGetFocus, aCF, ahk_id %winID%
cID3:=ControlGetID(cID3, aCF, winID)
if( (!ErrorLevel:=!(cID3==cID2 || (cID3==cID1 && (absolute || Swap(cID1,cID2))) ) ) || !force)
break
Send, {ESC}
Sleep, 0
}
return (ErrorLevel ? 0 : cID3)
}
LB_FindCursorPos( byRef cID )
{
LB_GETCURSEL = 0x188
NULL = 0x0
SendMessage, LB_GETCURSEL, NULL, NULL,, ahk_id %cID%
return ( ErrorLevel <> "FAIL" ? ErrorLevel + 1 : 0 )
}
LB_QueryText( cID, cPos )
{
LB_GETTEXT = 0x189
VarSetCapacity(text,1024)
SendMessage, LB_GETTEXT, % cPos - 1, &text,, ahk_id %cID%
return text
}