Gotoxy - advanced color text output and cursor control - now with server!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#16 Post by misol101 » 14 Jul 2016 19:20

Cmdwiz stringfind got a "noCase" option.

The executable was re-compiled with gcc.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#17 Post by misol101 » 22 Jul 2016 12:13

Archive and repo updated.

New operation for cmdwiz: printf. This just mimics printf in C, so it's basically an "echo" with printf codes (\n \r \t \a \b \\ are supported). Also, it does not include " if you write printf "text", something I often find annoying with echo. Cons: Slow.

New operation for cmdwiz: setcursorpos. In case gotoxy is not available (the horror!)

New save mode for cmdwiz saveblock: txt. This saves the block as plain text, no control codes included. The file is saved with the .txt extension

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#18 Post by misol101 » 22 Jul 2016 12:31

By the way, somebody asked for a way to save output from a program that doesn't write to stdout or stderr (which calls straight to WritrConsoleOutput or similar)

With the new cmdwiz saveblock 'txt' option, this is possible.

Code: Select all

@echo off
set H=1000
cmdwiz setbuffersize k %H%
cls
%1 %2 %3 %4 %5 %6 %7 %8 %9
::cmdwiz getcursorpos y
::set H=%errorlevel%
cmdwiz getconsoledim w
set W=%errorlevel%
cmdwiz saveblock output 0 0 %W% %H% txt
set H=&set W=

Here the max height of the output text is 1000 lines, and it is fixed (which means you may get a lot of blank lines at the end of output.txt)
If the cursor moves while the text is writing, you can uncomment the commented lines and get the correct number of output lines.
If the cursor does not move, either manually change H to how many lines you want to save, or accept the extra blank lines.

To use, e.g. saveout.bat type saveout.bat

Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Gotoxy

#19 Post by Aacini » 22 Jul 2016 18:54

misol101 wrote:New operation for cmdwiz: printf. This just mimics printf in C, so it's basically an "echo" with printf codes (\n \r \t \a \b \\ are supported). Also, it does not include " if you write printf "text", something I often find annoying with echo. Cons: Slow.

New operation for cmdwiz: setcursorpos. In case gotoxy is not available (the horror!)

Does your program mimics printf formats (like "%8i") or is just an echo with control characters?

The way to write control characters via \n, \r, \t, etc, is not part of printf function, but a standard feature of C language that apply in all cases where a string can be written. In other words: \n, \r, \t, etc, are NOT "printf codes"!

If the new operation for cmdwiz do the same task than gotoxy.exe command, why you don't name it the same ("gotoxy" operation)?

Antonio

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#20 Post by misol101 » 22 Jul 2016 19:07

Aacini wrote:Does your program mimics printf formats (like "%8i") or is just an echo with control characters?

The way to write control characters via \n, \r, \t, etc, is not part of printf function, but a standard feature of C language that apply in all cases where a string can be written. In other words: \n, \r, \t, etc, are NOT "printf codes"!

You are correct, it was mis-worded. No it does not mimic printf formats. I guess it would be more correct to say it's a printout function that mimics how C handles writing of special characters. As such, I think it is still useful. I guess "print" would be a better name than "printf".

Aacini wrote:If the new operation for cmdwiz do the same task than gotoxy.exe command, why you don't name it the same ("gotoxy" operation)?

gotoxy.exe does many things related to writing text, the positioning of the cursor is just the most basic function. See the first post in this thread for an overview of what gotoxy can do.

Also, cmdwiz.exe already has a getcursorpos operation, so the name setcursorpos makes more sense.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#21 Post by misol101 » 04 Sep 2016 15:24

Archive and repo update. Cmdwiz (the gotoxy and cmdgfx companion) had a bunch of new operations added:

1. getwindowbounds to get the console window's x/y position or its width and height. Note that the border is also included in these values.

2. setwindowpos to set the position of the console window

3. getdisplaydim to get the resolution of the current display (useful to e.g center the window with setwindowpos)

4. getmousecursorpos returns the screen coordinates of the mouse pointer

5. setmousecursorpos to set the mouse pointer position. In addition, it is possible to specify that a click happens after the move, either a left click, a right click, a left button down, or left button up. The last two can be used to e.g. simulate dragging windows around. This makes cmdwiz useful as a simple mouse task automation tool.

6. insertbmp is used to paste a bmp file in the console window, either as-is or stretched-out either as a percentage or as width/height settings. Full credits to aGerman for this function, which is also noted in the source code.

7. setwindowtransparency is used to set the transparency of the console window between 0 and 100. Again, full credit to aGerman for the source code.

8. setfont was lifted from carlos BG tool, full credit to him for this functionality (also noted in the source code). I then extended this operation by adding support for saved fonts, so in addition to the 10 terminal bitmap fonts it is also possible to load any font added to the console which has been saved with the corresponding savefont operation. This also makes it possible to restore your original font after a change to another font.

9. quickedit operation changed name to setquickedit and a corresponding getquickedit operation was added


I included an example batch called windowfuncs.bat which shows most of these new operations in action. The code is as follows:

Code: Select all

@echo off
setlocal ENABLEDELAYEDEXPANSION

cls
cmdwiz savefont oldfont.fnt
cmdwiz setfont Consolas72.cmdfnt
cmdwiz showcursor 1 100
mode 30,8

cmdwiz getwindowbounds w&set PIXELW=!errorlevel!
cmdwiz getwindowbounds h&set PIXELH=!errorlevel!

