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  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Utilities & Resources
View previous topic :: View next topic  
Author Message
Laszlo



Joined: 14 Feb 2005
Posts: 3877
Location: Pittsburgh

PostPosted: Tue Oct 25, 2005 4:19 pm    Post subject: Reply with quote

AHKnow* wrote:
temporarily block user input just before the console program terminates
We normally don't know when it would terminate.
AHKnow* wrote:
pass the original clipboard data into a variable too, like say variable "X". Then your script uses the clipboard. You then copy the contents of variable "X", back to the clipboard.
This is exactly what I meant. It is the standard practice, omitted from the original post for clarity
Code:
!c::
   Settimer GetIt, 30                  ; the GetIt thread will get the buffer
   RunWait %comspec% /k dir c:\,,,PID  ; will be closed from GetIt
                                       ; at this point: console buffer -> ClipBoard
   StringReplace Text,ClipBoard,`r`n%A_WorkingDir%>,,R ; remove last command prompt
   ClipBoard = %ClipBoard0%            ; <- Restore original
   MsgBox %Text%                       ; put here the code to process Text
Return

GetIt:
   WinGetTitle Title, ahk_pid %PID%    ; get the changing window title
   If Title <> %comspec%               ; program name affixed while busy
      Return                           ; keep trying until idle
   Settimer GetIt, Off                 ; need not run any more
   WinActivate ahk_pid %PID%           ; go to our console window
   ClipBoard0= %ClipBoardAll%          ; <- save original
   ClipBoard =                         ; empty ClibBoard to see data comming
   Send !{Space}es{Enter}              ; select all = used buffer, copy to clipboard
   ClipWait 2                          ; wait until clipboard is available, < 2s
   WinClose ahk_pid %PID%              ; close console window
Return
With this version the two applications involved jump to the foreground, and the user's work get interrupted. There is no need to block user input.
Back to top
View user's profile Send private message Visit poster's website
AHKnow*
Guest





PostPosted: Wed Oct 26, 2005 5:09 am    Post subject: Reply with quote

Thanks Laszlo. I think you did a good job dealing with my questions.
Back to top
fooz



Joined: 08 Jan 2006
Posts: 8

PostPosted: Fri Jan 20, 2006 6:47 pm    Post subject: Reply with quote

Hi,
Crossposting the following from this post:
http://www.autohotkey.com/forum/viewtopic.php?t=7490

Regarding CMDret, and the following code:

Code:


CMDout=
CMDerr=
ProgramName := "C:\php\php.exe getVPIP.php 5"

Ret := RunWaitEx(ProgramName, NULL, TextIn, CMDout, CMDerr)
MsgBox, Return Value: %Ret% `r`n`r`nStdError: `r`n%CMDerr%`r`nStdOutput: `r`n%CMDout%

RunWaitEx(CMD, CMDdir, CMDin, ByRef CMDout, ByRef CMDerr)
{
VarSetCapacity(CMDOut, 100000)
VarSetCapacity(CMDerr, 100000)
RetVal := DllCall("cmdret.dll\RunWEx", "str", CMD, "str", CMDdir, "str", CMDin, "str", CMDout, "str", CMDerr)
Return, %RetVal%
}


I am using it to call a PHP program that outputs values/data to standard out. Is this what is captured in "CMDout"? Or do I need to somehow access that variable by reference within the called PHP program?
Back to top
View user's profile Send private message
not-logged-in-daonlyfreez
Guest





PostPosted: Sat Jan 21, 2006 12:08 am    Post subject: Reply with quote

Try adding this

Code:
CMDin = ""


And changing this

Code:
ProgramName = C:\php\php.exe getVPIP.php 5

Ret := RunWaitEx(ProgramName, NULL, CMDin, CMDout, CMDerr)
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2328

PostPosted: Mon Jan 23, 2006 1:22 am    Post subject: Reply with quote

Work on version 4 of CMDret is now in progress. The main goal of this release is to streamline the syntax/functionality of CMDret to hopefully make the addition of CMDret functionality to AHK a bit easier (as a possible built-in command and/or function).

Any comments and/or suggestions for syntax and/or functionality of CMDret for the next release would be greatly appreciated Smile .

Thanks Smile
Back to top
View user's profile Send private message Visit poster's website
jroad



Joined: 06 Feb 2006
Posts: 26

