|
Questions & Answers
|
-
What is PowerPro?
-
What is PowerPro for?
-
How much does PowerPro cost?
-
Where to download PowerPro?
-
What is a script?
-
Why use scripts?
-
Can I use scripts if I am not familiarized with the script language?
-
What is a PowerPro plugin?
-
Where to download PowerPro plugins?
-
What are script parameters?
-
Is PowerPro worth keeping in memory?
-
How to run a script if PowerPro is loaded?
-
How to run a script if PowerPro is not loaded?
-
How to assign a script to the Total Commander's hotkey?
-
How to assign a script to the Total Commander's button?
-
Are all the scripts ready to be run on my computer?
-
Can I modify your scripts? Simplify them? Add new functions? Fix bugs in them?
-
Why script ZZZ displays the error message about the VEC plugin?
-
Why script ZZZ displays some other error message? Why ZZZ does not work as expected?
-
What is Xxcopy? Why do you call it from your scripts?
-
Have I to learn all the Xxcopy switches to use them in your scripts?
-
How much does Xxcopy cost?
-
I've written my own PowerPro script for Total Commander. What should I do?
-
What other questions should I ask?
-
What questions should I never ask?
Q: What is PowerPro?
A: Bruce Switzer, the author of PowerPro, answers this question better than somebody else.
Q: What is PowerPro for?
A: Here I give some examples. Want to learn more?
Q: How much does PowerPro cost?
A: Nothing. It's freeware.
Q: Where to download PowerPro?
A: The latest version is here.
Q: What is a script?
A: In a few words, script is a simple open-source program. Bruce Switzer gives the more detailed and comprehensive explanation of what the script is. First download PowerPro (see previous answer), install it, then open the ppst.chm file, read it chapter by chapter, and find all the answers there.
Q: Why use scripts?
A: Some people use scripts just to save time. Some people do that to automate difficult and/or boring jobs. Some people lack specific functions in programs they use, and make scripts fill these deficiencies.
I'll give some examples of using PowerPro scripts with Total Commander.
Example 1. Local menus
Some file managers, including Norton Commander, precursor of Total Commander, have so-called local menus, that is, those dependent on the current directory. This feature is requested by Total Commander users many times but is not still implemented by Mr. Ghisler. Well, using PowerPro script I realized this idea and now I have 5 local menus in different directories. I invoke them by pressing the F2 key (as in Norton Commander). So, if the specific file (_local.bar) is present in the current directory or its (grand)parent, the local menu is displayed, otherwise the default command ("Reread source") is executed.
Example 2. Merging bars
Suppose you have two button bars, First.bar and Second.bar, 12 buttons on each. You want to merge them into a single button bar. How to do so?
First way is to implement the following procedure 12 times:
-
Pick menu "Options\Change Button bar";
-
Open First.bar;
-
Right-click the next button and select "Copy";
-
Pick menu "Options\Change Button bar";
-
Open Second.bar;
-
Right-click the free space and select "Paste".
Is it boring? No, it is extremely boring!
Second way is to merge files directly and then edit the resulting file, changing cmd9 to cmd21 and so on, totally about one hundred edits. Is it better than the first way? It's an iffy question!
How to do the same with my script?
-
Run the script;
-
If First.bar and Second.bar are current files on active and inactive panels, just press the "Go!" button and that's all. Otherwise pick both files and press "Go!".
Example 3. Saved search
Do you use saved searches? Open the "Find file" window (Alt+F7 by default) and switch to the "Load/Save" tab. Is your list empty? My list comprises 23 saved searches. How to perform a specific search?
-
Alt+F7 - open the "Find file" window;
-
Switch to the "Load/Save" tab;
-
Find a necessary search;
-
Press "Load";
-
Press "Start search".
I am too lazy to do all that each time. I prefer to have a button bar with 23 buttons, one per search. I prefer to do only one mouse click rather than 5 (at least). Are you as lazy as I am? I hope you are.
Example 4. Edit comments of several files
Suppose you have many digital photos. After viewing you divide them into groups:
-
Upload to my site;
-
Nice picture, but needs editing;
-
Send to friends;
-
Oh hell... Never show this to my wife!;
-
Determine their fate later... as the mood takes me;
-
Well, I am not sure though...
The best way to comment a file is provided by Total Commander and is named "Edit file comment" (Ctrl+Z by default). Pay your attention to that the "file" word is in the singular. It's a pity you need to add the same comment to some tens or even hundreds of files from each group. Of course, there is the only, and time consuming solution: make the file list, save it as descript.ion, and then drag comments from one file name to another, switching every time from viewer to the text editor...
I prefer doing as follows. Open quick view window, and using Down and Ins keys mark files from the first group, and finally run the script. As a result, the Upload to my site comment will be assigned to all these files. If some group contains only one file, the cm_EditComment is executed, and nobody could see the difference between it and the script. Moreover, if my intensions regarding some file change, its comment would be like Oh hell... Never show this to my wife! Well, I am not sure though....
Q: Can I use scripts if I am not familiarized with the script language?
A: Of course you can, even if you haven't the slightest idea of programming.
Q: What is a PowerPro plugin?
A: It's a file with the dll (Dynamic Link Library) extension, coded by a qualified programmer. This file contains some functions called from a PowerPro script like this:
plugin_name.function_name(parameters)
For example, to retreive the size of the TotalCmd.exe file, I write the following line in my script:
a = file.size("TotalCmd.exe")
Then the a variable gets equal to "837156" (version 6.53).
Q: Where to download PowerPro plugins?
A: I use three sources of plugins:
-
PowerPro installation package. If you have PowerPro installed, go to the plugins\ subfolder of the PowerPro installation folder. There you'll find the following plugins: au.dll, clip.dll, date.dll, and others;
-
Huge archive of additional plugins and utilities. In my scripts I use ini.dll, miscplugin.dll and osd.dll plugins from that archive. Just extract these files to the plugins\ subfolder, and they are ready to be called from the scripts;
-
Two plugins: childwin.zip (to work with child windows) and tc.zip (to work with Total Commander). Download and extract them to the same subfolder.
Never rename, move or delete any *.dll files from the plugins\ subfolder!
Q: What are script parameters?
A: If you are acquainted with programming it's enough to note that parameters (or "arguments" in terms of PowerPro) are similar to arguments of any function, procedure, or subroutine. Two main distinctions are that PowerPro script parameters have fixed names (arg(1), arg(2), etc.), and their maximum quantity is 9, just as in batch file scripting language.
If you've never programmed, I'll try to answer this question by the example of script SubDirList. This script creates file and/or vector with a list of subdirectories of the current directory. It's obvious that each time the script is executed the current directory is different, and always corresponds to the %P parameter of Total Commander valid in the "Parameters" field of a button. So, the first parameter of the SubDirList script is "%P" (note the double quotes).
The second parameter of the SubDirList script defines where the list should be stored. If you prefer to use the list in your script, it's reasonable to set the second parameter equal to "v" (abbreviation of "vector"). If you would like to save the list as file named _subdirs.lst in the directory in question, then the second parameter is "f" that means "file". Finally, to have both vector and file, set the second parameter equal to "b" (descending from "both"). There is no more possible values of the second parameter: if you need neither vector nor file, why run the script?
As a result you have to pass the following string as a parameter to PowerPro:
runfile.SubDirList("%P", "b")
Pay your attention to the difference between PowerPro parameter and script parameter! PowerPro command line parameter is similar to the parameter (or key) of any program, for example, /N parameter of Total Commander. In the above example the PowerPro parameter is represented by the whole line.
On the contrary, the script parameters (or arguments) in the above example are "%P" and "b". Each script parameter is always included in quotes. If there are two or more parameters, they are separated by comma. Usually the string parameters ("b" in the example) are case sensitive unless the contrary is specified. That is, "B" can not be the second parameter of the SubDirList script.
Some scripts require parameter(s), some others don't. For example, below some of my scripts are called:
runfile.EditFileComments("%L")
runfile.Duplicate("%P%O", "%E")
runfile.LoadBar("D:\Utils\TotalCmd\PanelView.bar")
runfile.SisterDel("%P", "%O", "%E", "1", "b")
runfile.QuickViewWLXPlugins
Script QuickViewWLXPlugins doesn't need any parameters.
In the conclusion it should be reminded that Total Commander parameters like %P, %T, can cause problems when equal to names with spaces. So, some scripts accepting these parameters can work incorrectly. If this happens, try to type their names in lowercase (%p rather than %P, etc).
Q: Is PowerPro worth keeping in memory?
A: Yes, it is. When installing PowerPro you'll see the following window:
Only one thing you have to do is to leave the first checkbox selected. It allows you to use all the PowerPro capabilities: redefine hotkeys (including application-dependent), create bars and menus (or use those included in the installation), set timers, schedule tasks, work with sticky notes, create virtual desktops, etc. Please take into account that after installing PowerPro you could get rid of many small programs that provide these functions - it will free not only the disk space, but the RAM and startup time, too. Finally, if you are not yet ready to work with PowerPro, just do nothing and leave it in memory. It takes only about 1.5 Mb of the RAM (for comparison, Total Commander takes about 9 Mb!).
Q: How to run a script if PowerPro is loaded?
A: There are some ways described in details in the PowerPro manual. I'll tell you about one of the simplest. Just execute the following command:
<path>powerpro.exe runfile.scriptname(parameters)
<path> is a path to the folder where PowerPro is installed (usually
c:\Program Files\PowerPro\). scriptname is a name of file with the powerpro or txt extension, located in the scripts\ subfolder of <path>. This subfolder is created automatically at the PowerPro installation and is initially empty.
Q: How to run a script if PowerPro is not loaded?
A: It's more complex than in the previous case.
Download PowerPro plugin archive. In fact it includes not only plugins, but also some utilities especially destined to work with PowerPro. You need the ppbang utility and its advanced versions (ppbangOnce and ppbangTwice). These utilities are often updated, so you need to download the latest version and familiarize yourself with readme files. In brief, the ppbang* utilities try to pass the script to the running instance of PowerPro. If it is not running, they can first run it.
Q: How to assign a script to the Total Commander's hotkey?
A: If you are aware of how to do it for whatever program, you'll not find anything new in this answer.
-
Pick Total Commander menu: "Start\Change Start Menu\Add Item";
-
Type any suitable name, for example, Test Script;
-
In the "Command" field specify a path to the PowerPro or use the ">>" button to browse. Result is like d:\Utils\PowerPro\PowerPro.exe;
-
In the "Parameters" field type runfile.SomeScript, where SomeScript is a name of the script. Note that neither extension (txt or powerpro) nor path (scripts\) is specified;
-
If a script has no parameters, do not type anything else. But suppose the script requires two of them: current path and number 5. So type runfile.SomeScript("%P", "5");
-
Press "خت";
-
Open the configuration file wincmd.ini, find the [user] section and keys like
menu14=Test Script
cmd14=d:\Utils\PowerPro\PowerPro.exe
param14=runfile.SomeScript("%P", "5")
Here 14 is a user command number given by Total Commander, and you have to learn this number. There is no need to edit the wincmd.ini file;
-
Open the Totalcmd.inc, find the [user] section again and type
cm_usermenu14=714;Test Script
Number 714 is a unique identifier of the user command;
-
Pick Total Commander menu: "Configuration\Miscellaneous", then choose a hotkey in the "Redefine hotkeys (Keyboard remapping)" list. At the end of the "Commands" list find the [user] section (for the third time). Choose our new command cm_usermenu14 (Test Script);
-
Confirm your choice with the green "V" button and finally close the window by "خت".
Q: How to assign a script to the Total Commander's button?
A: It's much simpler:
-
Pick Total Commander menu: "Configuration\Change Button Bar";
-
Press "Append";
-
In the "Command" field indicate the PowerPro path, for example, d:\Utils\PowerPro\PowerPro.exe;
-
In the "Parameters" field type runfile.SomeScript("%P", "5");
-
In the "Icon file" field set a corresponding icon;
-
In the "Tooltip" field write Test script;
-
Press "خت".
Q: Are all the scripts ready to be run on my computer?
A: Most of them are. If not, you have to edit the script code a little bit - usually to indicate path to some files. I mark such places with blue. For example, in the script code you see the following line
global Config = "path\wincmd.ini"
It means that you have to indicate where the wincmd.ini file is on your computer. To do that, pick menu "Help\About Total Commander" and read the "INI-files" section. Then open the script file in any text editor and type the actual path there. Now the script is ready to be run on your computer.
Q: Can I modify your scripts? Simplify them? Add new functions? Fix bugs in them?
A: Of course you can. Moreover, you are encouraged to do that! If you believe that your modification of any kind would be interesting or useful for other people, it's a good idea to send me your version of my script. I'll publish it with your name/nick in the "Author"... sorry, "Authors" field.
Q: Why script ZZZ displays the error message about the VEC plugin?
A: Sometimes I can see the same window... It seems that the vec plugin contains some bugs. Just run the script once more. I've never seen two such messages in turn.
Q: Why script ZZZ displays some other error message? Why ZZZ does not work as expected?
A: If you have successfully run script ZZZ before, first try to run it again. If the error message re-appears try to shut down PowerPro, run it again and then re-run the script.
If ZZZ has never worked, it seems that you did not ensure everything for it to run. Read the script description carefully and check that:
-
Parameters you specify for the script correspond to those in the description;
-
Files and paths indicated instead of my text written in blue are actually existing on your computer;
-
Plugins mentioned in the description ("Plugins Called") are in the plugins\ subfolder of the PowerPro installation folder;
-
File ZZZ.txt or ZZZ.powerpro is in the scripts\ subfolder of the PowerPro installation folder;
-
"Parameters" field of your button/hotkey contains text runfile.ZZZ, not runfile.YYY, that is, you try to run the right script;
-
If ZZZ calls other scripts (it's marked with ;green comments), check whether these scripts are in the appropriate location and have names specified;
-
If ZZZ stores its settings in the configuration file (named usually ZZZ.ini), check that it is in the appropriate folder and that its sections, keys and values are correct;
-
If ZZZ requires Total Commander parameters such as %P, type them in lowercase (%p and %t rather than %P and %T, etc).
-
Put the question mark before parameter. For example, if
runfile.Duplicate("%P%O", "%E")
fails, try using
runfile.Duplicate(?"%P%O", ?"%E")
(advice by J. Kilian)
-
Run pproconf.exe or click "Configure" in the "PowerPro" program menu. Then go to "Setup" tab, press "Advanced Setup" button, and finally "Characters" tab. Check whether your settings correspond to mine.
Q: What is Xxcopy? Why do you call it from your scripts?
A: In brief, Xxcopy is a console utility to manage files and directories. To learn more, visit the Xxcopy homepage.
I call Xxcopy from my scripts because despite all the undoubted advantages of PowerPro, in some cases it shows less stable behaviour than Xxcopy. One of examples is given by TreeDown and TreeUp scripts, on one hand, and TreeDownX and TreeUpX, on the other hand (letter "X" means "using Xxcopy"). All these four scripts execute pairwise the same functions: TreeDown and TreeDownX move down the directory tree (go to the next directory), TreeUp and TreeUpX move up (previous directory). Moreover, the TreeDown and TreeUp scripts are slightly faster than TreeDownX and TreeUpX, but... only if the quantity of files and directories is not too great (up to some hundreds). If there are some thousands of them, the operating speed of TreeDown and TreeUp scripts falls drastically. Sometimes the computer even hangs.
I don't like when my computer hangs. I believe that you do neither. So I developed TreeDownX and TreeUpX scripts that call Xxcopy to make the file list. As a result, the scripts work fine with whatever number of files.
Q: Have I to learn all the Xxcopy switches to use them in your scripts?
A: No, you have not. You have to download and install Xxcopy, and to indicate path to it in the script code. It's quite enough for the script to work.
Q: How much does Xxcopy cost?
A: Xxcopy exists in two versions: freeware (for personal use or product evaluation), and professional (for routine commercial usage in a corporate environment). The former version have some properties disabled. I don't use these properties. I downloaded the freeware version and I use it in my scripts. You can do the same.
Q: I've written my own PowerPro script for Total Commander. What should I do?
A: Great! Send your script to me by e-mail. It would be nice to accompany it with a description similar to that for my scripts. I am certain to publish it with your name/nick in the "Author" field.
Q: What other questions should I ask?
A: Unfortunately, I can't promise that I would answer any question concerning PowerPro scripts for Total Commander, but I'll certainly try to. In fact, most of your questions can be reduced to one of the following:
-
Why script ZZZ does not work?
-
I need a script to do the so-and-so for me. Can you develop this script?
-
Your script ZZZ is fine, but why it lacks the so-and-so function?
Perhaps I can anticipate your questions with the corresponding answers:
-
First read my answer. If it still does not work, familiarize yourself with the configuration all scripts are tested in. I can't guarantee the script functioning in other configurations, for example, under other Windows versions.
-
If I need so-and-so myself, perhaps I'll try to develop this script. In this case your name/nick will be indicated in the "Author" field as follows: "idea by Somebody".
Most probably the so-and-so is a problem that I am not interested in. In this case my answer is most likely negative: no, I can't.
Finally, it's quite possible that so-and-so problem can be solved with PowerPro by neither me nor somebody else. You should take into account that the PowerPro scripting language has very modest capabilities as compared with programming languages like C++, Delphi, or Java.
-
First, may be it cannot be implemented because of the PowerPro limitations. Second, I don't need the so-and-so function, but I'll probably try to develop it. Third, I've just lost sight of this function - in this case I'll do my best to develop the so-and-so function and add it to the ZZZ script.
Q: What questions should I never ask?
A: I'll hardly answer questions about:
-
Features of PowerPro except for scripts (bars, hotkeys, virtual desktops, etc.);
-
Other scripting and programming languages;
-
Application of PowerPro scripts for programs other than Total Commander;
-
God, love and sex.