Consio is a small console library for Windows. I created it, so I can make small textbased menus and catch single keystrokes and not always use Tk for creating user interfaces. It's also handy for asking passwords from user and not echo them back to the screen.
The library is written in C and has been compiled with Cygwin tools under Cygwin environment using MinGW libraries and headers (so there are no dependencies to the Cygwin).
The source code is available at GitHub .
Binary files can be downloaded from here:
The whole package is released under the BSD license.
Here's a screenshot:
The library is pretty skimpy (well, it's version 0.3 at the moment, so don't expect too much), but it already implements the following commands:
mjk 2005-10-17: At the moment, this library has been tested only under Windows XP. All feedback is welcome and I would appreciate it greatly if people would tell me, how the library works under different flavors of Windows. The feedback can be appended to this page or sent directly to me (e-mail address is included in the package).
jmn 2005-10-18 Nice work - thanks for sharing.
It works fine on my old Windows NT & 2000 server boxes.
A consequence of course of using ReadConsole instead of lower level Console API functions such as ReadConsoleInput; is that Consio as it stands doesn't catch certain keys such as arrows, delete, end etc.. Perhaps 'press any key' in the demo should be qualified a little - otherwise the old joke about lusers hunting for the key marked 'any' just isn't as funny ;)
LES: this is very nice, and seems to work in my Windows 98. I couldn't make getch and getche work, but I suspect I just did something wrong.
mjk 2005-10-20: jmn, the "any key" issue will be fixed in next version, so no stupid user will be lost in the quest for finding the "any key" :) LES, I'm afraid that there is a small possibility that (at least at this point) this library will not work flawlessly under Windows 9x. Microsoft documentation claims that all functions I'm using are supported under older operating systems, but I'm not sure, if I can trust that. But I'm going to study this issue further at some point.
mjk 2005-10-20: Well, there is now the version 0.2 available and it among other things has an extended version of the getch command called "getchex", which will capture any keypress from the console and return a key code.
mjk 2017-06-10: Almost 12 years has passed and here we are, with a new version :) For source code and compiled binaries, please see the description above. The main reason for this release is the new command: Consio::getch2, which allows capturing key combinations, for example Alt+F1 and also recognizes arrow keys etc. with modifiers (Alt+arrow up, etc.)
Here's a conversation about this page, from the TkChat channel, on 2006-03-14. willdye
<mAcZ> is there possible to write "raw" to console? <mAcZ> windows console supports command "prompt" which can allows ASCII <mAcZ> and i wanna try to use this tclguy ?? kbk mAcZ - What are you trying to do, in more general terms. <mAcZ> i wanna use ascii chars in windows console, to use color for text aku I would say that you want ANSI sequences, not ASCII kbk Windows console - the black thing from a command line application, or the Wish console? The answers are different for the two. <mAcZ> the black thing * kbk tries to remember what's to be done for the Windows console - suspects that the answer is "it's not easy." tclguy that requires C API stuff IIRC, not just terminal control codes like a unix tty kbk tclguy - ISTR there's a way to jigger a Command Prompt to take ANSI escape sequences, but don't remember what it is. (And I don't remember whether it takes C code that we don't have) kbk console I/O extension - https://wiki.tcl-lang.org/14850 <mAcZ> AH! <mAcZ> perfect, big thanks * kbk bows. :)
What a pitty that this package didn't get further... And unfortunally, there's no modern CTk available for win32.
APN TWAPI's console module provides (I believe) a superset of these commands. MHo Yes. But what's really neaded is a cross platform CTk, otherwise one had to reinvent the wheel... And TWAPI, consio and ::term are not crossplattform. It's simply not possible to develop cross-platform tcl apps with a tui interface.