|
-
Jun 3rd, 2011, 07:41 AM
#1
Thread Starter
Hyperactive Member
Show console window instead of GUI
I have this program that is a GUI program in C#.
I am working on implementing a way to make it do what it does but automatically via the console.
For example I can give the args "-console -i "Input" -o "Output"
and then it writes in the console window and never shows the GUI.
I know how to hide the GUI, but I don't know how to make it write to the console window? Just writing Console.WriteLine("Hello") doesn't work, it doesn't write that line to the console window. (via CMD.exe)
Any1 that has a clue on what I need to do?
-
Jun 3rd, 2011, 08:06 AM
#2
Re: Show console window instead of GUI
You may have to attach to the console using the Win32 method AttachConsole. Take a look at this example.
-
Jun 3rd, 2011, 08:30 AM
#3
Thread Starter
Hyperactive Member
Re: Show console window instead of GUI
Thanks for that link. I tried it and it kinda worked, but it was a little to dirty method for me. I will make some custom solution instead. Thx again!
-
Jun 7th, 2011, 06:29 AM
#4
PowerPoster
Re: Show console window instead of GUI
if you dont mind the console window being opened, then change your project settings to be a console application (after you created your winforms project)
any input/output from then will be displayed on the console - your winforms app/forms will also be shown.
you may need to redirect your inputs/outputs from your winforms app to the console. again - many solutions but depends what your requirements are 
I also believe you can change the program.cs on the Main() method and prevent it from running the form itself and just use that area to implement your logic for inputs etc...
Last edited by Techno; Jun 7th, 2011 at 06:32 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|