AutoHotkey: From FileSync open another TC instance with selected files: Difference between revisions
Jump to navigation
Jump to search
(fix: added double quotes for paths containing spaces) |
(added: use the same helper instance of TC for every call) |
||
Line 5: | Line 5: | ||
*/ ; --> <code><pre> | */ ; --> <code><pre> | ||
; //////////////////////////////////////////////////////////////////////////// | ; //////////////////////////////////////////////////////////////////////////// | ||
; // TC_Sync_OpenFolderInSecondTC.ahk V0. | ; // TC_Sync_OpenFolderInSecondTC.ahk V0.12 (W) StatusQuo 2008 | ||
; // http://ghisler.ch/board/viewtopic.php?t=19713 | ; // http://ghisler.ch/board/viewtopic.php?t=19713 | ||
; // | ; // | ||
Line 17: | Line 17: | ||
#IfWinActive, ahk_class TCmpForm | #IfWinActive, ahk_class TCmpForm | ||
^#t:: ; Ctrl+Win+T | ^#t:: ; hotkey = Ctrl+Win+T | ||
; please adjust path here; %COMMANDER_PATH% is not available outside of TC | ; please adjust path here; %COMMANDER_PATH% is not available outside of TC | ||
sTCExe := "C:\totalcmd\TOTALCMD.EXE" | sTCExe := "C:\totalcmd\TOTALCMD.EXE" | ||
; static pidTC2 | |||
Send, {F3} | Send, {F3} | ||
sLDirName := GetActiveTCListerPath() | sLDirName := GetActiveTCListerPath() | ||
Send, +{F3} | Send, +{F3} | ||
sRDirName := GetActiveTCListerPath() | sRDirName := GetActiveTCListerPath() | ||
IfWinNotExist, ahk_pid %pidTC2% | |||
pidTC2 := "" | |||
if not (pidTC2 = "") | |||
{ | |||
WinActivate, ahk_pid %pidTC2% | |||
sTCExe = %sTCExe% /O | |||
} | |||
sRunStr := sTCExe | sRunStr := sTCExe | ||
if (sLDirName != "") | if (sLDirName != "") | ||
Line 31: | Line 41: | ||
if (sRunStr = sTCExe) | if (sRunStr = sTCExe) | ||
Return | Return | ||
Run, %sRunStr% | if (pidTC2 = "") | ||
Run, %sRunStr%,,, pidTC2 | |||
else | |||
Run, %sRunStr% | |||
Return | Return | ||
#IfWinActive | #IfWinActive |
Revision as of 03:42, 23 July 2008
; ////////////////////////////////////////////////////////////////////////////
; // TC_Sync_OpenFolderInSecondTC.ahk V0.12 (W) StatusQuo 2008
; // http://ghisler.ch/board/viewtopic.php?t=19713
; //
; // open another TC instance
; // with the folders of the currently selected file in cm_FileSync
; // via hotkey: Ctrl+Win+T
; ////////////////////////////////////////////////////////////////////////////
#SingleInstance, Force
Return
#IfWinActive, ahk_class TCmpForm
^#t:: ; hotkey = Ctrl+Win+T
; please adjust path here; %COMMANDER_PATH% is not available outside of TC
sTCExe := "C:\totalcmd\TOTALCMD.EXE"
; static pidTC2
Send, {F3}
sLDirName := GetActiveTCListerPath()
Send, +{F3}
sRDirName := GetActiveTCListerPath()
IfWinNotExist, ahk_pid %pidTC2%
pidTC2 := ""
if not (pidTC2 = "")
{
WinActivate, ahk_pid %pidTC2%
sTCExe = %sTCExe% /O
}
sRunStr := sTCExe
if (sLDirName != "")
sRunStr = %sRunStr% /L="%sLDirName%"
if (sRDirName != "")
sRunStr = %sRunStr% /R="%sRDirName%"
if (sRunStr = sTCExe)
Return
if (pidTC2 = "")
Run, %sRunStr%,,, pidTC2
else
Run, %sRunStr%
Return
#IfWinActive
GetActiveTCListerPath()
{
WinWaitNotActive, ahk_class TCmpForm,, 2 ; wait for starting lister, timeout 2 seconds
IfWinActive, ahk_class TCmpForm ; Lister hasn't started - no file on this panel side?
Return
WinGetActiveTitle, sWinTitle
WinClose, %sWinTitle%
iNamePos := (InStr(sWinTitle, "[", false, 0) + 1)
; folder only
; Return, % SubStr(sWinTitle, iNamePos, (InStr(sWinTitle, "\", false, 0) + 1) - iNamePos)
; folder + file name
Return, % SubStr(sWinTitle, iNamePos, StrLen(sWinTitle) - iNamePos)
}
;
Back to AutoHotkey