Jump to content

Recommended Posts

Posted

How do I send input and receive output from a command prompt without:

1. Using send (not the most reliable/efficient code from my understanding)

2. Without compiling the script as a CUI.

I've tried STDIN/STDOUT, but can't seem to either enter text into the command prompt or receive the output of commands entered in the command prompt. And from my understanding, ControlSend/ControlGetText won't work either as the command prompt does not have the standard Windows controls.

Suggestions?

Thank you all for your time and assistance with this!

Posted

I've tried STDIN/STDOUT, but can't seem to either enter text into the command prompt or receive the output of commands entered in the command prompt.

I dont know an awful lot about commant prompt, but I will offer you this.

You are doing something wrong, I suggest you post the code you have tried.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

you know PKZIP i've been using this to encrypt some of my files

using Autoit i have this code

Run("cmd /c C:\ENC\PKZIP.EXE -astest -n+ " & $ZipFilePath & " " & $UnFilePath)

who knows this might help your problem

Work smarter not harder.My First Posted Script: DataBase

Posted

I added a stripped down example i've done some time ago, it's working but now with out any sense, but head for the lines:

Local $foo = Run(@ComSpec & " /c " & $ShellScriptName, $Workdir, @SW_HIDE, 2 + 4)

$line = $line & StdoutRead($foo)

So the magic is done with :

StdoutRead

and

of course not in my example:

StdoutWrite

#include <GuiEdit.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <ScrollBarConstants.au3>

Opt('MustDeclareVars', 1)

;~ Global $ShellScriptName = $CmdLine[1]
;~ Global $Workdir = $CmdLine[2]
;~ Global $CounterFiles = $CmdLine[3]

global  $ShellScriptName="D:\1work\prog\DEMO_LOOP.CMD"
global  $Workdir="D:\1work\prog\"


Global $StartCounter = 1000
Global $ProgressStep = 100 / $StartCounter
ProgressGui()
Sleep(1000)

Exit
Func ProgressGui()
    Local $progressbar1, $progressbar2, $wait, $msg, $m, $outputwindow, $CurrentCounter, $infotext

    GUICreate("Progress on files...", 420, 300)
    $progressbar1 = GUICtrlCreateProgress(10, 10, 200, 20)
    GUICtrlSetColor(-1, 32250)
    $progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH)
    $infotext = GUICtrlCreateLabel("INFO:", 10, 70, 200, 20)
    $outputwindow = GUICtrlCreateEdit("Text", 20, 100, 350, 150)
    GUISetState()

    $wait = 20; wait 20ms for next progressstep
    $CurrentCounter = 10;
    Local $foo = Run(@ComSpec & " /c " & $ShellScriptName, $Workdir, @SW_HIDE, 2 + 4)
    Local $line
    Do
        $msg = GUIGetMsg()
        $line = $line & StdoutRead($foo)

        GUICtrlSetData($outputwindow, $line)
        _GUICtrlEdit_Scroll($outputwindow, $SB_SCROLLCARET)
        GUICtrlSetData($progressbar1, $CurrentCounter * $ProgressStep)
        GUICtrlSetData($progressbar2, (100 - $CurrentCounter * $ProgressStep))
        Sleep($wait)
    Until $CurrentCounter = 0
    GUICtrlSetData($infotext, "Files to do:" & $CurrentCounter & " from starting " & $StartCounter & " COMPLETE")
EndFunc   ;==>ProgressGui

Does this help you? So posting your code would be helpful.....

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...