AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CMDret - return output from console progs [DLL version]
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Utilities & Resources
View previous topic :: View next topic  
Author Message
m^2



Joined: 28 Feb 2008
Posts: 56
Location: Krk, PL

PostPosted: Wed Jul 23, 2008 10:58 pm    Post subject: Reply with quote

Hello,
I wanted to use cmdret to get output from 7zip, but there's one issue.
Some archives are encrypted. In such case 7zip waits for the password.
It would be great if CmdRet could not only get the returned text, but also write to stdin. However, if it's too much, could you return pid of the spawned program? In such case I could at least kill the program and inform the user that encrypted archives are not supported.
And one more suggestion. Why output to a control? It seems overly complicated, in my case I have to create an invisible control just to get messages from CmdRet.
_________________
Waiting for Windows 8...
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2399

PostPosted: Sun Jul 27, 2008 3:41 am    Post subject: Reply with quote

There is an option for stdin in the RunWEx(CMD, CMDdir, CMDin, CMDout, CMDerr) function but an option to wait for output before sending something to stdin is not currently supported (possibly in the next version) .

The latest beta version (download) will currently return the handle to the process when using the RunWCB() function. The next version is planned to support stdin in a similar callback function.

The optional function RunInControl() that is designed to output to control is mainly designed as a quick way to show console output in a GUI. There is no need to use this function if you don't need the user to view the output. Is there something in this function that you need that doesn't exist in the other functions? The RunReturn() or RunRedirect() functions should allow receiving output without having to use a hidden control.

Thanks for the feedback Smile
Back to top
View user's profile Send private message Visit poster's website
m^2



Joined: 28 Feb 2008
Posts: 56
Location: Krk, PL

PostPosted: Sun Jul 27, 2008 10:44 am    Post subject: Reply with quote

Thanks, but I implemented it already.. with callbacks too.
I've got an impression that RunInControl is the only function that doesn't return all output at once and therefore - let me react if something happens on the way.
_________________
Waiting for Windows 8...
Back to top
View user's profile Send private message
DerRaphael



Joined: 23 Nov 2007
Posts: 456
Location: Heidelberg, Germany

PostPosted: Wed Jul 30, 2008 10:29 am    Post subject: Reply with quote

hi corrupt,

i tried using the 3.1.2 dll version and your RunInCtrl Example. It always crashed the Autohotkey Script keep it not responding.

That means ... i started the Script. Clicked thru the tabs. Selected 1st tab, hit the button waited untill ping was done (some strange Asian chars appeared where Umlauts should have been) and then ... nothing

The Ping successfully did its Job, but the script got stuck. No more switching Tabs nothing. On ContextMenu Click in Taskbar windows told me that the application crashed.

Im running win2k sp4 (german) with ahk 1.0.47.06 and your latest supplied dll.

greetings
DerRaphael

great job btw Very Happy

edit i just tried the beta 4a version with same issue. while it runs everything is ok. but as soon the executed command is done, the script still thinks its runnin (so it tells me in status bar)
exiting the process manually with ProcessExplorer resulted in a crash much the way it did with prior versions.
_________________
Back to top
View user's profile Send private message
evandevon



Joined: 22 Apr 2008
Posts: 18

PostPosted: Mon Aug 04, 2008 5:20 pm    Post subject: E002_ReadConsoleInput Failed invalid handle error??? Reply with quote

Hi!
Im trying to use cmdret to get streaming output from serialterm (a command line serial port utility)
If I use the code below I get this error

Quote:

E002_ReadConsoleInput Failed...: (6) The handle is invalid


Code:

; CMDret DLL version 3.1.2 (or greater) required
; cmdstub.exe required if using command.com

 ret1 := CMDret("cmdstub.exe c:\serialterm.exe com1 19200 hex newline no")
 MsgBox, %ret1%

CMDret(CMD)
{
  VarSetCapacity(StrOut, 100000)
  RetVal := DllCall("cmdret.dll\RunReturn", "str", CMD, "str", StrOut)
  Return, %StrOut%
}


I don't know if serialterm is 16bit - I don't think I'd get anything at all if it was though.

If I use the streaming code
Code:
; CMDret DLL version 3.1 (or greater) required

Gui, Add, Edit, x6 y10 w460 h360 +HScroll
Gui, Show, x398 y110 h377 w477, CMDret - DLL version - Streaming Test App

CMD = cmdstub.exe c:\serialterm.exe com1 19200 hex newline no
OutputWindow := WinExist("CMDret - DLL version - Streaming Test App")

StrOut := DllCall("cmdret.dll\RunInControl", "str", CMD, "Uint", OutputWindow, "str", "Edit", "int",

"1")
Return

GuiClose:
ExitApp

I just get a blank gui - with and without the cmdstub.exe bit

I must be misunderstanding something. What I need is to see the hex values sent to my com port (in a way which I can use as variables in a script).

Any help is appreciated, thanks.
_________________
Inventing problems that need solutions...
Back to top
View user's profile Send private message
Serenity



Joined: 08 Nov 2004
Posts: 1017

PostPosted: Sat Aug 09, 2008 12:38 am    Post subject: Reply with quote

I'm experiencing the same crashing with v3.1.2 and 4a beta as DerRaphael mentioned. I'm also running 2k SP4 with AHK 1.0.47.06.
_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Utilities & Resources All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8
Page 8 of 8

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group