News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

qikpad Plus - a simple GUI for the DOS prompt

Started by jj2007, December 26, 2012, 10:09:27 AM

Previous topic - Next topic

jj2007

With a few edits, \Masm32\examples\exampl01\qikpad\qikpad.asm can be transformed into a GUI for the DOS prompt, with the ability to copy & paste directly, and to save sessions:

include \masm32\MasmBasic\MasmBasic.inc        ; line 12 - download here
;      .386
;      .model flat, stdcall  ; 32 bit memory model
;      option casemap :none  ; case sensitive

...
        Launch "cmd.exe", SW_MINIMIZE, cb:hEdit                ; line 285: start the commandline interpreter, send output to edit control
...
        ; -------------- lines 609-615: send strings to cmd.exe --------------------
      .elseif wParam == VK_RETURN
        void Rinstr(Win$(hEdit), Chr$(62))        ; find the prompt
        lea ecx, [eax+1]                ; set ecx on start of string to send
        .Repeat
                inc eax
        .Until byte ptr [eax]<=13        ; find end of string
        WritePipe Left$(ecx, eax-ecx)

That's all - full source & exe attached.

Vortex

Hi Jochen,

Very nice work :t Your tool can be used as a console replacement. Kindly, could you add an option to modify the console font?

dedndave

i seem to recall a nice little editor written long ago
let me see - who wrote that - oh ! - it was Erol   :shock:

Vortex

Hi Dave,

My apologies, maybe I am wrong but I didn't code an editor. Maybe, that was the autotype example.

dedndave


frktons

There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama

jj2007

Quote from: Vortex on December 27, 2012, 05:56:52 AM
Hi Jochen,

Very nice work :t Your tool can be used as a console replacement. Kindly, could you add an option to modify the console font?

Hi Erol,
For the QikPad demo this would be an overkill, but I can offer a more advanced version that does have this option - see attachment, in the menu. Attention, work in progress - the usual disclaimers apply.

P.S.:
@Andy: This one has a history of 99 lines max., and you can store it to disk with Ctrl H; note that some commands need start whatever.exe
@Frank: Thanks :biggrin:

dedndave

now, if we could just figure out how to emulate for 16-bit programs   :lol:
we could be rid of the console altogether
i have installed "PowerShell", but i haven't tested much code under it, yet

nice, Jochen   :t

jj2007

I have run into a problem:

The CmdGUI.exe posted above launches cmd.exe and then communicates with it through an anonymous pipe. That works like a charm, except that some commands behave strangely:

- all DOS commands seem to work fine (cd.., dir, ...)
- test.txt <enter> launches notepad
- notepad.exe <enter> shows strange behaviour:
  1. it is launched, i.e. you can see it in task manager
  2. but not visible
  3. until you send one more command, e.g. echo ciao <enter>

Any idea what is the logic of that? Fumbling with CreateProcess DETACHED_PROCESS flag does not solve the problem...

dedndave

weird   :P
maybe the command shell is using ShellExecute instead of CreateProcess ???

jj2007

#10
Weird indeed. The new process, e.g. notepad.exe is already in the process list and uses memory, has page faults etc, but has not started execution. I tested that with a
.code
start:
  <print something to a file>

Olly can't attach itself to the process, it tries but then hangs.

Same pattern for all windows GUI apps but apparently no problem for console apps. And services.msc or similar works directly.

Now perhaps this gives a clue: start notepad.exe works.
I am pretty sure it's something very simple ::)

P.S.: No such problem in Win7-64 - everything works smoothly there...

Tedd

My first guess would be that it's created as a child of the (hidden) cmd window, and inherets its handles and attributes as a result. For console processes, this is what you want - so the text is directed through the console and into your pipe.
Try playing with the values in STARTUPINFO.
Potato2

jj2007

Thanks, Tedd. I have been playing a while, no success in XP, but it just works fine on Win7-64...
AutoIt seems to have a similar problem:
QuoteSo, at the bottom of things, there's some disparity in the way that STDIN is handled for @COMSPEC /k depending whether it's spawned by the shell (a-la double-clicking a BAT file) or whether it's spawned from AutoIt

What is most annoying is that sending a second CrLf (or any other command, e.g. blabla) is sufficient to make the window show. Or type echo and hit Enter...

Vortex

Hi Jochen,

Thanks for your work. Much appreciated. A last feature request : the option to select the font and background color.

dedndave

maybe it's not the command execution, itself
maybe there are flags to play with when the pipe is created

hard to say, as it is somewhat buried in the masmbasic macros
i don't know if you use CreateNamedPipe or if you redirect standard handles