 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ahklerner
Joined: 26 Jun 2006 Posts: 1317 Location: USA
|
Posted: Sun Jul 13, 2008 4:16 pm Post subject: |
|
|
| 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 |
|
 |
tank
Joined: 21 Dec 2007 Posts: 2413 Location: Louisville KY USA
|
|
| Back to top |
|
 |
daniel2
Joined: 23 Jul 2007 Posts: 47
|
Posted: Sat Oct 04, 2008 2:26 pm Post subject: |
|
|
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Sat Oct 04, 2008 11:39 pm Post subject: |
|
|
| 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 |
|
 |
daniel2
Joined: 23 Jul 2007 Posts: 47
|
Posted: Sun Oct 05, 2008 5:07 pm Post subject: |
|
|
| 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.
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 )
| 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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Mon Oct 06, 2008 12:01 am Post subject: |
|
|
| 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 |
|
 |
daniel2
Joined: 23 Jul 2007 Posts: 47
|
Posted: Wed Oct 08, 2008 1:15 am Post subject: |
|
|
| Perfect! After downloading again, it works exactly as expected. Thanks again Sean! |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2197 Location: GERMANY
|
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2197 Location: GERMANY
|
Posted: Wed Dec 10, 2008 9:06 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2197 Location: GERMANY
|
Posted: Wed Dec 10, 2008 9:08 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 2197 Location: GERMANY
|
Posted: Wed Dec 10, 2008 9:09 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Sat Dec 13, 2008 4:46 am Post subject: |
|
|
| 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 |
|
 |
Metaxal
Joined: 04 Mar 2009 Posts: 21
|
Posted: Fri Mar 13, 2009 1:10 pm Post subject: |
|
|
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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2222
|
Posted: Fri Mar 13, 2009 1:38 pm Post subject: |
|
|
| 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 |
|
 |
Metaxal
Joined: 04 Mar 2009 Posts: 21
|
Posted: Fri Mar 13, 2009 2:16 pm Post subject: |
|
|
| 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
Fortunatly, this can easily be changed
| 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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|