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
nlid
  • Guests
  • Last active:
  • Joined: --
There you have it. cmdret4d.zip

HTH

Greetings,

daonlyfreez

blode
  • Members
  • 25 posts
  • Last active: Apr 27 2013 04:49 PM
  • Joined: 11 Jul 2012

There you have it. cmdret4d.zip

HTH

Greetings,

daonlyfreez

thanks a ton! :mrgreen:

blode
  • Members
  • 25 posts
  • Last active: Apr 27 2013 04:49 PM
  • Joined: 11 Jul 2012
Is there any solution for capturing stdout with AHK while keeping the the CLI application open / command prompt as it is ?

Is there a way I could send "diskpart" in one DllCall and "help" in the next and see diskpart's help?

Proxx
  • Members
  • 9 posts
  • Last active: Mar 17 2013 12:22 PM
  • Joined: 23 Mar 2011

Downloaded and using the cmdret4d.zip but all the examples are not working.

 

could somebody help me?



jdauthre
  • Members
  • 15 posts
  • Last active: Sep 17 2013 07:44 PM
  • Joined: 20 Apr 2010

Can anyone help?  I am wanting to stream STDOUT from Mplayer  to a variable line by line  and parse it for some other process, Using variations of the cmdret.dll\RunInControl example I can stream it to notepad or gui,edit  etc, but cant see a way of programmatically  getting the variable so I can then parse it.    I can do this using the old non dll CMDRET.  I am clearly missing something but I dont know what! 

Thanks in advance



szujeq
  • Members
  • 304 posts
  • Last active: Jan 12 2017 09:11 PM
  • Joined: 28 Mar 2011

Is there any alternative for CMDret (dll version)?? Best with support for unicode.

I rebuild there samples from ANSI to UNICODE but it do not display properly some characters and from time to time is not so stable.



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

I'm amazed that anyone still uses this (or tries to)...



Howardb1
  • Members
  • 13 posts
  • Last active: Jul 03 2013 07:45 AM
  • Joined: 17 May 2013

What other options do we have to do this?

 

I did see the following and found that it worked, but it chops the output of things like a directory listing or listing a 40k txt file.  Also, because the output is captured from the WSH Shell's Standard Output and Standard Error textstreams you must use the Exec method, so can't completely to hide the DOS window.  On the other hand, the output capture tends to take more than a few seconds, so what else are you going to watch while this happens? tongue.png None of this is critisms of your DLL.  I'm just sharing this incase another readers finds this later.

 

Thanks for your work!

I think using WshShell Object maybe a better way. For details, please see:
[AHK&AHK_l]Using COM to interact with command-line progs

 

However, I haven't been able to get your DLL to work yet for the examples I used on the other solution.  I'm using AutoHotKey L 64 bit on a Windows 7 Pro computer.  I either have my script wrong or the DLL isn't for the version of AutoHotKey that I'm running.

 

Anyway, thanks for putting this out here.



ReSpecto
  • Members
  • 2 posts
  • Last active: Sep 05 2014 08:21 AM
  • Joined: 17 Aug 2014

Sorry to bump this old-ass thread, but all the links here are dead, including the dropbox link on top of the page

can somebody post a new link please

or is there any alternatives/new ways of using the output of command-line tools in your scripts?
-thanks



garry
  • Spam Officer
  • 3219 posts
  • Last active: Sep 20 2018 02:47 PM
  • Joined: 19 Apr 2005

have no experience, just an example

;-- write to memory example exiftool.exe --------------
;-http://www.autohotkey.com/board/topic/89581-exiftoolexe-comspec-output/
;-http://www.sno.phy.queensu.ca/~phil/exiftool/

F1="%A_scriptdir%\xxb.jpg"                                    ;- check picture
objShell := ComObjCreate("WScript.Shell")
objExec := objShell.Exec(ComSpec " /c exiftool " F1 )         ;- exiftool.exe is in scriptdir
strStdOut := ""
while, !objExec.StdOut.AtEndOfStream
    strStdOut := objExec.StdOut.ReadAll()
MsgBox %strStdOut%                                            ;- show exifdata
exitapp



ReSpecto
  • Members
  • 2 posts
  • Last active: Sep 05 2014 08:21 AM
  • Joined: 17 Aug 2014

WOW Thanks!
I was looking for it for quite some time now...
how did I missed the whole StdOut stuff?

anyway, I managed to rewrite it to output line-by-line
here is a little script that pings to check connection, with live GUI output
 

DetectHiddenWindows,On
Run,%ComSpec% /k,,Hide UseErrorLevel,pid
if not ErrorLevel
{
while !WinExist("ahk_pid" pid)
Sleep,10
DllCall("AttachConsole","UInt",pid)
}
CMD=ping -n 10 8.8.8.8
objShell:=ComObjCreate("WScript.Shell")
objExec:=objShell.Exec(CMD)
Gui,1:-border
Gui,font,s8
Gui,Add,Text,W280 H300 vText gButtonCancel,Testing internet connection`r`nPinging Google DNS: 10 times
Gui,Show,w280 H300
while,!objExec.StdOut.AtEndOfStream
{
GuiControlGet,Text
strStdOut:=objExec.StdOut.readline()
GuiControl,,Text,%Text%`r`n%strStdOut%
}
GuiControlGet,Text
GuiControl,,Text,%Text%`r`n`r`n%A_Tab%%A_Tab%%A_Space%%A_Space%Click me to Close..
Return
ButtonCancel:
Gui,Destroy
Exitapp