Sign in to follow this  
Followers 0
HardCopy

TotalCommander Utility Save Permenant DirHotList

1 post in this topic

As users of TotalCommander will be aware - DirectoryHotlist in the current version is lost every time you restart the program.

This script will save every Path visited into files for the left & right panes which can than be accessed by the HotKey ALT + DOWNARROW. Click the desired path in the left or right box and that path will appear in the pane.

TotalCommander must be loaded before this script can be loaded or it will terminate.

Recommend Use batch file to load TC then this file.

It has worked ok for me to date, untested on other systems. v7.0 of TotalCommander will have its own

implementation of this feature. So its just a shortterm workaround.

Your comments bug reports welcomed.

HardCopy

;; Total Commander Utility - History Dir Path Saver (Scripted Work around till TC v7.0 arrives)
;; Saves every Directory visited into a history file, which will be available everytime this utility runs.
;; Current Version 6.54a Total Commander only keeps the data for the current session - lost when restarted.
;; Code Provided as is.
;; by Lawz2006 aka(HardCopy) - Code provided as is - may contain Bugs! FeedBack Welcome
;; 
;; Greetings & Thanks to C. Ghisler for Total Commander a Must Have Application.
    
    
;;INSTRUCTIONS For USE
;; ====================
;; Requires Latest BETA of Autoit Available from: 
;; http://www.autoitscript.com/autoit3/files/beta/autoit

;; 1. Compile & copy the newly created .EXE file into your Total Commander Directory (It Saves the history textfiles LeftPanehist.txt & RghtPaneHist.txt Files here too.)
;; 2. Assign A New Button on Button Bar & Press to Execute LawzTCHist.exe
;;  (Or preferably create a batch file to launch TotalCommander then this script/exe & Point your TotalCommander shortcut to point to the batch file. 
;; 3. Access Function by PRESSING <ALT>+<ARROWDOWN> as per TotalCommander default History function.
;; 4. This Function Terminates automatically if no Total Commander Session present .
;; Limitations : currently no user control for purging list - use a text editor if history gets to large.



#include <GUIConstants.au3>
#include <GUIList.au3>
#include <File.au3>
#Include <GuiListView.au3>

Opt("GUICoordMode",1)
Opt("WinTitleMatchMode",4)
Opt("WinTextMatchMode",2)


#NoTrayIcon

HotKeySet("!{DOWN}","GoGui")

Global $History[2] ,$g1 ,$g2
Global $LastDir_L = "", $LastDir_R = "", $CurrDir_L = "", $CurrDir_R = ""

Global $Title = "classname=TTOTAL_CMD"
Global $L_Hwnd = ControlGetHandle($Title,"","TMyPanel5")
Global $R_Hwnd = ControlGetHandle($Title,"","TMyPanel9")
Global $Pane1 = ControlGetHandle($Title, '','TMyListBox1')
Global $Pane2 = ControlGetHandle($Title, '','TMyListBox2')



While WinExists($Title)
    $CurrDir_L = StringReplace(ControlGetText($Title,"",$L_Hwnd),"*.*","")
    $CurrDir_R = StringReplace(ControlGetText($Title,"",$R_Hwnd),"*.*","")

    If $CurrDir_L <> $LastDir_L Then
        $LastDir_L = $CurrDir_L
        _SaveLeft($CurrDir_L)
    EndIf
    
    If $CurrDir_R <> $LastDir_R Then
    $LastDir_R = $CurrDir_R
    _SaveRight($CurrDir_R)
    EndIf
    Sleep(5)
WEnd

HotKeySet("!{DOWN}")
Exit 0



Func _SaveLeft($aTemp)
    Local $aHist, $aText
    $LFilename = @ScriptDir & "\LeftPaneHist.txt"
    $LFileHnd  = FileOpen($LFilename,0)

        $aText = FileRead($LFileHnd)
        FileClose($LFileHnd)
        $Res = StringInStr($aText,$aTemp & @CR)

    If $Res > 0 Then
    ;;do nothing
    Else
        $LFileHnd  = FileOpen($LFilename,1)
        FileWriteLine($LFileHnd,$aTemp)
        FileClose($LFileHnd)
    EndIf
EndFunc


Func _SaveRight($aTemp)
    Local $aHist, $aText
    $RFilename = @ScriptDir & "\RghtPaneHist.txt"
    $RFileHnd  = FileOpen($RFilename,0)

    $aText = FileRead($RFileHnd)
    FileClose($RFileHnd)

    $Res = StringInStr($aText,$aTemp & @CR)

    If $Res > 0 Then
    ;;do nothing
    Else
        $RFileHnd  = FileOpen($RFilename,1)
        FileWriteLine($RFileHnd,$aTemp)
        FileClose($RFileHnd)
    EndIf
EndFunc





Func GoGui()
WinActivate($Title)
Dim $aRecords
HotKeySet("!{DOWN}")

$Winpos = WinGetPos($Title,"")

$Loc1 = ControlGetPos("","",$Pane1)
$Loc2 = ControlGetPos("","",$Pane2)



$g1 = GUICreate("Right",350,200,$Winpos[0]+$Loc1[0],$Winpos[1]+$Loc1[1]+80,-1,$WS_EX_TOOLWINDOW ,$Pane1)
$b1 = GUICtrlCreateListView("         ",0,0,350,200,BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOCOLUMNHEADER,$LVS_SORTASCENDING),$LVS_EX_FULLROWSELECT )
If  _FileReadToArray(@ScriptDir & "\RghtPaneHist.txt",$aRecords) Then
    For $x = 1 to $aRecords[0]-1
        GUICtrlCreateListViewItem($aRecords[$x],$b1)        
    Next
    Else
        GUICtrlCreateListViewItem(" ",$b1)
