synchronize dirs: go to the current dir in the (2-nd??) TC?

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
leopoldus
Senior Member
Senior Member
Posts: 221
Joined: 2004-11-21, 09:47 UTC

synchronize dirs: go to the current dir in the (2-nd??) TC?

Post by *leopoldus »

Hello to all!

Is there any trick or plugin to do the following: when after dirs synchronizing the files list is displayed to open the folder/file being under cursor in th TC regular panel (this virtually means the command "Go to...")?

If it is not possible to open the file in the same TC session, is there any option to open the dir in the 2nd session of TC? Or at least to copy the folder/file full name to clipboard?

Thanks in advance.
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

A solution using AHK is now in TCWiki.

To grab the selected path/file names it currently abuses TC's Lister.
Maybe someone knows a more direct way?
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
leopoldus
Senior Member
Senior Member
Posts: 221
Joined: 2004-11-21, 09:47 UTC

Post by *leopoldus »

2StatusQuo

Thank you for the hint with AHK, I'll try to install it. However it's a bit confusing, that there is no any way to solve such essential task by TC internal resources :shock:
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Maybe someone knows a more direct way?
Just read from listbox by sending LB_GETCARETINDEX and LB_GETTEXT. The problem is to parse it afterwards to extract the filenames, I guess... ;)

Code: Select all

F4::
LB_GETCARETINDEX := 0x019F
LB_GETTEXT := 0x0189
ControlGetFocus, Panel_id, A
SendMessage, %LB_GETCARETINDEX%, 0, 0, %Panel_id%, A
LB_CursorPosition := ErrorLevel
VarSetCapacity(LB_String, 1024, 0)
SendMessage, %LB_GETTEXT%, %LB_CursorPosition%, &LB_String, %Panel_id%, A
MsgBox % LB_String
Return
Icfu
This account is for sale
User avatar
leopoldus
Senior Member
Senior Member
Posts: 221
Joined: 2004-11-21, 09:47 UTC

Post by *leopoldus »

Thanks again.

I think, that indeed most of TC users hardly use this synchronize tool just for automatically synchronizing, but rather for comparing directories in order to find some different files etc.
So the most logical and convenient way to continue work after synchronizing is done would be IMHO to press Enter to go to the focused file/folder, as it is with FindFiles result window. Another option should be to send results to regular panels (left, right or both) - again as in FindFiles. Aren't I right?
User avatar
leopoldus
Senior Member
Senior Member
Posts: 221
Joined: 2004-11-21, 09:47 UTC

Post by *leopoldus »

