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 

Tip: retrieving command line output without a text file

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jaco0646



Joined: 07 Oct 2006
Posts: 559
Location: MN, USA

PostPosted: Mon Jul 21, 2008 4:01 am    Post subject: Tip: retrieving command line output without a text file Reply with quote

This may have been posted already, but I've never seen it. The only way I've ever gotten info from the Windows command line is by writing to a text file, parsing it, and immediately deleting it (hoping that it was never written to disk).

I just discovered the "For" command which will parse output within the command shell and put it into variables, which can in turn be passed to an AHK script as parameters, therefore removing the need for a text file.

As a simple example, this scriptlet gets the PC's uptime in human-readable format.
Code:
If %0%
 MsgBox,64,UpTime,%1%
Else
 Run, %comspec% /c For /f "tokens=3*" `%x IN ('SystemInfo') DO If `%x==Time: Call "%A_ScriptFullPath%" "`%y",,Hide

_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Krogdor



Joined: 18 Apr 2008
Posts: 935
Location: The Interwebs

PostPosted: Mon Jul 21, 2008 4:15 am    Post subject: Reply with quote

You can also use CMDret:
http://www.autohotkey.com/forum/viewtopic.php?t=3687

Or the AHK functions for the same:
http://www.autohotkey.com/forum/viewtopic.php?t=8606
Back to top
View user's profile Send private message AIM Address
jaco0646



Joined: 07 Oct 2006
Posts: 559
Location: MN, USA

PostPosted: Mon Jul 21, 2008 4:50 am    Post subject: Reply with quote

I took a brief look at those threads, but the DLLCalls are way over my head. Confused I'm sure the functions are very powerful, but the "For" command may be a better alernative for lightweight applications. Either way, I posted it in case someone has a use for it. Smile
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
Krogdor



Joined: 18 Apr 2008
Posts: 935
Location: The Interwebs

PostPosted: Mon Jul 21, 2008 4:54 am    Post subject: Reply with quote

Yeah, the Dll version is... x_x
But the AHK functions are very easy to use, just:
CMDret_RunReturn(program)
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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