INTRODUCTION:
This script was started as an alternative to the Monitor or Open special lists. My recommendation is to learn to use those lists, as they are very powerful. In rare cases, you may find that this script is more useful or more flexible.
I enjoyed this script especially as a learning tool.
Prior to running the script, you need to specify which window captions it should monitor and which PP commands it should execute when the window captions are "found". Note that the meaning of "found" can be specified as a parameter to this script.
Window captions and PP commands are specified in an external file (multiple files are supported, see below). For instance, specify
*notepad* %windir%\media\ding.wav
to play a ding when notepad is "found".
There are three ways to use this script:
(1) Run it from the command line or from another script, it will perform its actions once and then exit.
(2) Assign it to the Open special list, it will monitor all new "found" windows.
(3) Assign it to the Monitor special list, it will periodically monitor all "found" windows.
It gives you more flexibility than Open or Monitor, but it's less performant (less snappy) and, admittedly, not all combinations of "found", captions and commands make practical sense. But you should experiment and see what's useful for you. And don't forget that you can use the Open or Monitor lists directly. See some examples following the USAGE section.
USAGE:
powerpro .Window_ActOn( [ <window predicate> ] )
where <window predicate> is an optional STRING and can be one of
[not] visiblewindow
[not] activewindow
[not] anywindow
[not] win.maxxed
[not] win.minned
[not] win.topmost
[not] win.trayminned
[not] win.resizable
[not] win.maxable
[not] win.minable
[not] win.toolwindow
when <window predicate> is omitted, "activewindow" is used "not" can be used to invert the predicate value. See powerpro.hlp and plugins/win.txt for definitions of each <window predicate>. See also the CONFIGURATION section below.
CONFIGURATION FILE:
The config filename must be the same as the script filename with .powerpro/.txt replaced by .cfg. Both files must be in the same folder. The config file MUST be tab-delimited with NO empty lines. example
<caption1><tab><actions1>
<caption2><tab><actions2>
...
If you need to use different configuration files just rename this file and its configuration file accordingly. Multiple copies of this script can be used simultaneously, provided that each copy has a unique filename and hence configuration file.
EXAMPLES:
(A) To associate commands to new windows:
create a new command list named
[OnNewWindows]
Name field: *
Command field: .Window_ActOn("visiblewindow")
Start pproconf, go to Command lists > Setup > Special Lists enter "OnNewWindows" in the Open field
In the configuration file Window_ActOn.cfg enter
*notepad* %windir%\media\ding.wav
Explanation: Each time a new window is created, OnNewWindows("visiblewindow") is executed, which in turn looks for visible windows whose captions match the captions specified in the .cfg file, *notepad* in this case. For all matches found, their associated set of PP commands are executed, ding.wav in this case. Thus, every time any new window is created, if notepad is still visible the same match will be found, and a ding will play. Admittedly, this example may be of limited value to you. Just experiment.
(B) To associate commands to new windows:
In the above example, change
.Window_ActOn("visiblewindow")
to
.Window_ActOn("activewindow")
in the Command field
Explanation: ding.wav will play only when notepad is the active window AND a new window is created. In practical terms, this is typically what happens when notepad is started.
(C) To do something to open windows:
In the above example, change
.Window_ActOn("activewindow")
to
.Window_ActOn("anywindow")
in the Command field
and change
*notepad* %windir%\media\ding.wav
to
*notepad* win close! *notepad*
Then run this script from the command line. It will close all notepad windows, if any.
LIMITATIONS:
PowerPro 3.8 and below can't detect new console windows, hence this script isn't called when a new command processor (cmd.exe, etc.) window opens
|