Locate and TC

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Locate and TC

Post by *majkinetor ! »

This is faster and better script to use Locate with TC. It will show you the file selected in Locate in TC:

CTRL F to on file to use it. CTRL m to show original Locate interface again.

Code: Select all

SetKeyDelay, -1 
SetBatchLines -1 

#IfWinActive, Locate ahk_class #32770 

^m::
	SetLocateWindow("show")
return

^f:: 
	hwnd := WinExist("Locate:")
	QV_TCGetControls() 
	SetLocateWindow()
	QV_rect := QV_GetViewDestination()
	QV_AdjustViewerPosition( QV_rect )

   sFileName := "" 
   sPath := "" 
   ControlGet, sActiveRow, List, Selected, SysListView321 
   StringSplit, aRowElements, sActiveRow, %A_Tab% 
   sFileName := aRowElements1 
   sPath := aRowElements2 

   If (sFileName) 
   { 
     SetTCPath( sPath ) 
     WinWaitActive, ahk_class TTOTAL_CMD 

     Loop 
     { 
        ControlGetText, ActivePath, TMyPanel2 
        StringTrimRight, ActivePath, ActivePath, 1 
        If (ActivePath = sPath) 
        Break 
     } 

     PostMessage, 1075, 2915 
     WinWaitActive, ahk_class TQUICKSEARCH 
     ControlSetText, TTabEdit1, %sFileName% 
     ControlSend, TTabEdit1, {Down}{Esc} 
   } 
return 

;------------------------------------------------------------------------

SetLocateWindow(state="")
{
	global hwnd

	if state=
		state = Hide

	if state = show
		ControlMove, SysListView321, 0, 250,,, ahk_id %hwnd%

	DllCall("SetMenu", "uint", hwnd, "uint", 0) 
	Control, %state%,, #327703		, ahk_id %hwnd%
	Control, %state%,, Presets		, ahk_id %hwnd%
	Control, %state%,, Tab			, ahk_id %hwnd%
	Control, %state%,, Ne&w Search	, ahk_id %hwnd%
	Control, %state%,, Sto&p		, ahk_id %hwnd%
	Control, %state%,, F&ind Now	, ahk_id %hwnd%

	if state = hide
		 ControlMove, SysListView321, 0, 30,,, ahk_id %hwnd%


	WinGetPos, x, y, w, h, ahk_id %hwnd%
	WinMove, ahk_id %hwnd%, , x, y, w+1, h+1
	WinSet, AlwaysOnTop, On, ahk_id %hwnd%
}

;------------------------------------------------------------------------

QV_TCGetControls() 
{ 
	global QV_TCActivePanel, QV_TCCurentDir, QV_TCHeader, QV_host

	ControlGetText pLeft,    TMyPanel5, ahk_class TTOTAL_CMD
	ControlGetText pCurrent, TMyPanel2, ahk_class TTOTAL_CMD

	StringReplace pCurrent, pCurrent, > 
			

	StringGetPos idx, pLeft, \, R 
	StringMid  pLeft, pLeft, 1, idx 

	if StrLen(pLeft) = 2 
      pLeft = %pLeft%\ 

	if (pLeft = pCurrent) 
      QV_TCActivePanel := "TMyListBox1" 
	else 
      QV_TCActivePanel := "TMyListBox2" 


	QV_TCCurentDir	:= "TMyPanel5"
	QV_TCHeader		:= "THeaderClick1"
	if QV_TCActivePanel = TMyListBox1
	{
		QV_TCCurentDir	:= "TMyPanel9"
		QV_TCHeader		:= "THeaderClick2"
	}
} 

;--------------------------------------------------------------------------- 

QV_GetViewDestination()
{
	global QV_mode, QV_Options_Width, QV_TCActivePanel, QV_TCCurentDir, QV_TCHeader, QV_host

	rect =

	ControlGetPos,  ,   ,   , hh, %QV_TCHeader%,		ahk_class TTOTAL_CMD
	ControlGetPos cx, cy, cw, ch, %QV_TCCurentDir%,		ahk_class TTOTAL_CMD
	ControlGetPos,  ,   , pw, ph, %QV_TCActivePanel%,	ahk_class TTOTAL_CMD
	WinGetPos x, y, , , ahk_class TTOTAL_CMD 
		 
	vX := x + cx 
	vY := y + cy 
	vW := pw
	vH := ph + ch + hh 
	rect = %vX%,%vY%,%vW%,%vH% 

	return rect
}

;--------------------------------------------------------------------------- 

QV_AdjustViewerPosition( rect )
{
	global hwnd

	loop, parse, rect, `,
	{
		p_%A_Index% := A_LoopField 
	}


	WinMove, ahk_id %hwnd%, ,%p_1%,%p_2%,%p_3%,%p_4%
}

;------------------------------------------------------ 

SetTCPath(path) 
{ 
   if !WinExist("ahk_class TTOTAL_CMD") 
   { 
      Run, %COMMANDER_PATH%\TOTALCMD.EXE 
      WinWait ahk_class TTOTAL_CMD 
   } 

   WinActivate ahk_class TTOTAL_CMD 

   path := path "`r" 
   VarSetCapacity( CopyDataStruct, 12 ) 
   InsertInteger( Asc( "C" ) + 256 * Asc( "D" ), CopyDataStruct ) 
   InsertInteger( StrLen( path ) + 5, CopyDataStruct, 4 ) 
   InsertInteger( &path, CopyDataStruct, 8 ) 
   InsertInteger( Asc( "S" ), path, StrLen( path ) + 1, 1) 
   InsertInteger( Asc( "T" ), path, StrLen( path ) + 2, 1) 
   SendMessage, 0x4A, , &CopyDataStruct, , ahk_class TTOTAL_CMD 

} 

