| View previous topic :: View next topic |
| Author |
Message |
jaco0646
Joined: 07 Oct 2006 Posts: 559 Location: MN, USA
|
Posted: Mon Jul 21, 2008 4:01 am Post subject: Tip: retrieving command line output without a text file |
|
|
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 |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 935 Location: The Interwebs
|
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 559 Location: MN, USA
|
Posted: Mon Jul 21, 2008 4:50 am Post subject: |
|
|
I took a brief look at those threads, but the DLLCalls are way over my head. 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.  _________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 935 Location: The Interwebs
|
Posted: Mon Jul 21, 2008 4:54 am Post subject: |
|
|
Yeah, the Dll version is... x_x
But the AHK functions are very easy to use, just:
CMDret_RunReturn(program) |
|
| Back to top |
|
 |
|