AutoHotkey Community

It is currently May 26th, 2012, 9:05 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 104 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject:
PostPosted: July 13th, 2008, 4:16 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
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.

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2008, 5:16 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
thanks for the beating dad :D
i was in a mood

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2008, 2:26 pm 
Offline

Joined: July 23rd, 2007, 3:43 am
Posts: 47
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 4th, 2008, 11:39 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 5th, 2008, 5:07 pm 
Offline

Joined: July 23rd, 2007, 3:43 am
Posts: 47
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. :oops:

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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 6th, 2008, 12:01 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 8th, 2008, 1:15 am 
Offline

Joined: July 23rd, 2007, 3:43 am
Posts: 47
Perfect! After downloading again, it works exactly as expected. Thanks again Sean!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 9:54 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Thanks a lot for this great function :D

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2008, 9:06 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Is there any way to implement CTRL & C function like it works in cmd?

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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2008, 9:08 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Is there any way to implement CTRL & C function like it works in cmd?

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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2008, 9:09 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Is there any way to implement CTRL & C function like it works in cmd?

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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 13th, 2008, 4:46 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 1:10 pm 
Offline

Joined: March 4th, 2009, 3:27 pm
Posts: 25
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 1:38 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2009, 2:16 pm 
Offline

Joined: March 4th, 2009, 3:27 pm
Posts: 25
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!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 104 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Klark92, Stigg, tomoe_uehara and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group