;------------------------------------------------------ 

SendTCCommand(cmd, wait=1) 
{ 
   if (wait) 
      SendMessage 1075, cmd, 0, , ahk_class TTOTAL_CMD 
   else 
      PostMessage 1075, cmd, 0, , ahk_class TTOTAL_CMD 
} 

;------------------------------------------------------ 

InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) 
{ 
  mask := 0xFF 
  Loop %pSize% 
  { 
    DllCall("RtlFillMemory", UInt, &pDest + pOffset + A_Index - 1, UInt, 1, UChar, (pInteger & mask) >> 8 * (A_Index - 1)) 
    mask := mask << 8 
  } 
}
Habemus majkam!
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2majkinetor !
Sorry I ask this. What is "Locate"?
User avatar
StickyNomad
Power Member
Power Member
Posts: 1933
Joined: 2004-01-10, 00:15 UTC
Location: Germany

Post by *StickyNomad »

2Alextp
It is a mighty and fast desktop search.

See here.
User avatar
gbo
Senior Member
Senior Member
Posts: 329
Joined: 2005-03-31, 19:58 UTC
Location: Lausanne (Switzerland)

Re: Locate and TC

Post by *gbo »

majkinetor ! wrote:This is faster and better script to use Locate with TC.
Not bad! I adopt it.

Thanks
Gil
Licence #17346

90% of coding is debugging. The other 10% is writing bugs.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Its not finished very... just an idea.. should be worked out much... you have good foundation though.

2 ALex
Interesting thing. I was able to add locatte window directly to the TC as a child. I tried that also with Viewer latter and it worked OK. So, Viewer was part of TC and moving the TC was moving the viewer. The strange thing is that WM_COPYDATA mechanism didn't work from that point. I tried to return viewer in non-child state, send the message and child it again, and it works but it doesn't look good.

Locate is instantious searcher. It records db of files at night so you don't wait for searches. Pending on changes list is transparent update on the fly so updating the db will hopefuly soon be forgoten. Much better then TC non-multi-thread search.
Habemus majkam!
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

Mh somehwere I saw a plug-in which somehow used Locate and displayed the results in TC. Unfortunately I guess it has been abandoned.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Didn't hear for that one...

It can be done thought.. locates db is open so you can search it yourself within FS plugin...
Habemus majkam!
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

I like the idea! :-)
I switched to Linux, bye and thanks for all the fish!
User avatar
Stitscher
Power Member
Power Member
Posts: 1058
Joined: 2004-02-17, 12:34 UTC
Location: Hamburg, Germany

Post by *Stitscher »

SanskritFritz wrote:I like the idea! :-)
So I do! :) 8)
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Kewl

Now we only need somebody to do it :8) :)
Habemus majkam!
User avatar
Stitscher
Power Member
Power Member
Posts: 1058
Joined: 2004-02-17, 12:34 UTC
Location: Hamburg, Germany

Post by *Stitscher »

I would do it if I had the knowledge. :P :?
But I could help during the beta test of that plugin :lol:

Stitscher
User avatar
Lefteous
Power Member
Power Member
Posts: 9536
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2majkinetor !
We are waiting for the first plug-in made with AHK ;-)
User avatar
van Dusen
Power Member
Power Member
Posts: 684
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

Post by *van Dusen »

10 month ago I've made my first experiments with AutoIt. Result of these trials was a script <Locate2DiskDir.au3>, which
* calls Locate32 and performs the search
* exports the results to a DiskDirExtended compatible archive
* opens the archive in a new folder tab in TC

See http://ghisler.ch/board/viewtopic.php?p=77478#77478

The script passably works, but I've never released a debugged and more stable version... but perhaps it is at least useful as a suggestion for further enhancements of majkinetor !'s AHK script.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Hej, Dusen, that is really open minded.
Nice solution :D.
We are waiting for the first plug-in made with AHK
LOL
Funny, I was just thinking today about similar thing - plugin that will wrap Lua scripting language so people can write tc plugins using Lua.

Lua is superb language as I was told by many, and the best of all, integration in your own code is via library that is 100K in size :) You can extend the language easily, you have function pointers, assotiative arrays, etc...

It would be really cool to just open Notepad and write your own TC plugin in a several hours...

Sounds like an extraordinary project. Results are similar to macro language already requested number of times. If you want to devote some time for this, let me know... too buisy to do it alone. ETA is 2 months with zero Lua knowledge and side job :P

BTW, it seems that people are more and more using Lua for integration with its apps. Even World of Warcraft uses it for its macro functinality. This fact means that Lua must be good as Blizard is legendary for having low number of bugs in their games and WoW environment is very CPU intensive. If macros do instantly work in WoW, witch is consuming 100% of CPU and 100% of GPU, then it will shine in TC. Even with icons in menus (lol goes to silvana and x duo and their security and performance trips...)
I would do it if I had the knowledge.
Nobody is born with the knowledge :D
If you wont to learn, I will help you ;)
After all, your avatar always cheers me up :P
Habemus majkam!
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Ah, I forgot this is already done in WCSScripter plugin but with VBScript (Lua of course, is much better language and more powerful)

Did anybody use this plugin and have positive feedback on it ?
Habemus majkam!
Post Reply