[FUNCION] Autoit CMD Prompt

Iniciado por 79137913, Noviembre 28, 2013, 10:42:17 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Noviembre 28, 2013, 10:42:17 AM Ultima modificación: Diciembre 02, 2013, 12:35:30 PM por 79137913
HOLA!!!

Jugando con autoit cree esta pequeña suite de funciones para trabajar con CMD:
Código: autoit
;Creado por 79137913
#include <Constants.au3>
Global $cmdpid
Global $cmdresponse

;~ _iniciarCMD()
;~ _sendCMDCommand("ping 127.0.0.1",2)
;~ MsgBox(0,"",$cmdresponse)
;~ _sendCMDCommand("cd ..",1)
;~ MsgBox(0,"",$cmdresponse)
;~ _sendCMDCommand("cd ..",1)
;~ MsgBox(0,"",$cmdresponse)
;~ _CerrarCMD()
Exit
func _SendCMDCommand($command,$timeoutlimit);Envia un comando CMD y devuelve la respuesta, timeout es en segundos
    StdinWrite($cmdpid,$command)
    StdinWrite($cmdpid,@CRLF)
;StdinWrite($cmdpid)
    Local $data
Local $response
Local $timeout
$data = ""
    While True
    sleep(100)
        $data &= StdoutRead($cmdpid)
        If $data <> "" Then
$response=$response & $data
$data=""
$timeout=0
EndIf
$timeout=$timeout+1
if $timeout=$timeoutlimit*10 then ExitLoop
    WEnd
    $cmdresponse = $response
EndFunc
func _CerrarCMD();Cerrar CMD
   StdinWrite($cmdpid)
EndFunc   
Func _IniciarCMD();Inicializar CMD
    $cmdpid = Run("C:\Windows\system32\cmd.exe",@SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
EndFunc


GRACIAS POR LEER!!!
"Algunos creen que soy un bot, puede que tengan razon"
"Como no se puede igualar a Dios, ya he decidido que hacer, ¡SUPERARLO!"
"La peor de las ignorancias es no saber corregirlas"

*Shadow Scouts Team*                                                You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Que bien numeros!!
Jamas he programado en Autoit, pero tiene aire a VB6