Packing and scripting

English support forum

Moderators: white, Hacker, petermad, Stefan2

snaggy
Junior Member
Junior Member
Posts: 43
Joined: 2006-04-25, 07:09 UTC

Packing and scripting

Post by *snaggy »

I have some general questions about scripting... taken the example of packing:

My problem (quite simple, just an example) : I want TC to automatically pack with a chosen packer all the files selected in the source panel, with the same directory as destination.

To do so now I use CTRL + mouse click on the icon (didn't find any shortcut or command..)

Is this a case in wich scripting can get useful? And is there a way to make scripts inside TC or I have to use external programs running in background (and using resources...) ?

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

Post by *majkinetor ! »

U use scripts when you want to avoid repetition of tasks over and over.

In your case you can use batch, and that is the easiest way. Scripts inside TC don't exist, you can eventualy use plugin for that, which is not very well documented. Batch is documented on other hand and people know how to do it and it is beyond TC. U can alternatively use VBscript or JavaScript but, as I said before, for your primer, batch is no more then several lines.
or I have to use external programs running in background (and using resources...) ?
everything is using resources. Plugins are like 3thd party programs just with less overhead but if they are programmed bad, they can eat more resources then starting another application. So, you can't do anything here until TC have its own scripts. Batch use console applications, which have no GUI (usualy) and are usualy not made by lamers, so, again, batch is the best for you.

If you use batch u have some tricks to hide its black winodow from appearing.
Habemus majkam!
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Re: Packing and scripting

Post by *Sheepdog »

snaggy wrote: I want TC to automatically pack with a chosen packer all the files selected in the source panel, with the same directory as destination.
Default for packing is [Alt]+[F5] (cm_packFiles). Packing to the source can be achieved with modifier Control key. (just like you do with the mouse)
Is this a case in wich scripting can get useful? And is there a way to make scripts inside TC or I have to use external programs running in background (and using resources...) ?
There is no internal scripting tool available. But several samples for scripting with external tools in TC are described in the Wiki.

Personally I prefer Autohotkey.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

To do so now I use CTRL + mouse click on the icon (didn't find any shortcut or command..)
Enter this in your wincmd.ini (@Sheepdog: long ago you have created these, right? ;)):

Code: Select all

[Shortcuts]
CA+F5=cm_PackFiles
CAS+F5=cm_PackFiles
From now on you can press Alt-Ctrl-F5 if you want to pack in same panel and Alt-Ctrl-Shift-F5 when you also wanna move the files into the archive.

If you know what archive you want to create, the steps
1. press Alt-Ctrl-F5
2. choose packer
3. press OK

can be scripted using AutoHotkey, that's one minute of "work".

AHK uses about 2 MB of RAM when idling and no CPU resources at all when using hotkeys only. I am using dozens of hotkeys created with AHK without any impact on system performance.

Icfu
This account is for sale
snaggy
Junior Member
Junior Member
Posts: 43
Joined: 2006-04-25, 07:09 UTC

Re: Packing and scripting

Post by *snaggy »

2 icfu:

It works, but why? The command is always the same, how can TC understad if you always say cm_PackFiles?

2 majkinetor !:

I've never used batch, how can I get some infos about it, and about its integration in TC?
snaggy
Junior Member
Junior Member
Posts: 43
Joined: 2006-04-25, 07:09 UTC

Post by *snaggy »

I've tried to use F9 in place of ctrl alt f5 but of course it doesn't work, it gives me the standard alt f5 dialog. How does it work?
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

It's a special implementation by ghisler. Don't ask, just use it. ;)
Edit: It doesn't work for other commands, so you can stop trying.

If you want to unpack to the same directory, just press DEL after pressing Alt-F9 (or F6). If you want to always unpack to the same directory, use this AHK script:
http://www.ghisler.ch/wiki/index.php/AutoHotkey:_Unpack_each_archive_to_a_separate_subdir

Icfu
This account is for sale
snaggy
Junior Member
Junior Member
Posts: 43
Joined: 2006-04-25, 07:09 UTC

Post by *snaggy »

I'm trying ahk, sounds good and powerful, but a bit hard to get used to at the beginning...

Anyway, if I have, let's say, 12 scripts I want to keep running, do I have to store them all in a .ahk file in order not to have 12 tray icons?!?

bye
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Yes, or like written here:
http://www.ghisler.ch/wiki/index.php/AutoHotkey
(alternatively add it to the AHK autostart file AutoHotkey.ini);
I have several AHK files running at the same time, each of them containing several scripts. My autohotkey.ini looks like that:

