Visualizzazione dei risultati da 1 a 5 su 5
  1. #1
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305

    [vb6] Vedere Un Messaggio Sulla Console Attuale

    Voglio che la mia applicazione, quando da riga di comando del prompt DOS scrivo
    Miaapp.exe Come Va?
    mi risponda scrivendo sempre nel prompt del DOS:
    “bene”
    Sono riuscita in parte a fare ciò che volevo usando l’esempio di codice che ho trovato nella API GUIDE:
    codice:
    Private Const FOREGROUND_BLUE = &H1
    …
    Private Const ENABLE_ECHO_INPUT = &H4&
    Private Const ENABLE_MOUSE_INPUT = &H10&
    Private Const ENABLE_PROCESSED_INPUT = &H1&
    Private Const ENABLE_WINDOW_INPUT = &H8&
    Private Const STD_OUTPUT_HANDLE = -11&
    Private Const STD_INPUT_HANDLE = -10&
    Private Const STD_ERROR_HANDLE = -12&
    Private Const INVALID_HANDLE_VALUE = -1&
    Private Declare Function AllocConsole Lib "kernel32" () As Long
    Private Declare Function FreeConsole Lib "kernel32" () As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
    Private Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
    Private Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (ByVal hConsoleInput As Long, ByVal lpBuffer As String, ByVal nNumberOfCharsToRead As Long, lpNumberOfCharsRead As Long, lpReserved As Any) As Long
    Private Declare Function SetConsoleTextAttribute Lib "kernel32" (ByVal hConsoleOutput As Long, ByVal wAttributes As Long) As Long
    Private Declare Function SetConsoleTitle Lib "kernel32" Alias "SetConsoleTitleA" (ByVal lpConsoleTitle As String) As Long
    Private hConsoleOut As Long, hConsoleIn As Long, hConsoleErr As Long
    Private Sub Form_Load()
        'KPD-Team 2001
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        'Create console
        If AllocConsole() Then
            hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
            If hConsoleOut = INVALID_HANDLE_VALUE Then MsgBox "Unable to get STDOUT"
            hConsoleIn = GetStdHandle(STD_INPUT_HANDLE)
            If hConsoleOut = INVALID_HANDLE_VALUE Then MsgBox "Unable to get STDIN"
        Else
            MsgBox "Couldn't allocate console"
        End If
        'Set the caption of the console window
        SetConsoleTitle "The KPD-Team 2001"
        'Set the background color of the text in the console to bright YELLOW text
        'on a BLUE background
        SetConsoleTextAttribute hConsoleOut, FOREGROUND_RED Or FOREGROUND_GREEN Or FOREGROUND_INTENSITY Or BACKGROUND_BLUE
        'Write something in the console
        ConsoleWriteLine "Hello World!"
        ConsoleWrite "Please enter your name: "
        'Ask for user input and show it in the caption
        Me.Caption = "Your name: " + ConsoleReadLine()
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'Delete console
        CloseHandle hConsoleOut
        CloseHandle hConsoleIn
        FreeConsole
    End Sub
    Sub ConsoleWriteLine(sInput As String)
         ConsoleWrite sInput + vbCrLf
    End Sub
    Sub ConsoleWrite(sInput As String)
         Dim cWritten As Long
         WriteConsole hConsoleOut, ByVal sInput, Len(sInput), cWritten, ByVal 0&
    End Sub
    Function ConsoleReadLine() As String
        Dim ZeroPos As Long
        'Create a buffer
        ConsoleReadLine = String(10, 0)
        'Read the input
        ReadConsole hConsoleIn, ConsoleReadLine, Len(ConsoleReadLine), vbNull, vbNull
        'Strip off trailing vbCrLf and Chr$(0)'s
        ZeroPos = InStr(ConsoleReadLine, Chr$(0))
        If ZeroPos > 0 Then ConsoleReadLine = Left$(ConsoleReadLine, ZeroPos - 3)
    End Function
    solo che il messaggio me lo scrive aprendomi una nuova console; io voglio che me lo scriva nella console attuale. Come faccio?
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

  2. #2
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305
    help
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

  3. #3
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305

    Re: [vb6] Vedere Un Messaggio Sulla Console Attuale

    Originariamente inviato da luisa227
    Voglio che la mia applicazione, quando da riga di comando del prompt DOS scrivo
    Miaapp.exe Come Va?
    mi risponda scrivendo sempre nel prompt del DOS:
    “bene”
    Sono riuscita in parte a fare ciò che volevo usando l’esempio di codice che ho trovato nella API GUIDE:
    codice:
    Private Const FOREGROUND_BLUE = &H1
    …
    Private Const ENABLE_ECHO_INPUT = &H4&
    Private Const ENABLE_MOUSE_INPUT = &H10&
    Private Const ENABLE_PROCESSED_INPUT = &H1&
    Private Const ENABLE_WINDOW_INPUT = &H8&
    Private Const STD_OUTPUT_HANDLE = -11&
    Private Const STD_INPUT_HANDLE = -10&
    Private Const STD_ERROR_HANDLE = -12&
    Private Const INVALID_HANDLE_VALUE = -1&
    Private Declare Function AllocConsole Lib "kernel32" () As Long
    Private Declare Function FreeConsole Lib "kernel32" () As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
    Private Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
    Private Declare Function ReadConsole Lib "kernel32" Alias "ReadConsoleA" (ByVal hConsoleInput As Long, ByVal lpBuffer As String, ByVal nNumberOfCharsToRead As Long, lpNumberOfCharsRead As Long, lpReserved As Any) As Long
    Private Declare Function SetConsoleTextAttribute Lib "kernel32" (ByVal hConsoleOutput As Long, ByVal wAttributes As Long) As Long
    Private Declare Function SetConsoleTitle Lib "kernel32" Alias "SetConsoleTitleA" (ByVal lpConsoleTitle As String) As Long
    Private hConsoleOut As Long, hConsoleIn As Long, hConsoleErr As Long
    Private Sub Form_Load()
        'KPD-Team 2001
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        'Create console
        If AllocConsole() Then
            hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE)
            If hConsoleOut = INVALID_HANDLE_VALUE Then MsgBox "Unable to get STDOUT"
            hConsoleIn = GetStdHandle(STD_INPUT_HANDLE)
            If hConsoleOut = INVALID_HANDLE_VALUE Then MsgBox "Unable to get STDIN"
        Else
            MsgBox "Couldn't allocate console"
        End If
        'Set the caption of the console window
        SetConsoleTitle "The KPD-Team 2001"
        'Set the background color of the text in the console to bright YELLOW text
        'on a BLUE background
        SetConsoleTextAttribute hConsoleOut, FOREGROUND_RED Or FOREGROUND_GREEN Or FOREGROUND_INTENSITY Or BACKGROUND_BLUE
        'Write something in the console
        ConsoleWriteLine "Hello World!"
        ConsoleWrite "Please enter your name: "
        'Ask for user input and show it in the caption
        Me.Caption = "Your name: " + ConsoleReadLine()
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'Delete console
        CloseHandle hConsoleOut
        CloseHandle hConsoleIn
        FreeConsole
    End Sub
    Sub ConsoleWriteLine(sInput As String)
         ConsoleWrite sInput + vbCrLf
    End Sub
    Sub ConsoleWrite(sInput As String)
         Dim cWritten As Long
         WriteConsole hConsoleOut, ByVal sInput, Len(sInput), cWritten, ByVal 0&
    End Sub
    Function ConsoleReadLine() As String
        Dim ZeroPos As Long
        'Create a buffer
        ConsoleReadLine = String(10, 0)
        'Read the input
        ReadConsole hConsoleIn, ConsoleReadLine, Len(ConsoleReadLine), vbNull, vbNull
        'Strip off trailing vbCrLf and Chr$(0)'s
        ZeroPos = InStr(ConsoleReadLine, Chr$(0))
        If ZeroPos > 0 Then ConsoleReadLine = Left$(ConsoleReadLine, ZeroPos - 3)
    End Function
    solo che il messaggio me lo scrive aprendomi una nuova console; io voglio che me lo scriva nella console attuale. Come faccio?
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

  4. #4
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305
    CONSOLE
    Praticamente voglio scrivere qualcosa nel prompt dos e voglio ricevere la risposta sempre li. È una cosa possibile?
    Quindi quando io aprirò il mio prompt dei comandi dos e scriverò vicino a
    C:\Documents and Settings\Luisa>
    MiaApp.exe ciao, voglio che sotto mi scriva “come va?” (NON VOGLIO UNA CONSOLE A PARTE!!!)
    Spero di essermi spiegata
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

  5. #5
    Utente di HTML.it L'avatar di luisa227
    Registrato dal
    Mar 2002
    Messaggi
    2,305
    Originariamente inviato da luisa227
    CONSOLE
    Praticamente voglio scrivere qualcosa nel prompt dos e voglio ricevere la risposta sempre li. È una cosa possibile?
    Quindi quando io aprirò il mio prompt dei comandi dos e scriverò vicino a
    C:\Documents and Settings\Luisa>
    MiaApp.exe ciao, voglio che sotto mi scriva “come va?” (NON VOGLIO UNA CONSOLE A PARTE!!!)
    Spero di essermi spiegata
    un appello agli esperti
    Le mie richieste qui sul forum sono al 99,9% considerate assurde e senza senso, ma per me un senso lo hanno e gradirei una risposta più seria possibile. Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.