i wanted to say a few words about one program being able to read another programs screen output and did not want those words hidden deep inside another thread, so bear with me.
Chris Holbrook wrote a good example on how to read a console programs console screen buffer.
title:screen scrape a DOS application in the source code section
http://www.powerbasic.com/support/pb...ad.php?t=37868
the code does not work in windows 2000 pro or below because the program uses the attachconsole function and that function is only support in windows xp and up versions. do a search on attachconsole and get some details on operating systems supported.
so far i have not found a way to do what the program above code from Chris does in windows 2000 pro.
there are some workarounds but still have not found an alternative to his type of program where it can read, as far as i know, most all console programs output. it appears there is a way of locking the console's screen buffer of a console program to keep another program from reading the buffer, but that is another story.
in my efforts to read a consoles screen buffer and put that to good use for my needs, i also knew that i was going to have concerns in trying to have a program read a specific console programs screen. you surely do not want two console programs running with the same caption or program title inside the process ids. how easily could it make your program find which console screen buffer to read if there were more than one program running with the same ids.
the reason for this post is to report that maybe a combination of two programs can be used get the desired effects and have easily resolved problems of more that one instance of a console program running and trying to acquire the console screen buffer.
i am doing my best to make this short so stick with me
many programs written do not have embedded code to recognize that another instance of the same program is running, and also may console programs run very well behaved when having more than one instance of the program running and perform well behaved even while using a the same database.
half of the incentive behind a program i wrote call ISITRNIT was for the reason of having a second program monitor the console screen buffer of another program and insuring that the program monitoring the program knows which programs console screen buffer to monitor.
ISITRNIT.EXE and CONSNAME.EXE can be gotten here.
by using ISITRNIT, the program should not let you run multiple instances of the same batch job from a certain point after the program ISITRNIT is used in the batch job, and you do have to place statements in the batch file to interpret the ERRLEVEL returned to either abort the batch job or let the batch job continue to execute other statements.
when the batch job continues to execute(does not abort) after the IRITRNIT program, then the batch file will hopefully have the process id name as what was named from the IRITRNIT program. if any other statements have an effect of renaming the process id name, then maybe by using the CONSNAME program can reset the process id name back to what name you wanted in the beginning of the batch job.
using IRITRNIT and using CONSNAME to reinforce the process id name can hopefully limit the chance of second instance of the program starting thereby allowing a different program written to monitor just that one console program's console screen buffer.
sorry, it is only wordy because i am having a hard time with describing the events.
so as i said before elsewhere, i like using batch files to start programs and using these two programs, ISITRNIT and CONSNAME, you can do something like this
a simple batch file listing
from the lines above, you can see where i would put my program that is monitoring the program "EDIT ME.TXT".
without being said, it is up to you to create the program "monitorprogram", using Chris's code as a starter.
there will be some problems where programs name their own captions/program id names and you can use the program ISITRNIT by itself to list program id names from a command prompt window.
hopefully the console program you are going to use does not rename the window's title caption making it easier for you to accomplish your goal of reading a console program's console screen buffer. it could be the end of the ropes as one might say if that would happen if you wanted to run multiple instances of the same program.
if you find yourself needing to run multiple instances of a program, create a second or more batch files like the first but altering the process names such as EDIT1 to EDIT2.
i could of probably made this clearer, but i do not have a editor on staff.
as of today, if you are wanting to do something of this sort in pre windows xp, i only know of two options.
one is to write a tsr program using powerbasic for dos and have the tsr write to a file the screen when either a certain key is pressed or when there has been no activity from the key board after so much time has lapsed.
second is to have a windows console or gui program start a second console program and monitor the second console's screen buffer and what a pain it will be if the console program you are monitoring uses emulators, tsrs, and god only knows what else to make the second console program run correctly. if you are using this method, you just might want to consider writing the captured screen buffer to a file and have third program making use of the captured screen data by reading the console screens buffer data that was saved inside the file.
a third way is to use the clipboard which works great for some things, but i do not know of any way of automate it, might as well do option 1 or 2 above.
ps, i am using windows 2000 pro, i wish attachconsole would have been implemented into my operating system, so i have the pain.
Chris Holbrook wrote a good example on how to read a console programs console screen buffer.
title:screen scrape a DOS application in the source code section
http://www.powerbasic.com/support/pb...ad.php?t=37868
the code does not work in windows 2000 pro or below because the program uses the attachconsole function and that function is only support in windows xp and up versions. do a search on attachconsole and get some details on operating systems supported.
so far i have not found a way to do what the program above code from Chris does in windows 2000 pro.
there are some workarounds but still have not found an alternative to his type of program where it can read, as far as i know, most all console programs output. it appears there is a way of locking the console's screen buffer of a console program to keep another program from reading the buffer, but that is another story.
in my efforts to read a consoles screen buffer and put that to good use for my needs, i also knew that i was going to have concerns in trying to have a program read a specific console programs screen. you surely do not want two console programs running with the same caption or program title inside the process ids. how easily could it make your program find which console screen buffer to read if there were more than one program running with the same ids.
the reason for this post is to report that maybe a combination of two programs can be used get the desired effects and have easily resolved problems of more that one instance of a console program running and trying to acquire the console screen buffer.
i am doing my best to make this short so stick with me
many programs written do not have embedded code to recognize that another instance of the same program is running, and also may console programs run very well behaved when having more than one instance of the program running and perform well behaved even while using a the same database.
half of the incentive behind a program i wrote call ISITRNIT was for the reason of having a second program monitor the console screen buffer of another program and insuring that the program monitoring the program knows which programs console screen buffer to monitor.
ISITRNIT.EXE and CONSNAME.EXE can be gotten here.
by using ISITRNIT, the program should not let you run multiple instances of the same batch job from a certain point after the program ISITRNIT is used in the batch job, and you do have to place statements in the batch file to interpret the ERRLEVEL returned to either abort the batch job or let the batch job continue to execute other statements.
when the batch job continues to execute(does not abort) after the IRITRNIT program, then the batch file will hopefully have the process id name as what was named from the IRITRNIT program. if any other statements have an effect of renaming the process id name, then maybe by using the CONSNAME program can reset the process id name back to what name you wanted in the beginning of the batch job.
using IRITRNIT and using CONSNAME to reinforce the process id name can hopefully limit the chance of second instance of the program starting thereby allowing a different program written to monitor just that one console program's console screen buffer.
sorry, it is only wordy because i am having a hard time with describing the events.
so as i said before elsewhere, i like using batch files to start programs and using these two programs, ISITRNIT and CONSNAME, you can do something like this
a simple batch file listing
Code:
c: md \temp cd \temp ISITRNIT EDIT1 IF ERRLEVEL = 1 GOTO ABORT rem consname is only to reinforce the processes name and might not be needed CONSNAME EDIT1 cd \directoryofprogram START c:\directory\monitorprgram EDIT1 EDIT ME.TXT GOTO STOP :ABORT :STOP EXIT
without being said, it is up to you to create the program "monitorprogram", using Chris's code as a starter.
there will be some problems where programs name their own captions/program id names and you can use the program ISITRNIT by itself to list program id names from a command prompt window.
hopefully the console program you are going to use does not rename the window's title caption making it easier for you to accomplish your goal of reading a console program's console screen buffer. it could be the end of the ropes as one might say if that would happen if you wanted to run multiple instances of the same program.
if you find yourself needing to run multiple instances of a program, create a second or more batch files like the first but altering the process names such as EDIT1 to EDIT2.
i could of probably made this clearer, but i do not have a editor on staff.
as of today, if you are wanting to do something of this sort in pre windows xp, i only know of two options.
one is to write a tsr program using powerbasic for dos and have the tsr write to a file the screen when either a certain key is pressed or when there has been no activity from the key board after so much time has lapsed.
second is to have a windows console or gui program start a second console program and monitor the second console's screen buffer and what a pain it will be if the console program you are monitoring uses emulators, tsrs, and god only knows what else to make the second console program run correctly. if you are using this method, you just might want to consider writing the captured screen buffer to a file and have third program making use of the captured screen data by reading the console screens buffer data that was saved inside the file.
a third way is to use the clipboard which works great for some things, but i do not know of any way of automate it, might as well do option 1 or 2 above.
ps, i am using windows 2000 pro, i wish attachconsole would have been implemented into my operating system, so i have the pain.
Comment