#Include, D:\Scripts\AHK\Hotkeys.ahk
#Include, D:\Scripts\AHK\Hotstrings.ahk
#Include, D:\Scripts\AHK\Total Commander.ahk
etc... You get the idea.

You can also add #NoTrayIcon in each of your AHK files if you prefer to start them manually each time you need them.

Icfu
This account is for sale
snaggy
Junior Member
Junior Member
Posts: 43
Joined: 2006-04-25, 07:09 UTC

Post by *snaggy »

I see you know a lot about ahk, I found some scripts of yours in the wiki page.

I have some questions though..
I have my unpack script working now, and i was trying the pack one. I did a kind of macro...

send ctrl alt f5, then select zip and hit OK

The ctrl alt f5 works fine, but I'd like to know how you get the windows as you did (WinWaitActive, ahk_class TDLGUNZIPALL) for the un pack.

The select zip is a problem. How can I tell him wich checkbox is it? You used
ControlSend, TCheckBox1, {SPACE}
but how to do that in my case? If I try the recorder he follows my mouse and records where it clicks....

anyway, it's getting interesting..
Last thing, is it possible to use as hotkey a single key such as F9? (I gess no, right?)

bye
User avatar
Hacker
Moderator
Moderator
Posts: 13081
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

I'd like to know how you get the windows as you did (WinWaitActive, ahk_class TDLGUNZIPALL) for the un pack
Right click on any script's tray icon and select Window Spy, then click on any window.
is it possible to use as hotkey a single key such as F9?
Sure it is. :)

Roman
Last edited by Hacker on 2006-05-05, 18:49 UTC, edited 1 time in total.
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.
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

icfu wrote:
To do so now I use CTRL + mouse click on the icon (didn't find any shortcut or command..)
Enter this in your wincmd.ini (@Sheepdog: long ago you have created these, right? ;)):

Code: Select all

[Shortcuts]
CA+F5=cm_PackFiles
CAS+F5=cm_PackFiles
Shit, you got me. ;)
snaggy wrote:I've tried to use F9 in place of ctrl alt f5 but of course it doesn't work, it gives me the standard alt f5 dialog. How does it work?
It is the Ctrl-key that tell TC to use the pack to current Dir. Assign cm_packfiles to Ctrl+F9 and it will work.



sheepdog
Last edited by Sheepdog on 2006-05-05, 17:08 UTC, edited 1 time in total.
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Snagy, you can do ANYTHING with ANYTHING, so questions like can I do this or that are pointless.

AHK, batch, JS or VB can do anything you can imagine, like any other programming language.


You can find many of examples how to use batch via google.
New version of command line for Windows is named Monad and it will be very powerful and above all, object oriented, which is first in "console world" that I know (counting other operating systems).

You can connect any batch script via Start Menu and so, hotkey.
Habemus majkam!
snaggy
Junior Member
Junior Member
Posts: 43
Joined: 2006-04-25, 07:09 UTC

Post by *snaggy »

I had almost forgot about batch, I'll search sm about it later.. Now I realized that with some efforts almost everything can be done, as you said

by the way, I made a script wich allows me to
AltGr + F9 --> to a zip in the same directory
AltGr + F10 --> to a rar in the same directory
Alt + F9 --> extract everything in a subfolder ...

It's really great!

I still have a question: if TC has a default hotkey, for example CTRL + F9, that I'll never use and I'd like to remap to a ahk function, what should I do?
I mean: ctrlF9 prints, I want it to execute an ahk script and not the default function

bye, and thank you all for the prompt replies, I've never seen such an active forum!
User avatar
Sheepdog
Power Member
Power Member
Posts: 5150
Joined: 2003-12-18, 21:44 UTC
Location: Berlin, Germany
Contact:

Post by *Sheepdog »

snaggy wrote:I still have a question: if TC has a default hotkey, for example CTRL + F9, that I'll never use and I'd like to remap to a ahk function, what should I do?
Two ways:

1. You create a usermenu entry that does nothing

[user]
menu10=cm_NoAction

and after that assign ctrl+F9 to it(Configuration->Options->Misc:Redefine Hotkeys). So TC will execute the command that does nothing and AHK will execute the command you programmed.

2. You check first if TC is active window and if yes you 'eat' the hotkey

Code: Select all

#IfWinActive, ahk_class TTOTAL_CMD

^F9::
msgbox, hallo
return


So you don't use the "~" the key would not be passed through.

sheepdog
"A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete fools."
Douglas Adams
Post Reply