EndIf
    _GUICtrlListViewSetColumnWidth($b1,0,450)
GUISetState()



$g2 = GUICreate("Left",350,200,$Winpos[0]+$Loc2[0],$Winpos[1]+$Loc2[1]+80,-1,$WS_EX_TOOLWINDOW,$Pane2)
$b2 = GUICtrlCreateListView("         ",0,0,350,200,BitOR($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOCOLUMNHEADER,$LVS_SORTASCENDING),$LVS_EX_FULLROWSELECT )
If  _FileReadToArray(@ScriptDir & "\LeftPaneHist.txt",$aRecords) Then
    For $x = 1 to $aRecords[0]-1
        GUICtrlCreateListViewItem($aRecords[$x],$b2)        
    Next
    Else
        GUICtrlCreateListViewItem(" ",$b2)
EndIf
    _GUICtrlListViewSetColumnWidth($b2,0,450)
    
GUISetState()




While WinExists($Title)
        $Dir = GUICtrlRead(GUICtrlRead($b1))
        If $Dir > "" Then
            _PasteIt("TMyListBox1",$Dir)
            ExitLoop
        EndIf

        $Dir = GUICtrlRead(GUICtrlRead($b2))
        If $Dir > "" Then
            _PasteIt("TMyListBox2",$Dir)
            ExitLoop
        EndIf

    Sleep(50)
WEnd



    GUIDelete($g1)
    GUIDelete($g2)

    HotKeySet("!{DOWN}","GoGui")
EndFunc



;Func _ReadFile($uFilename)
;   Local $aHist
;   $LFilename = @ScriptDir & $uFilename
;   $LFileHnd  = FileOpen($LFilename,0)
;   $aText = FileRead($LFileHnd)
;   FileClose($LFileHnd)
;   Return $aText
;EndFunc



Func _PasteIt($TmpPanel,$aDir) 
    GUIDelete($g1)
    GUIDelete($g2)
    WinActivate($Title)
    ClipPut("cd " & $aDir)
    Sleep(100)
    ControlFocus($Title,"",$TmpPanel)
    ControlSend($Title,"","Edit1", "{CTRLDOWN}V")
    ControlSend($Title,"","Edit1", "{CTRLUP}{ENTER}")
EndFunc



Func Quit()
    Exit
EndFunc

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0