Jump to content
Sign in to follow this  

Using pipes in AutoIt. Like "|" in CMD files.

Recommended Posts


Here is a simple solution for CMD piping.

; Example of piping in AutoIt

; define commands to pipe
$sCmd1 = "dir " & @SystemDir & "\*.*" ; display all files of system directory
$sCmd2 = "find /I "".exe""" ; select all EXE files
$sCmd3 = "find /I ""di""" ; select all files with 'di' as substring

; run commands concurrent
$iPID1 = Run(@ComSpec & " /C " & $sCmd1, "", @SW_HIDE, 9) ; $STDIN_CHILD(1) + $STDERR_MERGED(8)
$iPID2 = Run(@ComSpec & " /C " & $sCmd2, "", @SW_HIDE, 9) ; $STDIN_CHILD(1) + $STDERR_MERGED(8)
$iPID3 = Run(@ComSpec & " /C " & $sCmd3, "", @SW_HIDE, 9) ; $STDIN_CHILD(1) + $STDERR_MERGED(8)

; pipe output of first command as input to second command
While Sleep(10)
    $sTmp = StdoutRead($iPID1, False, True)
    If @error Then ExitLoop StdinWrite($iPID2)
    StdinWrite($iPID2, $sTmp)

; pipe output of second command as input to third command
While Sleep(10)
    $sTmp = StdoutRead($iPID2, False, True)
    If @error Then ExitLoop StdinWrite($iPID3)
    StdinWrite($iPID3, $sTmp)

; display output of third command
MsgBox(Default, Default, StdoutRead($iPID3), 0)
  • Like 2

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.