cmdwiz getdisplaydim w&set SW=!errorlevel!
cmdwiz getdisplaydim h&set SH=!errorlevel!
set /a WPX=%SW%/2-%PIXELW%/2,WPY=%SH%/2-%PIXELH%/2-20
cmdwiz setwindowpos %WPX% %WPY%
set /a YPOS=%PIXELH%/2-20, BMPHEIGHT=1
cmdwiz setcursorpos 9 3
cmdwiz print "CONSOLAS 72"
cmdwiz delay 3000
cmdwiz showcursor 0

for /L %%a in (1,2,%PIXELH%) do cmdwiz insertbmp 123.bmp 0 !YPOS! %PIXELW% !BMPHEIGHT! & set /a YPOS-=2,BMPHEIGHT+=4

set /a MPX = %WPX% + %PIXELW%/2, MPY = %WPY% + 15
cmdwiz setmousecursorpos %MPX% %MPY%

for /L %%a in (0,1,100) do set /a MPX+=2&cmdwiz setmousecursorpos !MPX! %MPY% d
for /L %%a in (0,1,98) do set /a MPX-=2&cmdwiz setmousecursorpos !MPX! %MPY% d
cmdwiz setmousecursorpos !MPX! %MPY% u

cmdwiz setwindowpos 0 0
cmdwiz setfont oldfont.fnt
del /Q oldfont.fnt>nul
mode 80,50 & cmdwiz showcursor 1 & cls
endlocal

DQ2000
Posts: 38
Joined: 07 Aug 2019 17:26

Re: Gotoxy

#22 Post by DQ2000 » 07 Aug 2019 17:47

hello a question how do I save the gotoxy project? please

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#23 Post by misol101 » 09 Aug 2019 02:22

DQ2000 wrote:
07 Aug 2019 17:47
hello a question how do I save the gotoxy project? please
I’m sorry I do not understand your question. What is it that you want to save?

DQ2000
Posts: 38
Joined: 07 Aug 2019 17:26

Re: Gotoxy

#24 Post by DQ2000 » 14 Aug 2019 14:38

misol101 wrote:
09 Aug 2019 02:22
DQ2000 wrote:
07 Aug 2019 17:47
hello a question how do I save the gotoxy project? please
I’m sorry I do not understand your question. What is it that you want to save?

I want to save the project

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#25 Post by misol101 » 15 Aug 2019 08:18

DQ2000: Save the gotoxy project? Huh? I still don't understand. There is no "project", or I don't understand what you mean... As the first post says, gotoxy can be downloaded/saved here: http://www.mediafire.com/download/8xywd ... gotoxy.zip

If you are a programmer and would like to see/edit the C source code for gotoxy.exe (and cmdwiz.exe), you can clone the repo with git here: https://github.com/misol1/gotoxy

DQ2000
Posts: 38
Joined: 07 Aug 2019 17:26

Re: Gotoxy

#26 Post by DQ2000 » 15 Oct 2019 01:56

hello: D I wanted to say that there is an editor for gotoxy files I just want to know the most used

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#27 Post by misol101 » 15 Oct 2019 16:10

Ok, so I am now thinking you want to save gxy files, the file format used by gotoxy.exe (and cmdgfx.exe)

As far as I know there is only one editor for gxy files and that is the one I made myself :D It is called editor.bat and is included in the gotoxy/cmdwiz archive. Use left/right mouse button to "draw" characters, or use cursor keys and type characters. You will definitely want to press F10 for further help on how to use it! Let me know if you try it and cannot figure something out. The interface is primitive and the script has not been touched for years.

Why not? Mostly because as long as you can show what you would like to save in a cmd window, you can actually use any editor, then print it in the cmd window and save it as a gxy file with the cmdwiz operation saveblock.

For example, let's say you wanted to turn goomba.spr (spr is carlos bg file format) into a gxy file:

Code: Select all

cls & sprite 0 0 goomba.spr & cmdwiz saveblock goomba 0 0 16 17
This will create goomba.gxy, which can be shown with e.g. gotoxy 0 0 goomba.gxy (Granted it is a bit of a pain that you need to know the dimensions of the block you want to save (16x17 characters in this case)...)

There is more stuff involved if you need to save the file with transparency intact, here is one approach: first fill buffer with "!" characters(ascii 21 hex), then do as above, but set 21 as transparent character in saveblock operation:

Code: Select all

gotoxy 0 0 "\N21" & sprite 0 0 goomba.spr & cmdwiz saveblock goomba 0 0 16 17 e 21
Now we get goomba.gxy, but with transparency.


Ok, I hope that makes some sense at least...


Edit: also, gxy files are not binary so can be edited with any normal text editor. While you won’t be able to ”see” the output, small edits can still often be done this way

DQ2000
Posts: 38
Joined: 07 Aug 2019 17:26

Re: Gotoxy

#28 Post by DQ2000 » 17 Oct 2019 00:14

Hi. I have been able to create one yes. but has an error

DQ2000
Posts: 38
Joined: 07 Aug 2019 17:26

Re: Gotoxy

#29 Post by DQ2000 » 17 Oct 2019 00:19

and I congratulate you for a job very well done friend :)

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Gotoxy

#30 Post by misol101 » 22 Oct 2019 04:43

DQ2000 wrote:
17 Oct 2019 00:19
and I congratulate you for a job very well done friend :)
Thank you. If you do want help with the problem you said you have it needs to be a bit more specific than ”has an error”.

Post Reply