Internal Associations for Extracting Archives

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

Moderators: white, Hacker, petermad, Stefan2

User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Internal Associations for Extracting Archives

Post by *robinsiebler »

I created some Internal Associations for Archives and an AutoHotKey script for extracting them. Feel free to use/modify this.

What the context menu looks like - Image: http://www.freeimagehosting.net/newuploads/ucnm4.png

Internal Associations

Code: Select all

[Associations]
Filter1=>Archives
Filter1.icon=C:\Program Files\totalcmd\Icons\WinXP2.icl,8
Filter1_Extract Here=c:\scripts\AutoHotKey\Extract_Archives.ahk "ExtractHere"
Filter1_Extract Here into SubDir=c:\scripts\AutoHotKey\Extract_Archives.ahk "ExtractHereSubDir"
Filter1_Extract into Opposite Pane=c:\scripts\AutoHotKey\Extract_Archives.ahk "ExtractOpposite"
Filter1_Extract into Opposite Pane Subdir=c:\scripts\AutoHotKey\Extract_Archives.ahk "ExtractOppositeSubDir"
Filter1_Extract to (Pick Dir)=c:\scripts\AutoHotKey\Extract_Archives.ahk "ExtractTo"
AutoHotKey Script

Code: Select all

/*
# Name:     	Extract_Archives.ahk
# Purpose:    	This script will automate the extraction of an archive, based 
#			  	upon the option the user chooses.
#
# Requirements:
#		AutoHotKey (duh!) - http://www.autohotkey.com/
#		Total Commander (duh!) http://www.ghisler.com
#		TCFS2 - http://www.totalcmd.net/plugring/tcfs2.html
#
# Note: You MUST change line 20 to point to your location of TCFS2!
#
# Author:     	Robin Siebler
# Created:     	05/20/2012
# Version:		0.5
*/

#NoTrayIcon

Run "%COMMANDER_PATH%\Tools\TCFS2\TCFS2.exe" /ef "tcm(509)"	;Open the Unpack dialog
NumParams := 0
ExtractAction = %1%

if (%NumParams% < 1)
{
	MsgBox, Missing Extraction Parameter!
	Exit
}
if (ExtractAction = "ExtractHere") {		;Extract Here
	WinWait, Unpack files, , 5
	if ErrorLevel {
		MsgBox, WinWait timed out.
		Exit
	}
	else {
		WinActivate				;Focus the Unpack dialog
		Send .\{Enter}			;Enter the current path and close the dialog
		IfWinActive Unpack files
			Send {Enter}
	}
} else if (ExtractAction = "ExtractHereSubDir")	{ 	;Extract Here into a Subdir
	WinWait, Unpack files, , 5
	if ErrorLevel {
		MsgBox, WinWait timed out.
		Exit
	} else {
		WinActivate
		Send .\{Enter}				;Enter the current path
		ControlClick TCheckBox1		;Check the 'unpack into subdir' checkbox
		ControlClick TButton4		;Click the OK button
	}
} else if (ExtractAction = "ExtractOpposite") {	;Extract into Opposite Pane
	WinWait, Unpack files, , 5
	if ErrorLevel {
		MsgBox, WinWait timed out.
		Exit
	} else {
		WinActivate
		ControlClick TButton4	;Click the OK button
	}
} else if (ExtractAction = "ExtractOppositeSubDir") {	;Extract into Opposite Pane SubDir
	WinWait, Unpack files, , 5
	if ErrorLevel {
		MsgBox, WinWait timed out.
		Exit
	} else {
		WinActivate					;Focus the Unpack dialog
		ControlClick TCheckBox1		;Check the 'unpack into subdir' checkbox
		ControlClick TButton4		;Click the OK button
	}
} else if (ExtractAction = "ExtractTo") {	;Extract to Selected Dir
	WinWait, Unpack files, , 5
	if ErrorLevel {
		MsgBox, WinWait timed out.
		Exit
	} else {
		FileSelectFolder, ExtractDir, , 3, "Select Extraction Folder"
		if ErrorLevel or ExtractDir =  {
			MsgBox You didn't pick a folder
			ControlClick TButton2
			Exit
		} else {
			WinWait, Unpack files, , 5
			if ErrorLevel {
				MsgBox, WinWait timed out.
				Exit
			} else {
				WinActivate							;Focus the Unpack dialog
				Send %ExtractDir%{Enter}{Enter}		;Enter the selected path and close the dialog
			}
		}
	}
}
Last edited by robinsiebler on 2012-05-22, 06:55 UTC, edited 1 time in total.
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Post by *robinsiebler »

