AutoHotkey Community

It is currently May 24th, 2012, 6:46 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 104 posts ]  Go to page 1, 2, 3, 4, 5 ... 7  Next
Author Message
 Post subject: StdoutToVar
PostPosted: February 20th, 2007, 1:09 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
I just saw this great post:
http://www.autohotkey.com/forum/viewtopic.php?t=8606

I thought I might share my own version which is actually porting to AHK of the script I've been using personally.
The main difference may be that it doesn't create the console window at all, not just hiding the console.

DOWNLOAD StdoutToVar.ahk.


Last edited by Sean on August 22nd, 2007, 7:44 am, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2007, 7:25 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2248
Location: switzerland
Nice script, I don't understand DllCall, I tried with DOS before
Code:
runwait,%comspec% /c ipconfig /all |find /V "XXXX" >ipconfig.txt,,hide
run,ipconfig.txt


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2007, 3:54 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2537
Hi Sean. Your version has a few interesting differences. Thanks for sharing :) .


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2007, 4:19 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
corrupt wrote:
Hi Sean. Your version has a few interesting differences. Thanks for sharing :) .

It's my pleasure!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 6:54 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I've added a link to this great script from the script showcase.

I'm sure you have better things to do with your time, but the topmost post could use a bit more introduction (even a single sentence), and possibly a simple usage example. When I examine a post for accessibility and presentation, I ask:

1) What is somone's first impression upon viewing this post?
2) Can someone find out the gist of the post in under 30 seconds? (This helps them decide whether to continue reading the whole thing.)

Thanks for sharing your proficiency and creativity.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 11:54 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Chris wrote:
I've added a link to this great script from the script showcase.

Thanks for adding the link to my script in this great place.

Quote:
I'm sure you have better things to do with your time, but the topmost post could use a bit more introduction (even a single sentence), and possibly a simple usage example.

Now it's going to be weekend, I'll update the script, maybe adding StdIn too.
Thanks for pointing it out.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 5:59 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
I would be interested in these points:
- Is it reliable/fail save?
- Are there any limitations on commands to be used?
- Is it fast? It looks like, since it seems to be using far less commands then CmdRet.
- How could a working directory be specified?

Has someone tested this code?

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 8:01 am 
Quote:
and possibly a simple usage example.
I've to backup Chris' proposal. Noobs (I guess not necessarily your target audience :wink:) will definitely benefit from having a sample to understand its full potential. Thx for sharing it. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 8:31 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Sean, thx for this great func.

One question: can you make it async ?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 12:57 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
One question: can you make it async ?

I updated the script, however, it's a preliminary version yet.
Anyway, do you mean like this by async?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 1:57 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
No. I mean about equivalent to CMDRet_Stream

Btw, I was always wondering is it possible to
Quote:
; Create the console app without creating a console window

so thx for this.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 2:20 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
No. I mean about equivalent to CMDRet_Stream

Well, I failed to see a difference if I understood it correctly.
The StdOutput() in my script didn't wait until the console app finished either.
It also retrieved the data whenever available. Was that what you meant?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 2:37 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
The difference is CMDRet_Stream notifies you on each new line, not after everything is finnished. Your version works like non stream version of CMDRet.

Anyway, its hard to define how this should work. For instance systeminfo command first displays status of currently scaned system item in the first line, deliting its contenst to show new status. Then it writes output normaly after everything is collected. Similar is Lame compressor which uses single line to update procentage.

When calling rar console app, CMDRet will return this string also

Code:
File name...  0% 1% 2% 3% .... 99% OK.



While rar is compressing single file it changes single line and CMDRet returns each changed char. CMDRet_Stream doesn't do that as timer is slow. I wonder is there any reliable solution with AHK to be sure you got everything program wrote... CMDRet seams to catch all, but it is non async (i.e. the user routine is not called as soon as change is there)

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 27th, 2007, 3:21 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
The difference is CMDRet_Stream notifies you on each new line, not after everything is finnished. Your version works like non stream version of CMDRet.

I see, you meant line-by-line retrieving.

PS. I just noticed the SetTimer there.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 28th, 2007, 5:19 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2537
majkinetor wrote:
When calling rar console app, CMDRet will return this string also

Code:
File name...  0% 1% 2% 3% .... 99% OK.



While rar is compressing single file it changes single line and CMDRet returns each changed char. CMDRet_Stream doesn't do that as timer is slow.
This isn't due to a slow timer in CMDret_Stream but due something that was overlooked. CMDret_Stream doesn't currently trigger on new output but triggers when a new line is added. This is why the information is usually retrieved after execution instead of during. However, due to an apparent lack of interest in CMDret, although it is still being developed, I have decided not to spend the time posting any updates for it. CMDret was originally provided as a function to allow people at the forum an opportunity to participate in development in hopes that the result would inspire Chris to add this functionality (possibly with similar syntax and functionality of the version(s) posted) as a built-in command/function in AutoHotkey. This does not seem to have turned out to be the case unfortunately. I will likely post one more updated version soon with a message in the first post indicating that the version posted will be the final version.

Sean, It looks like your version is coming along nicely :) . I would have preferred if it the functionality was produced as a single function instead of several functions that rely on each other but some people tend to prefer things broken apart in small pieces. It's all good :) .

One of the main reasons for CMDret creating a hidden console window was for compatibility for a few specific applications and for creating workarounds for 16 bit applications (unreleased versions). This difference can be made in either version by modifying one line of code though.


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 1, 2, 3, 4, 5 ... 7  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alexa [Bot], Bing [Bot], S0und and 12 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