Autoit Script: Save Path History /PermanentlyDirHotlist

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
-Lawz-
Junior Member
Junior Member
Posts: 3
Joined: 2003-12-16, 19:53 UTC
Location: Uk

Autoit Script: Save Path History /PermanentlyDirHotlist

Post by *-Lawz- »

Hi

Long time lurker here.

Thought I would contribute something, that i created to save paths visited for recall anytime TC is restarted, unlike dirhotlist which clears on every new session.

Its a work around till v7 TC arrives.

I hope someone finds this useful.

Regards

Lawz / aka HardCopy

Code: Select all

;; 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 file & Point your TotalCommander shortcut to point to it. 
;; 3. Access Function by PRESSING <ALT>+<ARROWDOWN> as per TotalCommander default History function.
;; 4. This Function Terminates automatically when Total Commander Closed.
;; 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 _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
Post Reply