I found a bug in my script :(

I've updated the code. :)
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

[mod]Moved to the Plugins and addons forum.

Hacker (Moderator)[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Re: Internal Associations for Extracting Archives

Post by *sgp »

robinsiebler wrote:I created some Internal Associations for Archives and an AutoHotKey script for extracting them. Feel free to use/modify this.
Nice application! I have linked this post to my context menu wiki tutorial (in section References), Feel free to delete the link if you don't want it there.
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Post by *robinsiebler »

Nope. Knock yourself out! :)
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
Sparhawk110
Junior Member
Junior Member
Posts: 11
Joined: 2009-02-11, 00:57 UTC

Post by *Sparhawk110 »

I am not familiar with scripting in TC. However this is exactly what I've been looking for. I have been able to get it to work and I love it, great job. I'm wondering if you could help me modify it slightly so that I have an option to do the extract with no confirmations and auto send to background.

Possibly adding another line on the right click like:

Extract Into Opposite Pane (Internal/NoCon)

or something similar.

Either that or a line in your script that I could add that would turn that feature on for any or all of your existing right click destinations.

Also, is it possible to have a keyboard shortcut for each of the extracts as well. I am trying to automate extracting large numbers of archived files.

I'm excited that I found this post, its right along the lines of what I need.
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Post by *robinsiebler »

I'll see what I can do. - Not much. :(

As far as I can tell, I can't put the unpack dialog into the background. That would need to be addressed in TC itself. As for a confirmation, you should not see the dialog at all, but sometimes the AHK script itself fails. There isn't anything that I can do about that; AHK is not a very robust tool in that regard. Perhaps someone more knowledgeable in the ways of AHK could address this failing of my script.

Personally, I got disgusted with how often the AHK script can fail, and created a similar script using vTask Studio (commercial software). It never fails. I could compile that script and give you the executable, but it may cause a problem with any anti-virus software you use.
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
Sparhawk110
Junior Member
Junior Member
Posts: 11
Joined: 2009-02-11, 00:57 UTC

Post by *Sparhawk110 »

I was able to get rid of some of the confirms I wanted to by modding the wincmd.ini file. So it is close to what I wanted. As far as the other script, sure, I'd be interested to try it out if you can get it to me. Thanks for taking a look. Just as it is now, it saves me a ton of time. Any thoughts about how to hotkey the new functions the script creates?

and thanks again.


robinsiebler wrote:I'll see what I can do. - Not much. :(

As far as I can tell, I can't put the unpack dialog into the background. That would need to be addressed in TC itself. As for a confirmation, you should not see the dialog at all, but sometimes the AHK script itself fails. There isn't anything that I can do about that; AHK is not a very robust tool in that regard. Perhaps someone more knowledgeable in the ways of AHK could address this failing of my script.

Personally, I got disgusted with how often the AHK script can fail, and created a similar script using vTask Studio (commercial software). It never fails. I could compile that script and give you the executable, but it may cause a problem with any anti-virus software you use.
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Post by *robinsiebler »

Here is a link to the scripts and a file containing the associations needed for them to work.

As for hotkeys, you can edit the TC config files to create your own hotkeys. This tool contains a Hotkey editor.
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
Sparhawk110
Junior Member
Junior Member
Posts: 11
Joined: 2009-02-11, 00:57 UTC

Post by *Sparhawk110 »

robinsiebler wrote:Here is a link to the scripts and a file containing the associations needed for them to work.

As for hotkeys, you can edit the TC config files to create your own hotkeys. This tool contains a Hotkey editor.

I think Ive got the concepts down fairly well, and Im sure my issues are completely me but Im wondering where the .exe files come into play with this. Your script is asking for .vxm. What am I missing. The associations work but the script doesnt run with the .exe. I think that is my only problem right now. And yes, I modified all the paths to match my own system and drives if you were wondering.

The hotkey editor is exactly what I needed,thanks.
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Post by *robinsiebler »

Sorry, change the .vxm to .exe. I use vTask Studio (a commercial program), so you couldn't run the scripts directly without that installed. The .exe is a compiled version of the script. It may or may not trigger a false positive on your virus software.
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
Sparhawk110
Junior Member
Junior Member
Posts: 11
Joined: 2009-02-11, 00:57 UTC

Post by *Sparhawk110 »

robinsiebler wrote:Sorry, change the .vxm to .exe. I use vTask Studio (a commercial program), so you couldn't run the scripts directly without that installed. The .exe is a compiled version of the script. It may or may not trigger a false positive on your virus software.

actually i got it, just opened the exe in the vtask and saved as a vxm, and it now works....however im getting an error on step 40. It looks like its trying to press the last OK button and fails. If I press it myself quickly before the error pops up, it works and no error comes up. Any ideas. (this is with the extract to opposite pane option) But all of them fail on that last step of pressing the last OK.

TC- Extract Archive.vxm - Step 40
File: TC - Extract Archive.vxm
Step: 40
Time: 11:22
Action "Use Window"
Error: Unable to find window 'OK|TButton'

The others are similar just with a different line error.
Sparhawk110
Junior Member
Junior Member
Posts: 11
Joined: 2009-02-11, 00:57 UTC

Post by *Sparhawk110 »

One more thing, looking at Vtask, the command it is having trouble with in each case is "Activate, First, Title + Class" in each option.
Sparhawk110 wrote:
robinsiebler wrote:Sorry, change the .vxm to .exe. I use vTask Studio (a commercial program), so you couldn't run the scripts directly without that installed. The .exe is a compiled version of the script. It may or may not trigger a false positive on your virus software.

actually i got it, just opened the exe in the vtask and saved as a vxm, and it now works....however im getting an error on step 40. It looks like its trying to press the last OK button and fails. If I press it myself quickly before the error pops up, it works and no error comes up. Any ideas. (this is with the extract to opposite pane option) But all of them fail on that last step of pressing the last OK.

TC- Extract Archive.vxm - Step 40
File: TC - Extract Archive.vxm
Step: 40
Time: 11:22
Action "Use Window"
Error: Unable to find window 'OK|TButton'

The others are similar just with a different line error.
User avatar
robinsiebler
Senior Member
Senior Member
Posts: 460
Joined: 2003-03-05, 21:04 UTC

Post by *robinsiebler »

For the title, make sure it matches the title of your Total Commander bar. For it failing to click the OK, button, I am not sure. That never fails for me. You could try adding a pause before the mouse click and see if that works.
Robin L. Siebler
Personal License #13949
------------------------------
"Bother", said Pooh, as he deleted Windows
Sparhawk110
Junior Member
Junior Member
Posts: 11
Joined: 2009-02-11, 00:57 UTC

Post by *Sparhawk110 »

robinsiebler wrote:For the title, make sure it matches the title of your Total Commander bar. For it failing to click the OK, button, I am not sure. That never fails for me. You could try adding a pause before the mouse click and see if that works.

Nope still no good, thinking through, im wondering about versions of total commander.

I'm trying with 8.01 both 32bit and 64bit, same errors with both.
Post Reply