Lua wdx,wfx (like double commander)

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
nsp
Power Member
Power Member
Posts: 1950
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Lua wdx,wfx (like double commander)

Post by *nsp »

I've done a try to double commander (dev version) :oops: and i've seen that you can create wdx plugin using lua language.

for quick stuff it could be great to have such scripting capability directly embedded.

2Ghisler as the next version is compiled with lazarus/freepascal you can even give a look at what is done in double commander...
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

I don't know LUA, but I have heard very positive things about it. I know Civilization-V uses it instead of Python this time around. Although I'm boycotting CIV until at least CIV-6 -- hopefully it wont suck :-)
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Interesting that there's so little reaction to this suggestion. Personally I find scripting to be one of the bigger features TC lacks.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50873
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Currently it's not planned to put internal scripting in Total Commander. Why? Windows is a multi-tasking system, and many tasks may involve multiple programs. Therefore it's better to use a system-wide scripting tool like AutoHotkey instead of a separate one in each program.
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
I think the best solution would be to create an object model which can be used in script languages like VBScript. Look at SpeedCommander for instance.
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Lefteous wrote:2ghisler(Author)
I think the best solution would be to create an object model which can be used in script languages like VBScript. Look at SpeedCommander for instance.
You mean COM?
User avatar
Lefteous
Power Member
Power Member
Posts: 9537
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

Well if there would be AppleScript or Automator on Windows I would prefer this :-)
Have you ever worked with AppleScript?
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

I have,
Example Applescript:
Please Mr.Jobs print this variable when you can get around to it from the Opera application using quoteformat unless there are no quotes then fail.
Applescript can't even natively do Regex without piping the string into the command prompt and using SED or Grep/Awk.
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
HBB
Senior Member
Senior Member
Posts: 295
Joined: 2008-05-05, 21:31 UTC

Post by *HBB »

I support Lefteous' suggestion :
I think the best solution would be to create an object model which can be used in script languages like VBScript.
Or, at least, internal support to vbscript as similar (and with improved way) in the plugins ScriptContentPlugin, ScriptWFX, ....

I see that writing a plugin requires to know delphi, C++ or any other programming languages. To learn them needs time and interest.

I believe that there should be some simple ways for daily needs of average users (like me).

Regards
User avatar
JohnFredC
Power Member
Power Member
Posts: 886
Joined: 2003-03-14, 13:37 UTC
Location: Sarasota Florida

Post by *JohnFredC »

Lefteous wrote:I think the best solution would be to create an object model which can be used in script languages like VBScript. Look at SpeedCommander for instance.
Yes! I suggested an object model several years ago here!

No need for a scripting engine inside TC itself, just an interface to a defined model + methods and perhaps some dedicated hooks in the interface to start an editor, list scripts, run a script, etc.

The latest version of Salamander has exactly this schema (look under Plugins->Automation). Very useful.
Licensed, Mouse-Centric, moving (slowly) toward Touch-centric
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50873
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No need for a scripting engine inside TC itself, just an interface to a defined model + methods and perhaps some dedicated hooks in the interface to start an editor, list scripts, run a script, etc.
Hmm, I don't know whether this is possible at all with Delphi...
Author of Total Commander
https://www.ghisler.com
Harding
New Member
New Member
Posts: 1
Joined: 2011-11-12, 19:34 UTC

Post by *Harding »

For the ones interested, I have used Total Commander with Python for some nice scripting.

Example: I made a small script that use 7-zip to "decompress here" function.

Howto:
1. Install Python.
2. Install 7-zip
3. Edit your usercmd.ini and add:

Code: Select all

[em_zip_compress_here]
cmd=C:\Python26\python.exe
button=C:\Python26\python.exe
param=c:\Python26\zip_operation_here.py compress %L

[em_zip_decompress_here]
cmd=C:\Python26\python.exe
button=C:\Python26\python.exe
param=c:\Python26\zip_operation_here.py decompress %L
4. Create your c:\Python26\zip_operation_here.py with the following code:

Code: Select all

# Written by Harding 2011-11-13 version 1.1
import sys
import time
import string
import os.path
import subprocess
import datetime

path_to_7z = "\"c:\\Program Files (x86)\\7-Zip\\7z.exe\""
ext_to_use = "zip" # can also be "7z"

def compress_7z(arg_src_files, arg_dst_dir):
	src_files_string = ""
	for file in arg_src_files:
		src_files_string = src_files_string + " \"" + file.strip() + "\""

	command = path_to_7z + " a \"" + arg_dst_dir + "\" " + src_files_string
	subprocess.Popen(command)


def decompress_7z(arg_src_files, arg_dst_dir):
	for compressed_file in arg_src_files:
		command =  path_to_7z + " x -o\"" + arg_dst_dir + "\\" + os.path.basename(compressed_file) + ".dir\" \"" + compressed_file + "\" "
		subprocess.Popen(command).wait()
		
		# If it was only 1 folder that we unpacked then move it up one step
		files_unpacked = os.listdir(arg_dst_dir + "\\" + os.path.basename(compressed_file) + ".dir")
		if (len(files_unpacked) == 1 and os.path.isdir(arg_dst_dir + "\\" + os.path.basename(compressed_file) + ".dir\\" + files_unpacked[0])):
			command = "mv \"" + arg_dst_dir + "\\" + os.path.basename(compressed_file) + ".dir\\" + files_unpacked[0] + "\" \"" + arg_dst_dir + "\""
			subprocess.Popen(command).wait()
			
			# Delete the folder we generated
			command = "rmdir \"" + arg_dst_dir + "\\" + os.path.basename(compressed_file) + ".dir\""
			subprocess.Popen(command).wait()
	
if __name__ == '__main__':
	if (len(sys.argv) < 3):
		print "Invalid nubmer of args"
		exit()
	
	if ("compress" == sys.argv[1] or "decompress" == sys.argv[1]):
		with open(sys.argv[2], "rb") as f:
			all_marked_files = f.readlines()
		all_marked_files = [x.strip() for x in all_marked_files]
		dt = datetime.datetime.now()
		dt = datetime.datetime.timetuple(dt)
		full_path = all_marked_files[0].strip().split("\\")
		full_path = [x for x in full_path if x]
		
		dst_dir = full_path[0]
		for i in range(1, len(full_path)-1):
			dst_dir = dst_dir + "\\" + full_path[i]

		if ("compress" == sys.argv[1]):
			compress_7z(all_marked_files, dst_dir + r"\0000_" + time.strftime("%Y-%m-%d_%H_%M_%S", dt) + "_" + os.path.basename(all_marked_files[0]).strip() + "." + ext_to_use)
		else:
			decompress_7z(all_marked_files, dst_dir)
	else:
		print "Unknown command. Only \"compress\" and \"decompress\" are supported"
		
	# time.sleep(10)
Not perfect code but you get the idea.

5. Set your hotkey under configuration -> options -> Misc. -> Command -> usercmd.ini -> em_zip_compress_here

EDIT: Added the funcionallity to create a folder for each archive and if it was only a folder in the archive then move it up one step.
Post Reply