Page 1 of 2

Alternate Console

Posted: Mon Nov 03, 2014 8:43 pm
by JHPJHP

Re: Alternate Console

Posted: Mon Nov 03, 2014 11:09 pm
by ostapas
Many thanks for the recent "parcel out" of your codes, this really brings some fresh air to the forum!

Re: Alternate Console

Posted: Tue Nov 04, 2014 10:01 am
by JHPJHP
Hi ostapas,

You're most welcome. It was cathartic to "clean out my script closet", and hopefully provide something useful in the process.

Cheers!

Re: Alternate Console

Posted: Fri Nov 07, 2014 10:56 am
by Kwai chang caine
Splendid !!! Works very well...
Impressive the man work and panther :shock:
Thanks for sharing 8)

Re: Alternate Console

Posted: Sat Oct 03, 2015 9:22 am
by JHPJHP
Hi Kwai chang caine,

Thank you for your comments.

--------------------------------------------------

Updated to support Windows 10, including various bug fixes.

If the animations show in full-screen:
- delete the Registry key: HKEY_CURRENT_USER\Console
-- the Console key will be recreated when changes are made to a console's properties
- set cmd.exe (Command Console) to legacy mode from properties
-- don't set this option from the console created by the program
-- this option may not be available in earlier versions of Windows

Re: Alternate Console

Posted: Sun Feb 05, 2017 12:08 pm
by JHPJHP
Updated:
- added 1 example
-- alt_animation_gif.pb
- added 5 images
-- countdown.gif, fishing.gif, flipping.gif, running.gif, troll.gif

Previously only Sprite sheets were used to generate Console animations, but thanks to the PureBasic team adding GIF support, animated GIF's can also be used.

If your interest is only Console animations, download the Standalone version of Console Animation from the first post, I'm not sure the Alternate Console download has a use outside of curiosity; this was one of the first things I wrote while learning PureBasic, and maybe can assist someone travelling a similar road.

Re: Alternate Console

Posted: Sat Jun 17, 2017 5:24 pm
by Kwai chang caine
Hello JHPJHP :D

I use your splendid alternate console since several month ago 8) , and i don't know why, only sometime not always, i have an IMA at this line

Code: Select all

Dim lpBuffer.CHAR_INFO(BufferSize, nRight - 1)
in the procedure

Code: Select all

ReadCmdConsole(nLeft.i = 0, nTop.i = 0, nRight.i = 0, nBottom.i = 0)
Then i stop the code, and run another time and all is good after :shock:

I have noticed the variable "BufferSize" is empty, have you an idea what is the reason why ?

Re: Alternate Console

Posted: Sat Jun 17, 2017 10:18 pm
by JHPJHP
Hi Kwai chang caine,

I can see a couple problems...

1. The version you are using is out of date: Download links in the first post have been updated.
2. The Function GetConsoleScreenBufferInfo can fail, but I wasn't trapping for it; this has been updated.
-- you may want to include a notification if the call fails

Re: Alternate Console

Posted: Sat Jun 17, 2017 11:09 pm
by Kwai chang caine
Thanks a lot for your answer, i try your tips
Have a good night

Re: Alternate Console

Posted: Wed Nov 28, 2018 6:14 pm
by jassing
Some good stuff in there.
I spotted a couple of (minor) errors.
  • in cmdRunBatch(), (OpenFileRequester()) "StandardFile$" is not defined as local or global variable... shouldn't it be "FileName"?
  • * In cmdReadConsole(), there is a variable that is added to others. "Increment" but this is not defined, so it has no effect.
  • I also found that altPrint() doesn't work if the app is compiled as a console app.
this seems to fix (or hack into submission) the last item.

Code: Select all

Procedure altOpenConsole(State = 1, Title.s = "Alternative Console", xColumn = 80, yRow = 300)
  Protected GetConsoleWindow.protoGetConsoleWindow
  Result = #False
  
  CompilerIf #PB_Compiler_ExecutableFormat = #PB_Compiler_Console
    If  #True  ; hackish, I know.
  CompilerElse 
    If AllocConsole_() 
  CompilerEndIf 

Added a small macro to be the companion to altOpenConsole()

Code: Select all

Macro AltCloseConsole() : FreeConsole_() : EndMacro
Any idea how to tell which window/console has input/focus?

great work!
-j

Re: Alternate Console

Posted: Thu Nov 29, 2018 6:04 pm
by JHPJHP
Hi jassing,

Thank you for your generous contribution, and for your previous post outlining some potential problems with Alternate Console.

Alternate Console was probably my first attempt at creating something "useful" with PureBasic; looking over the code...
- in cmdRunBatch(), (OpenFileRequester()) "StandardFile$" is not defined as local or global variable
-- fixed, package updated
- in cmdReadConsole(), there is a variable that is added to others. "Increment" but this is not defined
-- Increment is used for scrolling/copying the console contents to the debug window/variable; updated the example cmd_show_console.pb to better demonstrate its use
- I also found that altPrint() doesn't work if the app is compiled as a console app
-- I compiled/tested some of the examples (Windows 10) without a problem, please be more specific; small change made to the Procedures altPrint, altPrintN
- Added a small macro to be the companion to altOpenConsole()
-- Shouldn't be needed, see the Procedure/Callback HandlerRoutine, it will free the console on a close event
- Any idea how to tell which window/console has input/focus?
-- Try using the API GetActiveWindow and GetFocus, matched against data derived from an enumeration of opened Window handles; let me know if you need any help

Re: Alternate Console

Posted: Fri Nov 30, 2018 6:24 am
by jassing
JHPJHP wrote: - Added a small macro to be the companion to altOpenConsole()
-- Shouldn't be needed, see the Procedure/Callback HandlerRoutine, it will free the console on a close event
... unless you want to close the console before program end ...


as for the compiled as a console issue (and maybe I'm missing something...)

Code: Select all

IncludeFile "Alt_Console.pbi"
CompilerIf #PB_Compiler_ExecutableFormat = #PB_Compiler_Console
  If altOpenConsole(1,"Test print",100,500)
    altPrintN("This is a test")
    altInput()  
  Else 
    MessageRequester("Ooops","Console Open Failed")
  EndIf
CompilerElse : CompilerError("Compile as a console")
CompilerEndIf
For me, when run as a windows program, it works as expected. but when run as a console, altOpenConsole() fails

Re: Alternate Console

Posted: Fri Nov 30, 2018 4:41 pm
by JHPJHP
Hi jassing,
jassing wrote:as for the compiled as a console issue (and maybe I'm missing something...)
You're correct, I overlooked your code snippet about the Compiler Format, and only focused on compiling an executable; allocating a console in Console Mode is redundant.
- fixed, package updated
jassing wrote:... unless you want to close the console before program end ...
Can you provide an example where the CloseConsole Macro is needed; the existing Event Handler should be sufficient.

Cheers.

Re: Alternate Console

Posted: Fri Oct 04, 2019 9:53 pm
by JHPJHP
Updated:
- added a clear console registry option
- applied a couple minor improvements

Clear Console: Registry
This option only applies to the animated examples executed in Windows 10+.

Re: Alternate Console

Posted: Thu Sep 30, 2021 12:28 pm
by Derren
Hey,

I just wanted to test your code. Sadly you offer it only on your website for a payment. :(