Page 1 of 1 1
Topic Options
#157452 - 2006-02-19 04:27 PM scrndump.exe needed!
disti Offline
Just in Town

Registered: 2006-02-19
Posts: 2
Hi everyone!

I read a few posts about cursor positioning and I found out that the scrndump utility is exactly what I'm looking for.
Unfortunately, I can't find it anywhere: every link I found on this forum and through google is broken!

Is there anyone that has this tool on his hard disk and that can send it to me or can provide a valid link to it?

Thank you!

Roberto Reale
disti(at)robertoreale.com

Top
#157453 - 2006-02-20 03:44 AM Re: scrndump.exe needed!
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
what does this app do? Are you trying to capture the screen via a script?

cj

Top
#157454 - 2006-02-20 06:07 AM Re: scrndump.exe needed!
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Is scrndump.bas what you mean??
_________________________
Co


Top
#157455 - 2006-02-20 08:25 AM Re: scrndump.exe needed!
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
No, it's an EXE and I think Richard "may" have a copy of it.

I think it does text screen scraping but not positive.

Top
#157456 - 2006-02-20 10:27 AM Re: scrndump.exe needed!
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Yup, it's an exe I wrote a while back to help someone on the board that wanted to capture the current state of the console.

It also has a couple of additional useful features that Disti is referring to. It can set the exit code to reflect the console size or the current cursor position - useful if you want to integrate console commands into KiXtart scripts and you cannot tell what size the user has set the console to, or where the command left the cursor.

I'll drop a copy of the exe and a demo script directly to Disti's email.

Top
#157457 - 2006-02-20 10:44 AM Re: scrndump.exe needed!
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Source code if anyone else is interested in compiling from scratch or bug fixing:



#include <windows.h>
#include <stdio.h>

/* vim: set sw=4 ts=4: */

char *sMyName;

void usage(void){
fprintf(stderr,"Usage: %s [options] [filename]\n",sMyName);
fprintf(stderr," -buffer Exit value is buffer size (width*1000)+height\n");
fprintf(stderr," -cursor Exit value is cursor position, (X*1000)+Y\n");
fprintf(stderr," -size Exit value is console size (width*1000)+height\n");
fprintf(stderr," Default action is to write settings and console characters to file.\n");
fprintf(stderr," Default filename is 'scrndump.kix'\n");
return;
}

int main(int argc, char **argv){

HANDLE hStdout;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
CHAR_INFO *chiBuffer;
CHAR_INFO *chiElement;
COORD coordBufferSize;
COORD coordBufferStart;
FILE *fhScript=NULL;
int X,Y;
int iMode=0;
char *sFilename=NULL;

sMyName=argv[0];
/* Open output file, binary mode */
while(--argc){
++argv;
if(strcmp(*argv,"-cursor")==0)
iMode='c';
else if(strcmp(*argv,"-buffer")==0)
iMode='b';
else if(strcmp(*argv,"-size")==0)
iMode='s';
else if(*argv[0]=='-') {
fprintf(stderr,"Illegal option '%s'\n",*argv);
usage();
return -1;
} else {
if(sFilename){
fprintf(stderr,"Invalid option '%s', file already opened as '%s'\n",argv[0],sFilename);
usage();
return -1;
} else {
sFilename=argv[0];
}
}
}

/* Get inherited console handle */
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

/* Get console attributes */
if (! GetConsoleScreenBufferInfo(hStdout, &csbiInfo)){
fprintf(stderr,"GetConsoleScreenBufferInfo failed.\n");
return 1;
}

/* Populate "screen size" array */
coordBufferSize.X=csbiInfo.srWindow.Right-csbiInfo.srWindow.Left+1;
coordBufferSize.Y=csbiInfo.srWindow.Bottom-csbiInfo.srWindow.Top+1;
/* Copy info to top left of our local buffer */
coordBufferStart.X=0;
coordBufferStart.Y=0;

/* Allocate buffer for console window information */
if((chiBuffer=(CHAR_INFO *)malloc(coordBufferSize.X*coordBufferSize.Y*sizeof(CHAR_INFO)))==NULL){
fprintf(stderr,"Cannot allocate memory for screen buffer. So Sorry.\n");
return 1;
}

/* Copy window area of console buffer into local array */
if(! ReadConsoleOutput(
hStdout,
chiBuffer,
coordBufferSize,
coordBufferStart,
&csbiInfo.srWindow)){
fprintf(stderr,"Cannot read screen buffer. So Sorry.\n");
return 1;
}
/* Quick modes */
if(iMode=='c') return (csbiInfo.dwCursorPosition.X*1000+csbiInfo.dwCursorPosition.Y);
if(iMode=='s') return (coordBufferSize.X*1000+coordBufferSize.Y);
if(iMode=='b') return (csbiInfo.dwSize.X*1000+csbiInfo.dwSize.Y);

/* Dump console attributes */
if(sFilename==NULL) sFilename=".\\scrndump.kix";
if((fhScript=fopen(sFilename,"wb"))==NULL){
fprintf(stderr,"Cannot open dump file '%s' for writing\n",sFilename);
return 1;
}
fprintf(fhScript,"; Screen dump for KiXtart.\r\n; Richard Howarth rhowarth@sgb.co.uk \r\n");
fprintf(fhScript,"$CONSOLE_Height=%d\r\n",coordBufferSize.Y);
fprintf(fhScript,"$CONSOLE_Width=%d\r\n",coordBufferSize.X);
fprintf(fhScript,"\r\n");
fprintf(fhScript,"$CONSOLE_BUFFER_Height=%d\r\n",csbiInfo.dwSize.Y);
fprintf(fhScript,"$CONSOLE_BUFFER_Width=%d\r\n",csbiInfo.dwSize.X);
fprintf(fhScript,"\r\n");
fprintf(fhScript,"$CONSOLE_CursorY=%d\r\n",csbiInfo.dwCursorPosition.Y);
fprintf(fhScript,"$CONSOLE_CursorX=%d\r\n",csbiInfo.dwCursorPosition.X);
fprintf(fhScript,"\r\n");
fprintf(fhScript,"ReDim $CONSOLE_Chars[$CONSOLE_Height]\r\n");
fprintf(fhScript,"\r\n");

chiElement=chiBuffer;
for(Y=0;Y<coordBufferSize.Y;Y++){
fprintf(fhScript,"$CONSOLE_Chars[%d]='",Y);
for(X=0;X<coordBufferSize.X;X++){
if((chiElement->Char.AsciiChar)=='\''){
fprintf(fhScript,"'+\"'\"+'");
} else {
fputc(chiElement->Char.AsciiChar,fhScript);
}
++chiElement;
}
fprintf(fhScript,"'\r\n");
}

close(fhScript);

return 0;
}

Top
#157458 - 2006-02-20 10:33 PM Re: scrndump.exe needed!
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well if you can't host the file anymore Richard then I can host it on KiXhelp if you like.
Top
#157459 - 2006-02-21 09:43 AM Re: scrndump.exe needed!
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Cheers Doc. If I get any more requests then I'll accept your kind offer.
Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.149 seconds in which 0.121 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org