Jump to content

Recommended Posts

Posted

I'm having a problem with Windows 8 requiring a double "return" when inputting values into the console. With Win 7 and below only a single "return" is needed to signal the end of line, but with Windows 8 it requires two "returns" and the buffer is empty. I've done some research on changing the console mode but I'm not sure what mode needs to be turned off or on to work with Win8.

I'm using the Readfile API example from Valik to do the input but I not sure on how to change the console mode setting using this API.

#AutoIt3Wrapper_Change2CUI=y
#include <WinAPI.au3>
#include <StringConstants.au3>

_GetServiceInfoCMD()

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


Func _GetServiceInfoCMD()
    Local $sCustomerID = _ConsoleInput("Please enter your Customer ID: ")
    Local $iDcount = StringLen($sCustomerID)
    ConsoleWrite("Count: " &  $iDcount & @CRLF)
    Local $iIsNumber = StringIsDigit($sCustomerID)
    ConsoleWrite("IsNumber: " &  $iIsNumber & @CRLF)
    Local $i = 1
    While $i
        If $iIsNumber <> 1 Then
            ConsoleWrite( $sCustomerID & " is not a valid entry, must be numbers only." &  @CRLF)
            $sCustomerID = _ConsoleInput("Please enter again: ")
            $iIsNumber = StringIsDigit($sCustomerID)
            $iDcount = StringLen($sCustomerID)
            ConsoleWrite("IsNumber: " &  $iIsNumber & @CRLF)
            ConsoleWrite("Count: " &  $iDcount & @CRLF)
        ElseIf $iDcount <> 7 Then
            ConsoleWrite( $sCustomerID & " is not a valid entry, 7 numbers only." &  @CRLF)
            $sCustomerID = _ConsoleInput("Please enter again: ")
            $iIsNumber = StringIsDigit($sCustomerID)
            $iDcount = StringLen($sCustomerID)
            ConsoleWrite("IsNumber: " &  $iIsNumber & @CRLF)
            ConsoleWrite("Count: " &  $iDcount & @CRLF)
        Else
            $i = 0
        EndIf

    WEnd
    ConsoleWrite("Customer ID is: " & $sCustomerID & @CRLF)
    Local $sQuit = _ConsoleInput("Please any key to exit....")

EndFunc
Posted

Welcome to the forum.

Please add link to the Valik example which you use in your code.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 weeks later...

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...