Page 1 of 1
[HELP] Fake Command Prompt
Posted: Sat Dec 22, 2012 1:56 pm
by 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.
Re: [HELP] Fake Command Prompt
Posted: Sat Dec 22, 2012 3:58 pm
by 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
Re: [HELP] Fake Command Prompt
Posted: Sat Dec 22, 2012 4:29 pm
by 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.