#AutoIt3Wrapper_Change2CUI=y
#include <WinAPI.au3>
#include <AutoItConstants.au3>
$sResponse = _ConsoleInput("Please enter website:")
ConsoleWrite("pinging:" & $sResponse&@CRLF)
$DOS = Run("Ping " & $sResponse, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While ProcessExists($DOS)
$Message = StdoutRead($DOS)
ConsoleWrite($Message)
WEnd
$Message = StdoutRead($DOS)
If $Message <> "" Then ConsoleWrite($Message)
;https://www.autoitscript.com/forum/topic/107951-help-with-_winapi_createfile-function-and-raw-mode/?do=findComment&comment=761172
Func _ConsoleInput($sPrompt)
If Not @Compiled Then Return SetError(1, 0, 0) ; Not compiled
ConsoleWrite($sPrompt)
Local $tBuffer = DllStructCreate("char"), $nRead, $sRet = ""
Local $hFile = _WinAPI_CreateFile("CON", 2, 2)
While 1
_WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), 1, $nRead)
If DllStructGetData($tBuffer, 1) = @CR Then ExitLoop
If $nRead > 0 Then $sRet &= DllStructGetData($tBuffer, 1)
WEnd
_WinAPI_CloseHandle($hFile)
Return $sRet
EndFunc