Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

CMDret - return output from console progs [DLL version]


  • Please log in to reply
175 replies to this topic
valenfor
  • Members
  • 21 posts
  • Last active: Jan 20 2012 05:14 AM
  • Joined: 26 Feb 2005
I know most others have already said, but just wanted to give the big

Wooo Hooo!

I got the DLL, got my tail.exe and mix em up in the same bowl and its LIKE BUTTER BABY!!!!

BCX looks cool too corrupt - thanks for introducing me to another programming platform as well.

V.

  • Guests
  • Last active:
  • Joined: --

my program should also run in the command line environment, which does not separate stderr and stdout - they get mixed

If you're running the program in the command line environment of Windows NT/2000/XP/2003, you can use the "2>" syntax to redirect error output and separate it from standard output, as in
Program parameters >StdOut.txt 2>StdErr.txt
Jacques.


If you want both stdout and stderr to go to a single file, you can use:
Program parameters > Stdout-err.log 2>&1


corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

I know most others have already said, but just wanted to give the big

Wooo Hooo!

I got the DLL, got my tail.exe and mix em up in the same bowl and its LIKE BUTTER BABY!!!!

BCX looks cool too corrupt - thanks for introducing me to another programming platform as well.

V.

Thanks & you're welcome :) .

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
BCX Source (version 3.1.2)

daonlyfreez
  • Members
  • 995 posts
  • Last active: Jan 23 2013 08:16 AM
  • Joined: 16 Mar 2005
Muy cool indeed! 8)

:D

Thank you! Working with AutoHotkey is getting better and better :)
Posted Image mirror 1mirror 2mirror 3ahk4.me • PM or Posted Image

zipzulu
  • Members
  • 3 posts
  • Last active: Jun 26 2005 09:07 AM
  • Joined: 14 May 2005
Hi all,

basically, I have to agree that corrupt’s cmdret is extremely helpful. However, I’ve some problems with this tool and wonder if someone can point me in the right direction.

I’m trying to compile a C/C++ project using a PERL script (see CompileCmd below) and redirect its output to a GUI edit window within a tab control. Both versions (one using CMDret.exe and one using the cmdret.dll) basically work, that is, the output shows up in the edit control but with

version 1 (CMDret.exe)
- close to the end of the compile process the output just stops, no compiler output files are created - seems to me that the process just dies at some stage (the PERL script runs ok in a DOS box)

version 2 (cmdret.dll)
- everything works ok with regard to the compile process but the output window is not refreshed at some point - just the grey output window without the edit or tab control can be seen. Once the compile process completed, I can click on the output window to re-display the controls as well as the compiler output.
- one additional question: Is it somehow possible to get the PID of the CMD process as in the CMDret.exe version?

Version 1 using CMDret.exe:
GuiControl, 2:Choose, OutputTab, 2 
SetTimer, SubOutputCompile, 250
RunWait, %RunCMD1% "p=" "%comspec% /c cd /d %vProjectFolder% && date/t &&  time /t && %CompileCmd% && date/t && time /t", , hide, CompilePID
SetTimer, RefOutputCompile, Off
Gosub, SubOutputCompile



Version 2 using cmdret.dll:
CMD = %comspec% /c cd /d %vProjectFolder% && %CompileCmd% && echo.
OutputWindow := WinExist("Output Window")
GuiControl, 2:Choose, OutputTab, 2 	
StrOut := DllCall("cmdret.dll\RunInControl", "str", CMD, "Uint", OutputWindow, "str", "Edit", "int", "2") 


Thanks

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
Hi zipzulu,

Thanks for the feedback :) .

If using CMDret.exe you could try using cmdstub.exe
RunWait, cmdstub.exe %RunCMD1% "p=" "%comspec% /c cd /d %vProjectFolder% && date/t &&  time /t && %CompileCmd% && date/t && time /t", , hide, CompilePID
Although I am planning to update CMDret.exe soon to fix a few issues, CMDret.dll is currently considered to be an updated version of CMDret.exe.

The refresh issue with the RunInControl function in CMDret.dll seems to happen because the thread in the script is put on hold until the function in the .dll returns. This seems to prevent the Window from refreshing until the function returns. You could maybe try calling the function in the .dll from a timed sub or by creating a small script that calls the function, then execute the script using the Run command (untested). Thanks for pointing this out. I'll try and post a few sample scripts using RunInControl a bit later.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

- one additional question: Is it somehow possible to get the PID of the CMD process as in the CMDret.exe version?

Out of curiosity, how would you like to use this info?

zipzulu
  • Members
  • 3 posts
  • Last active: Jun 26 2005 09:07 AM
  • Joined: 14 May 2005
corrupt,

first of all, thanks for the response. I haven't had the opportunity to test your suggestions but will try to do so sometime next week.

Out of curiosity, how would you like to use this info?


The compilation process takes quite some time and sometimes I realize that my changes weren't that smart after all :wink: , so I'd like to be able to stop compiling ...

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

The compilation process takes quite some time and sometimes I realize that my changes weren't that smart after all :wink: , so I'd like to be able to stop compiling ...

Thanks for clarifying. That sounds like it would come in handy. I'll try and get the .exe version updated this week and look into adding the functionality to the .dll version. Thanks for the suggestion :) .

Jaysun
  • Members
  • 20 posts
  • Last active: Sep 25 2006 12:42 AM
  • Joined: 01 Nov 2004
Without getting too much into the why I am trying to do the following, I am trying to create a custom GUI for the Windows FORMAT command line tool. This is for use on public computers and I cannot let our users be able to access the command line, and using "Rundll32.exe shell32.dll,SHFormatDrive" to make the Windows GUI for FORMAT has been probematic, plus the Windows GUI on XP does not pop up a dialog that shows if there were any bad sectors when the format is done.

So can CMDret be used to send keystrokes and strings to FORMAT while it is running? Can it grab all text output as it is actively displayed by the FORMAT command?

I have read through all the posts in this thread and tried using each of the functions of CMDret and before I try anymore, I'd like to know if it is possbile to do what I need to do.

Thanks much,

Jason

  • Guests
  • Last active:
  • Joined: --
give users access to format isn't a good idea anyway, only floppies maybe

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

So can CMDret be used to send keystrokes and strings to FORMAT while it is running?

Nope. CMDret doesn't send keystrokes... but AutoHotkey does...

Can it grab all text output as it is actively displayed by the FORMAT command?

I haven't done any testing with the FORMAT command yet. I might be able to set up something to format in a few days to test... It wouldn't surprise me if it didn't work correctly though...

floh
  • Guests
  • Last active:
  • Joined: --
nice feature! but...
... i'm new to dll handling and i have a question: how to interact with a program?

The problem: i have a Linux server who provides a SSL console interface. To connect this interface i use PuTTY or its command line tool PLINK.
How can i "remote control" plink.exe from AHK to log in into the server, read the answer from server (then AHK should parse the answer strings, display messages or fill some of the data into a GUI) and then send other commands depending on the answer or user action? The ssh session has to keep open for longer time.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I'm not sure if CMDret can interact with a console SSH client in this manner. If it can't, you might have better luck setting the client to maintain a log file. You could have the script watch the log file and respond to what shows up in there.

Alternatively, you could periodically copy the window text (or parts of it) to the clipboard, and then parse the clipboard to determine what responses have occurred.