Difference between revisions of "AutoHotkey: From FileSync open another TC instance with selected files"

From TotalcmdWiki
Jump to: navigation, search
(script added)
 
m (Added category AutoHotkey scripts)
Line 50: Line 50:
  
 
;</pre></code>Back to [[AutoHotkey]]
 
;</pre></code>Back to [[AutoHotkey]]
 +
 +
[[Category:AutoHotkey scripts|From FileSync open another TC instance with selected files]]

Revision as of 10:55, 19 July 2008

		; ////////////////////////////////////////////////////////////////////////////
		; // TC_Sync_OpenFolderInSecondTC.ahk  (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::	; Ctrl+Win+T
		; please adjust path here; %COMMANDER_PATH% is not available outside of TC
	sTCExe := "C:\totalcmd\TOTALCMD.EXE"
	Send, {F3}
	sLDirName := GetActiveListerPath()
	Send, +{F3}
	sRDirName := GetActiveListerPath()
	sRunStr := sTCExe
	if (sLDirName != "")
		sRunStr = %sRunStr% /L=%sLDirName%
	if (sRDirName != "")
		sRunStr = %sRunStr% /R=%sRDirName%
	if (sRunStr = sTCExe)
		Return
	Run, %sRunStr%
	Return
#IfWinActive

GetActiveListerPath()
{
	WinWaitNotActive, ahk_class TCmpForm,, 1	; wait for starting lister, timeout 1 second
	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