I want to know how you would go about adding a GUI to a command line application.
For example, I think uTorrent can be used in the command line? but it also has a regular Windows version.
You can create a 'batch-file', and then double-click on it (it will be executed by the command line). The extension used for this is .bat.
Not that hard to do. You can google a little bit around, and will learn quickly how to do this.
For example, visit this site: http://rancidtaste.hubpages.com/hub/How-to-create-a-batch-file
Just my cent.
If you only will provide a gui for the application, you can add a form that will be the gui for it.
The form must contain the necessary info an controls to be able to call the right methods or functions you already defined.
Usually, on the main procedure, you will check if the environment is user interactive to show the form, unless a parameter in the call to the application asks for not to use the GUI.
If you must show the form, then show it as dialog, and end the application when the form is closed.
Hope this helps.
Okay well I kind of know how to make Windows forms applications if that's what you mean. But most tutorials just show how to add buttons and stuff to the form and call functions with them. I guess you can make class files and include them in the main file, but where would you define functions?
Some of this code is mine and some is not. It is an example of how to build a GUI for a console application. In this case, the application is md5sums.exe, which takes a file or folder name as an argument then calculates a checksum for the file, or all files in the folder. The controls on the form are
txtOutput - displays program output (stdout and stderr)
tstFile - for the user to enter a file or folder name
btnExecute - executes the command
Public Class Form1
Private WithEvents MyProcess As Process
Private Delegate Sub UpdateOutputDelegate(ByVal text As String)
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
MyProcess = New Process
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Private Sub btnExecute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecute.Click
If My.Computer.FileSystem.FileExists(txtFile.Text) Or My.Computer.FileSystem.DirectoryExists(txtFile.Text) Then
.FileName = "cmd.exe"
.Arguments = "/c d:\utils\md5sums.exe " & txtFile.Text
.UseShellExecute = False
.CreateNoWindow = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.RedirectStandardError = True
MyProcess.BeginErrorReadLine() 'start async read on stderr
MyProcess.BeginOutputReadLine() 'start async read on stdout
MsgBox("file or folder not found", vbOKOnly, txtFile.Text)
Private Sub MyProcess_ErrorDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.ErrorDataReceived
'add stderr text to output display
UpdateOutput(vbCrLf & "Error: " & e.Data)
Private Sub MyProcess_OutputDataReceived(ByVal sender As Object, ByVal e As System.Diagnostics.DataReceivedEventArgs) Handles MyProcess.OutputDataReceived
'add stdout text to output display
UpdateOutput(vbCrLf & e.Data)
Private Sub UpdateOutput(ByVal text As String)
'add text to output display
If txtOutput.InvokeRequired Then
Dim myDelegate As New UpdateOutputDelegate(AddressOf UpdateOutput)
Code could be added to parse the text in txtOutput and extract the checksum. Comments on how to improve this code are always appreciated.