Sign in to follow this  
Followers 0
maprwz

COBOL popup in ProcessList but not WinList

4 posts in this topic

I am encountering a COBOL popup window when the program errors. When I am running in foreground mode (a Remote Desktop session) my script can see both the window using WinList and the process using Process list. So I just send an {ENTER} to the window and everything is OK.

When I execute the same COBOL program and script in background mode (from a special client) I only get two windows using Winlist and the COBOL popup window is not one of them. However I do get all the same processes using ProcessList.

I need to send an {ENTER} to the COBOL popup window. I cannot just kill the process, because I need it to write out a .LOG file and it does not do that if I kill the process.

BTW: my server is Windows 2003

Share this post


Link to post
Share on other sites

I realized that I was only listing the windows that had titles. And since a lot of the titles are blank I wasn't seeing them.

When I printed out a the list from WinList() I found that is was providing handles and not PID's so I added this code to convert it:

$win = WinList()
  For $i = 1 to $win[0][0]
       $handle = $win[$i][1]
       $wtitle = $win[$i][0]
       $wpid = WinGetProcess ($handle)

Then I found that most of the time there were 3 windows for each process: one with a blank title, one with the title of the window and one with the name of the .EXE.

Using this I was able to match the Process to the window.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Now that I had the window I wanted, I did a WinActivate and then a Send. But when I executed it in background, with my special client, nothing happened!

Adding some debugging code I found that the WinActivate failed. So what worked in the foreground did not work in background.

Edited by maprwz

Share this post


Link to post
Share on other sites

So drawing on previous experience with foreground and background tasks I determined that I would need to run the script on the desktop. The technique I used was:

  • create a daemon and install it as a service with "Interact with Desktop". The daemon:

    - watches a directory for a script file

    - gets the script file name and uses Run() to execute the script

    - deletes the script file

  • the routine that the special client uses builds the script and puts it into the daemon's directory
This techinque worked perfectly!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0