2StatusQuo
A solution using AHK is now in TCWiki.
To grab the selected path/file names it currently abuses TC's Lister.
Seems that this script does not properly work in the event when the path includes spaces (the most of lognnames does include!) :( :( May be need adding quotes in some line, but I have no idea in which place exactly.

Another downside is that the script starts a new copy on TC every time. Ideal option would be to send focused dir from 1st TC session always to the same 2nd TC session, changing there the current dir properly.

Furthermore the script opens only left or Right dir focused in the synchronizing window, but not the both simultaneously.

Could anybody advise me how to modify this script to solve these tasks (if possible).
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2icfu
Just read from listbox by sending LB_GETCARETINDEX and LB_GETTEXT. The problem is to parse it afterwards to extract the filenames, I guess... Wink
Sounds nice, thanks.
I'll try this, and maybe this way I can make the script work on lines with single files, too...
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2leopoldus
Seems that this script does not properly work in the event when the path includes spaces
Another downside is that the script starts a new copy on TC every time.
Both issues are now solved, thanks for reporting:
- missing double quotes were added
- now the script opens just one additional instance of TC, which it re-uses on the next call

The current version is available through the same link in TCWiki.
Furthermore the script opens only left or Right dir focused in the synchronizing window, but not the both simultaneously.
In fact it does open both simultaneously - but only if the cursor is placed on a line that's containing a file on both sides.

This limitation is, because it retrieves the file/path information from the files under the cursor - where there's no file, there's nothing to retrieve.
I'll check, if this can be improved using icfu's suggestion of how to retrieve the information from the window.

Workaround for now (since it now always uses the same TC instance as target):
you can press the hotkey twice - once on a file on the left, once on a file on the right (if existing)...
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
leopoldus
Senior Member
Senior Member
Posts: 221
Joined: 2004-11-21, 09:47 UTC

Post by *leopoldus »

2StatusQuo
By now it works perfectly! A bit of magic: in order to check it I opened 4 sessions of TC - and your script somehow knows, which sessions it that it has to work with! :) Many thanks!

But I think you should not completely remove the previous version of the script as well, but rather repair it regarding long names handling. May be somebody (not me!) just prefers to open a new TC session for every dirs pair, as it was with your older script.

Regarding further improvement you could give a look at this software for handling windows captions I've found in inet, may be it gives you some idea.
http://www.softpedia.com/get/Office-tools/Clipboard/CopyText.shtml
http://www10.pair.com/vsap/CopyText_versions.txt

P.S.
IMHO the situation might be much simpler if TC's SynchDirs window would have the option to handle items by Windows' shell context menu - just the way as Find Files results window and the most of TC's modules allows. Did somebody ever discuss this subject with Mr. Ghisler?
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

Update (same link in TCWiki):
- Now it also works with single files - if there is no file on one side, it just CDs to the directory without selecting a filename.
- Also you can configure some things by setting variables:

Code: Select all

	boAlwaysOpenNewTask := 0	; set to 1 to not re-use TC target window (always open a new one)
	boCdToFolderOnly    := 0	; set to 1 to just cd to dirs (does not use Lister to select file)
	iListerTimeOutSecs  := 1	; if using Lister: timeout after n seconds of not appearing Lister
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2icfu
Just read from listbox by sending LB_GETCARETINDEX and LB_GETTEXT.
Thanks a lot again, that was really a great help.
Indeed parsing the string containing the listbox line seems to be a "problem" -
no clear delimiters (just space), no fixed strings or positions. :?
Maybe I'll play some more with these lines later to see if i can get stable information out of them...

By now I use your method to get the dir containing the files, so the Lister workaround is only needed, if the files shall be selected in the target TC.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

2leopoldus
By now it works perfectly! A bit of magic: in order to check it I opened 4 sessions of TC - and your script somehow knows, which sessions it that it has to work with! :) Many thanks!
Well, that magic is quite easy to do, it just remembers the ID of the TC process it just started itself initially... :)
But I think you should not completely remove the previous version of the script
No problem, the old versions are available through the history link in the Wiki.
I added the double quotes separately before adding other functionality.
software for handling windows captions I've found in inet
I'll take a look at it, thanks.
IMHO the situation might be much simpler if TC's SynchDirs window would have the option to handle items by Windows' shell context menu - just the way as Find Files results window and the most of TC's modules allows. Did somebody ever discuss this subject with Mr. Ghisler?
Yes: http://ghisler.ch/board/viewtopic.php?t=12295
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Have removed the ", A" from the code, not needed due to #IfWinActive and might be problematic if compare window loses focus.
Thanks a lot again, that was really a great help.
You're welcome, it was a good investment! ;)

Icfu
This account is for sale
User avatar
leopoldus
Senior Member
Senior Member
Posts: 221
Joined: 2004-11-21, 09:47 UTC

Post by *leopoldus »

2StatusQuo

Thanks again!
But could you explain a bit more at the script's page for not-so-advanced users (including me) the practical meaning of two options:

Code: Select all

boCdToFolderOnly    := 0   ; set to 1 to just cd to dirs (does not use Lister to select file) 
iListerTimeOutSecs  := 1   ; if using Lister: timeout after n seconds of not appearing Lister
The technical side is clear, but what for a user could use these options?

BTW, TC synchronizing dirs function handles archives as well, but the script does not support it. It is not a criticism, but only a remark.
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Post by *StatusQuo »

leopoldus wrote:the practical meaning of two options:
Well, using Lister to get the selected file names is far away from perfect and may fail in certain situations.

iListerTimeOutSecs: Just in case, if Lister fails or takes longer to start, the script gives up waiting after this time and assumes there is no file
(in this case it uses only the directory without setting the cursor to the selected file).
Increasing this value avoids giving up too early, but takes longer if there really is no file on one side.

boCdToFolderOnly: If set to "1" this makes the script work completely without using Lister.
That makes it both faster and more reliable - but the price is, as the variable name implies,
that it just goes into the directories containing the selected files, without placing the cursor on the selected files.

So, if entering the target directories is enough, a user would probably prefer boCdToFolderOnly := 1 here.
I changed the standard to this safe mode now, so users don't have to worry about these settings, unless willing to try the advanced behavior. So now it's:

Code: Select all

	boCdToFolderOnly    := 1	; set to 0 to have cursor placed on selected files; uses Lister, experimental
	iListerTimeOutSecs  := 1	; if using Lister: timeout after n seconds of not appearing Lister
BTW, TC synchronizing dirs function handles archives as well, but the script does not support it. It is not a criticism, but only a remark.
Right. Using the safe mode (boCdToFolderOnly := 1, now standard) the target TC at least goes to the archive's location.

Navigating into the archive looks more complex, as
  • Lister uses a copy of the file in the TEMP folder here, and
  • TC doesn't seem to support commands like cd C:\archive.ext\compressed\file.ext, not even in the command line of an open TC.
So the script would have to detect that the path is inside an archive (not indicated by TC's cm_FileSync, so it would be hardly reliable),
and then navigate step by step to the target, one sub-dir after another...
I have no idea yet how to do this reliably, sorry.
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
Post Reply