Show output of the toolbar button command

English support forum

Moderators: Stefan2, white, Hacker

Post Reply
arko
Junior Member
Junior Member
Posts: 70
Joined: 2020-04-05, 06:41 UTC

Show output of the toolbar button command

Post by *arko »

Is there a more modern alternative to this?

Code: Select all

cmd.exe /k "binary.exe -flags"
I am in the process of creating a few toolbar buttons and somewhat annoyed by the lack of default tools in Windows to display console output except of using the snippet above. I have also tried improvising around the following:

Code: Select all

powershell.exe -NoExit -NoLogo -Command "binary.exe -flags"
...Which was neither overly successful nor visually appealing.

All I want is the small rectangle showing output from the command executed by the button.
Bonus points if it can copy text from it to the clipboard.

Is anyone familiar with the *NT API willing to hack something along these lines?
  • Accept minimally formatted (\r\n) text as an input
  • Get mouse pointer position
  • Draw appropriately sized window, display content
  • Copy to the clipboard by right click, close window by left click
That's all :)
User avatar
Stefan2
Power Member
Power Member
Posts: 3773
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Show output of the toolbar button command

Post by *Stefan2 »

Instead of executing the EXE, execute a batch or other script,
call there the EXE and f.ex. output to a temporary file and open it, f.ex., in Notepad2.




 
User avatar
Dalai
Power Member
Power Member
Posts: 8417
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Show output of the toolbar button command

Post by *Dalai »

An approach for a generic batch script for this purpose could look like this:

Code: Select all

@echo off
%*
echo.
pause
(or call %* instead of just %*). A button calling the script could look like this:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\ShowOutput.cmd
set
cmd.exe
Show command output


-1
Replace the "set" command in the parameter field with your "binary.exe -flags". If the CMD window is too small, you can use

Code: Select all

mode con lines=x cols=y
with x and y set to your liking. But beware that setting the window size this way kills the CMD window buffer size, i.e. scrolling will be impossible.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo - Download-Mirror
arko
Junior Member
Junior Member
Posts: 70
Joined: 2020-04-05, 06:41 UTC

Re: Show output of the toolbar button command

Post by *arko »

Dalai wrote: 2020-04-17, 18:49 UTC An approach for a generic batch script for this purpose could look like this:

Code: Select all

@echo off
%*
echo.
pause
Thank you, Dalai, this should work for now. Button example:

Code: Select all

TOTALCMD#BAR#DATA
%$APPDATA%\GHISLER\scripts\show_output.cmd
"C:\Program Files\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File %p%n
C:\Program Files\Windows Defender\MpCmdRun.exe
Scan with Defender

-1
Much better than nothing, but if someone is willing to hack the window option mentioned above - please reply :D
Stefan2 wrote: 2020-04-17, 18:09 UTC Instead of executing the EXE, execute a batch or other script,
Yep, see above.
User avatar
Dalai
Power Member
Power Member
Posts: 8417
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Show output of the toolbar button command

Post by *Dalai »

Well, the size of the CMD window can be set as usual: open CMD by typing "cmd.exe" and set its size in its properties (right-click on the title bar). When confirming the settings Windows may ask if these settings should apply to this window or to all windows (with the same name). Tell it to save it for all windows. The window (buffer) size can also be set in the registry, as is documented by Microsoft.

I set at least 55 lines and 120 columns for the window size and 900 lines and 120 columns for the window buffer, which is usually enough for every output encountered so far. The registry values for these size values are

Code: Select all

[HKEY_CURRENT_USER\Console]
"WindowSize"=dword:00370078
"ScreenBufferSize"=dword:03840078
And copying to clipboard is also easy: if QuickEdit is enabled in the CMD (see its properties), it will allow text selection with the left mouse button and copying to clipboard via right-click on the selection and via ENTER key.

Is there any more you need?

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo - Download-Mirror
arko
Junior Member
Junior Member
Posts: 70
Joined: 2020-04-05, 06:41 UTC

Re: Show output of the toolbar button command

Post by *arko »

Dalai wrote: 2020-04-18, 15:57 UTC Is there any more you need?
I have created a topic at Lazarus forum which explains the idea in greater detail: https://forum.lazarus.freepascal.org/index.php/topic,49394.0.html

Brief visual explanation:

1. Image: https://i.imgur.com/yLbhasp.png
2. Image: https://i.imgur.com/rlSI1XF.png
Post Reply