ozboomer has asked for the wisdom of the Perl Monks concerning the following question:
First-up, I'm running ActiveState perl v5.8.9 under Windows XP SP3 (32-bit) on a fairly reasonable Inter Core2 Duo PC @ 3GHz and with 4GB RAM...
I have an application where a number of instances of an .exe run and they each have different title text on their windows.
I'm trying to work a way that I can capture the window title for each of the instances and if one of the items is missing, I can do something to restart it, viz:
list of jobs = (123, 456, 789) for each running job process if process window title matches one of job list note job number is running go to next process endif endfor for each required job if not flagged as running create the job endif endfor
Now, I can use something like Win32::Process::Info to get some basic info... but not the window title (although, that module seems to be rather unreliable anyway). If I use Win32::API, I can get into GetConsoleTitle() in kernel32.dll and retrieve the window title for my own cmd.exe process... but how do I get the window title for another process?
I can do things a very klunky way and shell out a 'tasklist' command and then parse the results, viz:
c:\>cmd.exe /c "tasklist /v" Image Name PID Session Name ... CPU Time Window Title =========== ====== ============ ... ========== ==============... Socks.exe 10968 Console 0:00:01 2442 - Socks Socks.exe 1240 Console 0:00:00 2745 - Socks Socks.exe 20720 Console 0:00:01 4085 - Socks Socks.exe 6188 Console 0:00:00 2423 - Socks
...but I would think there'd have to be a 'native perl' -way to do it?
I've scoured through CPAN and had a look through the Monks' site but have had no joy.
I would appreciate any thoughts on a 'more elegant' means to approach the problem.
Thanks.
|
|---|