PostPosted: Mon Feb 13, 2006 9:04 pm    Post subject: Reply with quote

Hi corrupt,

First off thanks for taking the time working on this tool. My question would be to ask if it was possible to have your tool return the process id? If not, then could the exe version be updated to send output to a variable?

Also, I just downloaded the CMDRET1.1 exe zipfile, looking for examples but did not find any within.

Regards
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10450

PostPosted: Sun Feb 26, 2006 10:37 pm    Post subject: Reply with quote

Due to a suggestion from PhiLho, I put a link to this topic in the FAQ under "how to retrieve command line output". This should help increase awareness of CmdRet.
Back to top
View user's profile Send private message Send e-mail
corrupt



Joined: 29 Dec 2004
Posts: 2328

PostPosted: Sun Mar 12, 2006 1:28 am    Post subject: Reply with quote

The RunReturn function is now available as a function that doesn't rely on an external dll Smile
Back to top
View user's profile Send private message Visit poster's website
eagle00789



Joined: 27 Nov 2006
Posts: 48
Location: Heerlen Country: Netherlands

PostPosted: Tue Jun 26, 2007 7:23 am    Post subject: Reply with quote

is any of the CMDRet functions in the dll compatible with a hidden cmd window, or can i use the pure ahk-function to get the output of a hidden cmd window (started with
Code:
RunWait, c:\winamppid.vbs,,hide
) or can you make a suggestion of how to do this on a hidden cmd window
_________________
Before asking a question try to read the manual
Always use the code sections when you paste some code
Back to top
View user's profile Send private message
corrupt



Joined: 29 Dec 2004
Posts: 2328

PostPosted: Wed Jun 27, 2007 7:22 am    Post subject: Reply with quote

eagle00789 wrote:
is any of the CMDRet functions in the dll compatible with a hidden cmd window, or can i use the pure ahk-function to get the output of a hidden cmd window (started with
Code:
RunWait, c:\winamppid.vbs,,hide
) or can you make a suggestion of how to do this on a hidden cmd window
Instead of using RunWait to start the vbs script, try using CMDret instead. CMDret does not currently have an option to connect to a process that is already running. The window should end up being hidden if run using CMDret.
Back to top
View user's profile Send private message Visit poster's website
eagle00789



Joined: 27 Nov 2006
Posts: 48
Location: Heerlen Country: Netherlands

PostPosted: Wed Jun 27, 2007 2:31 pm    Post subject: Reply with quote

ok. i'm changing my code right now Very Happy
_________________
Before asking a question try to read the manual
Always use the code sections when you paste some code
Back to top
View user's profile Send private message
Hogar
Guest





PostPosted: Wed Aug 01, 2007 7:17 pm    Post subject: Reply with quote

Hi corrupt,

Great work!
You wrote it's freeware but did you mean "freeware" or "free software"? What License is it?

Thanks
Hogar
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2328

PostPosted: Wed Aug 01, 2007 7:30 pm    Post subject: Reply with quote

Hogar wrote:
Hi corrupt,

Great work!
You wrote it's freeware but did you mean "freeware" or "free software"? What License is it?

Thanks
Hogar
Thanks Smile

For non-commercial use, non-critical environments (eg. not for medical equipment, nuclear reactor, etc...) - no restrictions
For commercial use - a credit somewhere would be nice but not required, depends on usage...

If you would like something a lot more specific then please suggest a specific license and I'll let you know... Either way, I wouldn't be looking for compensation, I'd just want to cover possible liability issues... (USE AT YOUR OWN RISK) Wink Smile .
Back to top
View user's profile Send private message Visit poster's website
Hogar
Guest





PostPosted: Wed Aug 01, 2007 9:22 pm    Post subject: Reply with quote

Thanks!

Be shure I write your name ("corrupt"?) in the Credits/About.

Hogar
Back to top
corrupt



Joined: 29 Dec 2004
Posts: 2328

PostPosted: Thu Aug 02, 2007 1:10 am    Post subject: Reply with quote

Hogar wrote:
Thanks!

Be shure I write your name ("corrupt"?) in the Credits/About.

Hogar
Greg Fenty (aka "corrupt")
apps4apps@gmail.com
http://www.apps4apps.filetap.com

This message will self-destruct in 48 hours... Wink
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  Next
Page 6 of 7

 
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