[HELP] Fake Command Prompt

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

[HELP] Fake Command Prompt
Scottie1972
has anyone come up with a why to create a Fake CMD Terminal that will accept string arguments?
if so please share. i could use a good working example.

i ask cause i am trying to create a game, well rather re-create a game and i need a "fake" command propmt to allow for command inputs.
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: [HELP] Fake Command Prompt
mandai
I suppose you could just use Console.Write and Console.WriteLine to simulate the output from a command prompt.
You can use Console.ReadLine to store the arguments.

If you are using a Forms based application then you can use the AllocConsole function to display the console window.
Code: Select all
    <DllImport("kernel32.dll")> Shared Function AllocConsole() As Boolean
    End Function

    <DllImport("kernel32.dll")> Shared Function FreeConsole() As Boolean
    End Function

    Sub consoleThread()

        AllocConsole()

        While True

            Console.WriteLine("test")

            Dim input As String = Console.ReadLine()

        End While

    End Sub

    Dim t As Thread = New Thread(AddressOf consoleThread)

    Private Sub btnConsole_Click(sender As System.Object, e As System.EventArgs) Handles btnConsole.Click

        '2nd thread needed so it doesn't freeze up the GUI on ReadLine
        t.Start()

    End Sub
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: [HELP] Fake Command Prompt
Scottie1972
mandai wrote:
I suppose you could just use Console.Write and Console.WriteLine to simulate the output from a command prompt.
You can use Console.ReadLine to store the arguments.

If you are using a Forms based application then you can use the AllocConsole function to display the console window.
Code: Select all
    <DllImport("kernel32.dll")> Shared Function AllocConsole() As Boolean
    End Function

    <DllImport("kernel32.dll")> Shared Function FreeConsole() As Boolean
    End Function

    Sub consoleThread()

        AllocConsole()

        While True

            Console.WriteLine("test")

            Dim input As String = Console.ReadLine()

        End While

    End Sub

    Dim t As Thread = New Thread(AddressOf consoleThread)

    Private Sub btnConsole_Click(sender As System.Object, e As System.EventArgs) Handles btnConsole.Click

        '2nd thread needed so it doesn't freeze up the GUI on ReadLine
        t.Start()

    End Sub
this is kinda of what i am thinking.
but instead of a consoleFree opening,
it would be more like a usercontrol with a label (for output) and a textbox for input.
Image
3 posts Page 1 of 1
Return to “Coding Help & Support”