[quote=kev peel;291082]i don't think this is possible with [i]existing</i> consoles.
Sure you can, screen readers for the blind do it all the time.
Take a look at nvda (opensource) and there's another one I can't remember at the moment.
They're not written in powerbasic, and they use msaa for the work, but they do read the screens of dos applications quite well.
I've not made any headway in porting the window bridge screen reader to powerbasic, but I'll go look at it's source, and see if I can find anything refering to how it grabs content from other programs, and perhaps post something here explaining the process, even if I can't code it directly. That may help.
Announcement
Collapse
No announcement yet.
question on reading console screen buffer by a different program
Collapse
X
-
>if you cannot help why bother with a response
As a Real Life demonstration of the importance of communications skills to applications developers.
You must be able to elicit from the user what it is he really wants.
I have seen far too many systems which were technical home runs but user strikeouts for lack of mutual undestanding.
Leave a comment:
-
-
I don't think this is possible with existing consoles, due to handle inheritance. Now if you wrote a "shell" program that used CreateProcess with both the main console and your "addon" utility (to inherit both handles), that might work. Failing that, try Google to see if anyone has the same requirement. This forum is but a bright star in the Win32 development universe
Leave a comment:
-
-
Michael,
if you want to chit chat, there is a cafe section.
if you cannot help why bother with a response.
Leave a comment:
-
-
Oh, you want the text on the screen of a target non-cooperating console or MS-DOS program saved to disk every four seconds.
I don't know how to do that, either.
Leave a comment:
-
-
MCM
i am after the text
the program above program was just a test
i had to start somewhereLast edited by Paul Purvis; 18 Jul 2008, 03:07 PM.
Leave a comment:
-
-
You want a screen shot of target console/MS-DOS program - excuse me, a non-cooperating console/MS-DOS program - saved to disk every four seconds?
Well, why didn't you just say so?
I don't know how to do that but at least we know your goal now.
MCM
Leave a comment:
-
-
MCM
thanks for responding
i would hope child process is the term that best fit.
i was able to write a test program about 12 months ago where i used the api functions allocconsole and createfile to spin off console program and capture the screen then sent the screen buffer to the a file every so much of a second and it appears everything when fine there.
is that what you where to referring to MCM.
the programs i wanted to take screen shots of are both DOS and CONSOLE programs.
i will put up my example program
this was a windowed program as i look back now
Code:'consoletofile 'pbwin 8.03 ' #COMPILE EXE '#Dim All #REGISTER NONE #INCLUDE "WIN32API.INC" FUNCTION GetConsoleWindow AS LONG DIM lpConsName1 AS ASCIIZ * 256, lpConsName2 AS ASCIIZ * 256, hWndConsole1 AS LONG, hWndConsole2 AS LONG DIM temp AS STRING GetConsoleTitle lpConsName1, SIZEOF(lpConsName1) DO IF LEN(lpConsName2) >= SIZEOF(lpConsName2) THEN EXIT FUNCTION lpConsName2 = lpConsName2 + " " SetConsoleTitle lpConsName2 DO hWndConsole1 = FindWindow(BYVAL %NULL, lpConsName2) IF hWndConsole1 THEN EXIT DO ELSE ApiSleep 40 LOOP IF hWndConsole1 = hWndConsole2 THEN EXIT DO hWndConsole2 = hWndConsole1 LOOP FUNCTION = hWndConsole1 SetConsoleTitle lpConsName1 END FUNCTION FUNCTION PBMAIN DIM Buf AS STRING, i AS LONG, j AS LONG, sBuf AS STRING DIM hFile AS LONG commandline$=TRIM$(COMMAND$) TEMP&=INSTR(commandline$," ") IF TEMP&=0& THEN MSGBOX "a bad command line was given, see examples below"+_ $CRLF+_ "consoletofile.exe <space> drive:directory\outputfile directory without any spaces <space> consoleprogram"+_ $CRLF+_ "consoletofile c:\temp\consoleoutput.txt program.exe"+_ $CRLF+_ "the drive and directory of the consoleoutput.txt file must already exist before running this program",_ %MB_TASKMODAL OR %MB_OK,"consoletofile.exe":_ EXIT FUNCTION END IF REM test for bad characters in the commandline filetestchar$="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789_.:\-@ " FOR CHECK&=1& TO LEN(commandline$) IF INSTR(filetestchar$,UCASE$(MID$(commandline$,CHECK&,1&)))=0 THEN MSGBOX "there seems to be an unaccepted character on the command line check for bad characters"+_ $CRLF+_ "only use the following characters "+filetestchar$+_ $CRLF+_ "the command tail given is listed below, found a bad character at position"+STR$(check&)+_ $CRLF+_ commandline$,_ %MB_TASKMODAL OR %MB_OK,"consoletofile.exe":_ EXIT FUNCTION END IF NEXT CHECK& outputtofile&=0& SCREENTOFILE$="" cmdline$ = "" SCREENTOFILE$=TRIM$(MID$(commandline$,1,TEMP&)) cmdline$=RIGHT$(commandline$,LEN(commandline$)-TEMP&) cmdline$=TRIM$(cmdline$) REM test to see if output file exist, and if it does exist no console output will be saved ofile%=FREEFILE ERRCLEAR OPEN SCREENTOFILE$ FOR INPUT AS #ofile% IF ERR=53 THEN outputtofile&=0& END IF IF ERR=76 THEN outputtofile&=1& MSGBOX "There is no directory for "+screentofile$+", therefore no console output will be saved"+_ $CRLF+_ "press anykey to continue",_ %MB_TASKMODAL OR %MB_OK,"consoletofile.exe" END IF IF ERR=0 THEN CLOSE #ofile% outputtofile&=1& MSGBOX "The file "+screentofile$+" already exist, therefore no console output will be saved to this file",_ %MB_TASKMODAL OR %MB_OK,"consoletofile.exe" END IF ERRCLEAR IF outputtofile&=0& THEN ofile%=FREEFILE OPEN SCREENTOFILE$ FOR OUTPUT LOCK READ WRITE AS #ofile% IF ERR=76 THEN outputtofile&=1& MSGBOX "testthere is no directory for "+screentofile$+", therefore no console output will be saved",_ %MB_TASKMODAL OR %MB_OK,"consoletofile.exe":_ END IF IF ERR<>0 THEN outputtofile&=1& MSGBOX "There is somekind of error using the file "+screentofile$+", therefore no console output will be saved",_ %MB_TASKMODAL OR %MB_OK,"consoletofile.exe" END IF IF ERR=0 THEN WRITE #ofile%,SPACE$(4000) CLOSE #ofile% END IF END IF ERRCLEAR AllocConsole pid???=SHELL (cmdline$,1) SLEEP 500 i = GetConsoleWindow READSCREENSTART: hFile = CreateFile("CONOUT$", %GENERIC_READ OR %GENERIC_WRITE, _ %FILE_SHARE_READ OR %FILE_SHARE_WRITE, BYVAL 0&, %OPEN_ALWAYS, _ %FILE_ATTRIBUTE_NORMAL, BYVAL 0&) IF hFile = %INVALID_HANDLE_VALUE THEN i = GetConsoleWindow freeconsole KILL SCREENTOFILE$ SendMessage i, %WM_SYSCOMMAND, %SC_CLOSE, 0 KILL SCREENTOFILE$ EXIT FUNCTION END IF DIM sb AS CONSOLE_SCREEN_BUFFER_INFO GetConsoleScreenBufferInfo hFile, sb BUF="" SBUF="" Buf = SPACE$(sb.dwsize.x * sb.dwsize.y) ReadConsoleOutputCharacter hFile, BYVAL STRPTR(Buf), LEN(Buf), BYVAL MAKDWD(0, 0), i CloseHandle hFile OemToCharBuff BYVAL STRPTR(Buf), BYVAL STRPTR(Buf), LEN(Buf) FOR i = 0 TO sb.dwsize.y - 1 sBuf = SBuf + MID$(Buf, i * sb.dwsize.x + 1, sb.dwsize.x) + $CRLF NEXT temp$=TRIM$(sbuf) REPLACE $CR WITH " " IN TEMP$ REPLACE $LF WITH " " IN TEMP$ temp$=TRIM$(temp$) IF LEN (temp$)=0 THEN i = GetConsoleWindow freeconsole SendMessage i, %WM_SYSCOMMAND, %SC_CLOSE, 0 EXIT FUNCTION END IF REM IF outputtofile&=1& then sleep 4000:goto readscreenstart ofile%=FREEFILE producefile: ERRCLEAR OPEN SCREENTOFILE$ FOR OUTPUT LOCK READ WRITE AS #ofile% IF ERR THEN SLEEP 1250:GOTO producefile ERRCLEAR WRITE #ofile%,sb.dwsize.x,sb.dwsize.y WRITE #ofile%,temp$ CLOSE #ofile% ERRCLEAR SLEEP 1250 GOTO READSCREENSTART END FUNCTION
Leave a comment:
-
-
i was in the hopes i could get want i wanted ....
... without having the console program run as a child to another process....
But what was it you wanted? "save screen buffer address to disk" is a "how" not a "what."
Leave a comment:
-
-
thanks Eric
i was in the hopes i could get want i wanted without having the console program run as a child to another process, because the console program is being supported by a third party and it runs our large database which i am not willing to make much changes to the environment under which it runs.
when problems come up, i do not want the third party to not be pointing fingers to others.
it is a shame that people do that when they know conditions exist where their programs have problems, but i cannot afford for the third party to point fingers.
Leave a comment:
-
-
Recording a memory location (address) in one process and trying to use it in another process is a non-starter, as all addresses are private to a process.
What is it you want from this program over which you have no control? The contents of the screen at some point in time?
From the doc it appears you can do lots of stuff by obtaining a handle to the target process' screen buffer, but I don't know how to do that.
(Can you even get a handle to another process' STDIN or STDOUT? I know you can pass a handle to another process and that target process can duplicate it for its own use, but I don't know how you'd get a handle from an unsuspecting process).
MCM
Leave a comment:
-
-
this question could of gone inside a previous thread i started but i wanted high attraction to question.
the second program does not have to interact with the console program but if it had that would be great.
i have no control over the console program and prefer to run the console program.
i was thinking of having a program run and record the console screen buffer location from a batch file just prior to running this third party console program.
my windows program could then read the file to get the console screen buffer, then read the location from memory.Last edited by Paul Purvis; 18 Jul 2008, 05:32 AM.
Leave a comment:
-
-
Paul --
It sounds like my company's DOSBox Tools* product can do exactly what you are describing. There's even a free version that you can download.
-- Eric Pearson, Perfect Sync, Inc.
*No relation to DOSBox by SourceForge.
Leave a comment:
-
-
Using PB/DOS? Just BSAVE the screen in one program and BLOAD it in the other.
Or do you mean have one Windows program interact with another Windows program in real time via something like a console interface? If so this question should probably be in one of the other forums, but there is no user-accessible "move thread" function. But that's very doable, but you wouldn't do it that way.... at least I wouldn't.
(Disk IS memory!)
[EDIT]
Woo, for some reason I thought this was the PB/DOS forum. Never mind the PB/DOS comments.
[/EDIT]
MCMLast edited by Michael Mattias; 18 Jul 2008, 05:22 AM. Reason: Had second cup of coffee and realized I had the forum wrong
Leave a comment:
-
-
question on reading console screen buffer by a different program
before i do a lot of work, maybe some of you know the answer.
can i store the location in memory of the console screen buffer in a file and a different program start by other means, say in a batch file using the command "start filename.exe" or even start by other means not from inside the console and have that other program read the memory location of the console screen buffer stored as data in a file, then in the other program retreive the console screen's buffer.
i am using windows 2000 and the attachconsole api is not in that version,
so i am having to do something else.
thanks in advanceTags: None
-
Leave a comment: