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 

StdoutToVar
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Sun Jul 13, 2008 4:16 pm    Post subject: Reply with quote

tank wrote:
documenting seans functions would be like documenting ahk's source so that a novice could understand it

Apparently you have never actually looked at the source of autohotkey... I'll give you a random snippett here:
http://pastebin.com/m3d3e477f
(I used the pastebin because the forum does not like c++ codez.)
[the comments are red]

tank wrote:
do we really think that explaination would help any one maybe Chris wants these examples alone on the first page

Chris wants some examples or documentation because it is going into the Script Showcase . The Script Showcase includes the very best scripts (as seen in Chris' eyes). Is it really too much for him to ask for some sort of consistency in the user scripts he is including with the installer? I think not.

PS: Please stop using large red type to try to get your point across. It is annoying. Also please attempt to make complete and coherent sentences.

tank wrote:
i for one dont understand the point

That is the exact reason that you should not even be posting your ramblings.

Oh and by the way...the post you replied to is over a year old.
_________________

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
tank



Joined: 21 Dec 2007
Posts: 2413
Location: Louisville KY USA

PostPosted: Sun Jul 13, 2008 5:16 pm    Post subject: Reply with quote

thanks for the beating dad Very Happy
i was in a mood
_________________
Basic Webpage Controls with JavaScript / COM - Tutorial by Jethrow
Back to top
View user's profile Send private message
daniel2



Joined: 23 Jul 2007
Posts: 47

PostPosted: Sat Oct 04, 2008 2:26 pm    Post subject: Reply with quote

Sean wrote:
Streaming ability was added to StdCreateProcess(). If specify the parameter bStream to True it'll create a console window and display line-by-line the result, in addition to returning the result as a whole.

This function is so unbelievably helpful to me, I wanted to thank you updating it so it has ability to stream. The question I have is how to specify my own callback function rather than using the console window?

I currently have my own modded version of function that does this, but would prefer to not use a non standard version of your function for my stdlib.

Code:
  Loop
    If   DllCall("ReadFile", "Uint", hStdOutRd, "Uint", &sTemp, "Uint", nTemp, "UintP", nSize:=0, "Uint", 0)&&nSize
    {
      NumPut(0,sTemp,nSize,"Uchar"), VarSetCapacity(sTemp,-1), sOutput.=sTemp
      If   bStream&&hCon+1
        Loop
           If   RegExMatch(sOutput, "[^\n]*\n", sTrim, nTrim)
            %bStream%(sTemp), nSize ? nTrim+=nSize : ""
           Else   Break
     }

Please let me know if there is something simple I am overlooking with how I could be utilizing the console window method that you have provided. Thanks!
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Sat Oct 04, 2008 11:39 pm    Post subject: Reply with quote

daniel2 wrote:
Please let me know if there is something simple I am overlooking with how I could be utilizing the console window method that you have provided.

As it's easy to incorporate the custom callback function into StdoutToVar_CreateProcess() I implemented it. You can pass the custom function name to bStream instead of True. For example,
Code:
; Custom Function Name must not consist solely of numbers!
MsgBox % sOutput := StdoutToVar_CreateProcess("ping.exe www.autohotkey.com", "Stream")
; Custom Function Name is "Stream" in this example!

Stream(sString)
{
;   Custom Routine here! For example,
   OutputDebug %sString%
}
Back to top
View user's profile Send private message
daniel2



Joined: 23 Jul 2007
Posts: 47

PostPosted: Sun Oct 05, 2008 5:07 pm    Post subject: Reply with quote

Sean wrote:
As it's easy to incorporate the custom callback function into StdoutToVar_CreateProcess() I implemented it. You can pass the custom function name to bStream instead of True.

Wow. I didn't realize that you implemented like that from reading your description of new functionality. Embarassed

That is how the modification I made above works too. I reverted to using the StdoutToVar.ahk posted in initial post (I can only assume that it is the most recent version)-- but still doesn't display OutputDebug, and if I run script from explorer it keeps displaying results in console window (my callback function for streaming isn't getting called at all Question )
Code:
MsgBox % sOutput := StdoutToVar_CreateProcess("ping.exe www.autohotkey.com", "Stream")
; Custom Function Name is "Stream" in this example!

Stream(sString)
{
;   Custom Routine here! For example,
   tooltip, received: %sString%
}

I also tried putting a msgbox in my function-- but the only msgbox that shows is for the returned sOutput.

Anyway, thanks for taking time to give example utilizing a callback routine.
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Mon Oct 06, 2008 12:01 am    Post subject: Reply with quote

daniel2 wrote:
I didn't realize that you implemented like that from reading your description of new functionality.
Sorry, I wasn't clear enough. I meant implemented after your request. Please download again.
Back to top
View user's profile Send private message
daniel2



Joined: 23 Jul 2007
Posts: 47

PostPosted: Wed Oct 08, 2008 1:15 am    Post subject: Reply with quote

Perfect! After downloading again, it works exactly as expected. Thanks again Sean!
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 2197
Location: GERMANY

PostPosted: Tue Dec 09, 2008 9:54 pm    Post subject: Reply with quote

Thanks a lot for this great function Very Happy
_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 2197
Location: GERMANY

PostPosted: Wed Dec 10, 2008 9:06 pm    Post subject: Reply with quote

Is there any way to implement CTRL & C function like it works in cmd?

Someting like:
Code:
StdoutToVar_CreateProcess(sCmd, bStream = "", sDir = "", sInput = "", sHotkey="")

_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 2197
Location: GERMANY

PostPosted: Wed Dec 10, 2008 9:08 pm    Post subject: Reply with quote

Is there any way to implement CTRL & C function like it works in cmd?

Someting like:
Code:
StdoutToVar_CreateProcess(sCmd, bStream = "", sDir = "", sInput = "", sHotkey="")

_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 2197
Location: GERMANY

PostPosted: Wed Dec 10, 2008 9:09 pm    Post subject: Reply with quote

Is there any way to implement CTRL & C function like it works in cmd?

Someting like:
Code:
StdoutToVar_CreateProcess(sCmd, bStream = "", sDir = "", sInput = "", sHotkey="")

_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Sat Dec 13, 2008 4:46 am    Post subject: Reply with quote

HotKeyIt wrote:
Is there any way to implement CTRL & C function like it works in cmd?
No, without defeating the very purpose of this script. The closest thing you can do may be TerminateProcess or alike.
Back to top
View user's profile Send private message
Metaxal



Joined: 04 Mar 2009
Posts: 21

PostPosted: Fri Mar 13, 2009 1:10 pm    Post subject: Reply with quote

Excellent script!

However it seems to crash without notice when the command is not correct, like:
MsgBox % x:= StdoutToVar_CreateProcess("plop")
MsgBox "ok !"

Also, StdoutToVar_CreateProcess("dir") doesn't work, you have to write
StdoutToVar_CreateProcess("cmd /K dir")

Is that normal behavior?
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2222

PostPosted: Fri Mar 13, 2009 1:38 pm    Post subject: Reply with quote

Metaxal wrote:
However it seems to crash without notice when the command is not correct, like:
It's not a crash, it'll just execute ExitApp if failed to create a process as it's pointless to keep running then.
Quote:
StdoutToVar_CreateProcess("dir") doesn't work, you have to write
StdoutToVar_CreateProcess("cmd /K dir")
Yes, it's a normal behavior. dir is not a stand-alone application, it's an internal command of the command prompt, cmd.exe.
Back to top
View user's profile Send private message
Metaxal



Joined: 04 Mar 2009
Posts: 21

PostPosted: Fri Mar 13, 2009 2:16 pm    Post subject: Reply with quote

Sean wrote:
Metaxal wrote:
However it seems to crash without notice when the command is not correct, like:
It's not a crash, it'll just execute ExitApp if failed to create a process as it's pointless to keep running then.


Ah ok I see. Well, I d'ont like my app to exit when one function call fails Wink
Fortunatly, this can easily be changed Smile

Sean wrote:

Metaxal wrote:
StdoutToVar_CreateProcess("dir") doesn't work, you have to write
StdoutToVar_CreateProcess("cmd /K dir")
Yes, it's a normal behavior. dir is not a stand-alone application, it's an internal command of the command prompt, cmd.exe.


Ok, I thought it would be something like that. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Page 4 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