Universal Viewer QuickView script

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
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Universal Viewer QuickView script

Post by *Alextp »

Splitted from here.
Last edited by Alextp on 2007-12-26, 13:57 UTC, edited 3 times in total.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2majkinetor
Quote:
We don't need "F3-F2" mode,

We do. I might open the ATViewer with one file, and move cursor to the other files without the wish to display them. So we need to set the mode explicitely.
No, I don't understand. "Wish to move wihout to display" is not a Quick View mode.

And you suggest user to move to file, switch to Viewer, toggle mode, switch to TC, and move to another file. What for is it?
Quote:
Majkinetor, can you write such hook? So that I'll just receive messages from it.

Yes I can. It must be in a separate dll though, as designed by Windows architecture (you can't hook other apps then yourself from the exe, just from dll).

What do you say to first try to do this in AHK, since it will allow us to act more quickly to see how things function
Ok, let it be in AHK.
You need to implement following things for now:

1. Toggle menu
2. Toggle caption
3. Set size/position. X,Y,W,H (should take 1&2 into account)
4. Receive file
Ok.

I suggest to use EM_DISPLAYBAND message:
WParam: command, LParam: data (int or PChar or PRect).
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

Instead of messages for hiding menu/caption I suggest commandline parameter:

/view=NNN

where NNN is set of one or more letters:
M: hide menu bar and disable hotkeys
C: hide window caption and border
S: supress message boxes
A: set "Always on top" window style
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

And you suggest user to move to file, switch to Viewer, toggle mode, switch to TC, and move to another file. What for is it?
We must track CTRL Q then also. It will be done this way.
I suggest to use EM_DISPLAYBAND message:
WParam: command, LParam: data (int or PChar or PRect).
This approach will not do, since you can't send pointer to the string from different applications (AHK & ATViewer, or the same with dll). So this will probably be the WM_COPYDATA, or you can set some invisible control, I change the text of it and after that send you notification via custom message.
Instead of messages for hiding menu/caption I suggest commandline parameter:
Not quite. Command line parameters for this app is must. But we will not do it this way when communicating since this will be slow (Windows will start your application again on each call, you will have to supply mutex for single instance, redirect the call to your open app yourself, etc.. too much work, too poor results + flickering)
Win Messages are the only solution.

For instance, there is AHK script to connect TC with Locate. This one uses your suggestion to redirect locate selection to TC. When I changed original script to communicate with TC via messages, the swith was instant, and before that you could see noticable delay.

I will formalise everything and post here as soon as I can. Probably tomorrow on the job :)
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 »

We must track CTRL Q then also. It will be done this way.
I don't understand..
So this will probably be the WM_COPYDATA, or you can set some invisible control, I change the text of it and after that send you notification via custom message.
Ok.
Not quite. Command line parameters for this app is must. But we will not do it this way when communicating since this will be slow
No. I mean:

0. user runs addon.
you (addon) close all Viewer windows.

1. user presses Ctrl-Q.
you activate quick view:
- start new Viewer with mentioned parameters.
You then don't need to change them. Set them once at start.
- send message to Viewer

2. user moves cursor.
you send messages.

3. user presses Ctrl-Q again.
you deactivate quick view: close Viewer that was opened.

That's all, no sevaral starts of app.
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2majkinetor !
Please write test app, that can catch hook's messages.
First, implement 2 msgs: "Send filename" (using WM_COPYDATA, I don't like hidden control) and "Reposition window". Tell me when it's done.

I think these msgs are enough. And even first one is enough, because of SetWindowPos().
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

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

Post by *majkinetor ! »

Ok, Alex

I created the script and I post it here so you can see it works. You copy this in ahk file and execute it:

Code: Select all

#ifWinActive ahk_class TTOTAL_CMD

^q::
	bOpen := !bOpen
	if (bOpen)
		Tooltip % "OPEN QV: " .  GetName(2)
	else
		Tooltip % "CLOSE QV"
return

~Down::
~Up::
	if (bOpen)
		Tooltip % GetName(2)
return


GetName(method)
{
	;using clipboard
	if (method = 1)
	{
		SendTCCommand("cm_CopyFullNamesToClip")
		return clipboard
	}

	;using command line
	if (method = 2)
	{
		Send ^+{ENTER}
		ControlGetText name, Edit1
		Send {ESC}
		return name
	}

	msgbox what are you doing ?
}

#ifWinActive

^r::
	reload
return

;---------------------------------------------------------------------------
SendTCCommand( xsTCCommand, xbWait=1 )
{
	loop Read, %COMMANDER_PATH%\TOTALCMD.INC
	{
		StringSplit asCommands, A_LoopReadLine, =
		if (asCommands1 = xsTCCommand)
		{
			StringSplit asCommandsValues, asCommands2, `;
			Break
		}
	}

	if !(asCommandsValues1 > 0)
		return
	
	if (xbWait)
		SendMessage 1075, %asCommandsValues1%, 0, , ahk_class TTOTAL_CMD
	else
		PostMessage 1075, %asCommandsValues1%, 0, , ahk_class TTOTAL_CMD
}
When you press CTRL Q once, it will show you the tooltip with the currently selected name, when you press it again, it will show you that Quick View is closing.
When you move with the up/down arrow, tooltip will change file name.

I implemented 2 methods to obtain current selection.

One is using clipboard, second command line. The problem with first one is that clipboard must be saved, but some apps like CLCL will still catch bunch of files. This works like a charm and very fast.

Second one is issuing CTRL ALT ENTER to set command lines text to path, then grab this text, and send ESC to remove path. This works nice also, but you have flicker in the command line (I can solve this), and it is bad if you hidden command line, then on every move it will be toggled and hidden again, which is not nice. I set the script to work with this method, since I don't like bunch of file names in my CLCL history.

I can also use third technique, to simulate inline Edit grab the name, merge it with path (i can get this) but that is basicly the same as using command line.


There is no other way to get current selection from TC that I know. I am surre that other solutions don't exist. Although you may see that current selection is shown in status bar, this is not the text that I can get, but Ghisler is drawing this ?! If Ghisler could add some hidden field to contain current selection, or send a file name to the world via WM_COPYDATA and new internal command that will request this, we could do this the right way.

Anyway, I think this is good for the start, benefits are big, loses are small.

You can test this, to see yourself.


You need to do following:

1. Implement WM_COPYDATA
2. Implement parameters you suggested (you were right about this)
Parameters should be this:
start in quick view mode

Although you can implement other parameters like hide menu, hide title, I can do all that from AHK for now, so you can skip this and go to the point, witch is WM_COPYDATA.
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 »

But where is test app?
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

Script works. Nice!

But you forgot other key in TC:
Up Down Left Right Home End Ctrl-Home Ctrl-End BkSp Enter Ctrl-PgUp Ctrl-PgDn

Edit:
Yes, we should ask Ghisler to make message about selected filename in TC. And about active panel's Rect.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Hej, Alex, this was only preview.

I will do everything when you implement WM_COPYDATA.
When you receive this message, you will have to get the file name and change the display depending on the type of the file.
Everything else leave to me.
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 »

I will do everything when you implement WM_COPYDATA
So you suggest me to write test app...
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Ok, I will change the script to send the message, so you can use it in testing.
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 !
http://atorg.net.ru/temp/TestMsg.rar
See Readme!
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2majkinetor !
Does script work with test app now?
Post Reply