Is there a way to combine Console and GUI applications in C#? - c#

HOMEWORK:
Over the course of the semester, I have created about a dozen applications in C#. While most of them are console applications, three of them are GUI apps. As a final project, our instructor has asked us to create a portfolio program which displays a menu from which the user can select which console application to run.
Being the overachiever that I am, I would like to create a single program that would allow the user to select ANY program created during the semester, console OR GUI.
While I've found a lot of q&a's that address allowing a program to run EITHER as a GUI or Console, I'm not sure those are quite applicable to my situation. This link and this link seem to most CLOSELY match what I'm trying to do. Part of the problem is that we're just starting to scratch the surface of GUI programming this semester, so I don't know a lot of what I don't know. This makes it difficult to ask the right questions and determine how relevant a link is.
My approach is to create a GUI menu. Some of the menu items would launch a Console app inside a Console window, and some of the menu items would launch their respective GUI apps. Does anyone have any practical advice or relevant links that would help guide me to a solution?

Related

How to get a value of a RadioButton from a WinForm application that I don't have an API for?

I have a small calculation system that will be installed in multiple PCs. Those PCs have a program installed in them and this program is always open (but minimized).
I need to get the value of a 'RadioButton' in this program but I can't access it!
I've tried to get an API for this application but the company developed it refused to co-operate. I've got a crazy idea, you can refer to my question regarding this idea Click It and the last thing is to get the cache for the button but I think this is going to work with WebApplications only!
Any help would be Great! =) .. And btw I decided to build my application as web application but then I changed my mind to build it as a WinForms because of the screenshot. But if I got a better and a more clean solution I'd go back to WebApp
Screen grabbing is not a good option. You should be able to use FindWindow based methods to get hold of the radio button if the app uses windowed controls. If not then UI Automation may very well be able to get the value of the radio button. Whatever it's usually possible to read UI state out of another application with methods like this, and much easier than screen scraping.

Design Patterns or Good ways to solve the problem

I need to develop an application in Winform C# and trying to find out suitable design pattern for this application.
Basically, My application Interacts with couple of Exes and output is monitored and based on the output, user will click button to trigger another console application (as shown in fig).
Right now, I have written separate class for every console application with which my application is interacting.
What are best ways to solve this problem (using Design Patterns).
Thank you,
Harsha
Are the Console App from 3d?
If not, You are able to create another Project(DLL) with the methods of that apps, and use it on your Winforms app.

Multi-project solution & cross-application data handling

Time for another "what am I overlooking" question! Thanks in advance for your guidance, and as ever, you guys rock! :)
.NET 2010 Winforms, but I only have the Express version. I have 05 Pro, but am trying to transition to 2010. If I need to upgrade... well, maybe I'll stick with 05, since this is just for my own amusement.
I want to make a multi-application suite for a project I've got in mind. The project has several components that should interact together, but still be robust and stand-alone.
The components include:
1) A Notification Area utility (I/E System Tray) - I anticipate using this as a quick-launch, data-passing medium, and other minor things. I'd like to keep it as small as possible. Double-click to launch main menu, right-click to launch another app.
2) The Main Menu. This is what would start if you run the program normally, and essentially organizes the other apps.
3-6) These other apps each do some things, but are fairly self-contained.
.
.
Question 1: What is a multi-app or multi-project solution called? I think I'm missing a buzz-word here, because my search-fu isn't getting any results.
For the most part, I'm looking for some pointers, more precise vocabulary, and some suggestions on what existing features can handle these sorts of things.
Question 2: How can I make each of these apps/projects able to launch independently? I don't want to go through the Main Menu each time; I want the ability to start the app from Program Files directly.
Despite that requirement, I also need to check if the Notification Utility is running, and start it if it isn't. The Utility should be running any time any other app is running, and closing it would close all the other apps.
Also, the Notification (and Main Menu) apps need to be able to start the other apps.
Question 3: How can I pass data between the windows?
The concept in my head is to have Window A send a packet to the Utility, which would then pass it to Window B. Window B also needs to send a confirmation packet.
Question 4: How can I set up one of the apps (the Notification Utility)
Question 1 - "Solutions" typically contain one or more projects.

Create separate window from Console Application

I'm having a bit of a trouble trying to create a multi window'ed console application. Currently, my application's main console window is used to collect user input and display output.
Much of this output comes from a separate thread, as live data comes in. I was wondering if there is a way for me to separate my application into two windows, where the second window was either a console window or even any other kind of window that could display the text of the incoming strings... In particular, the main console window would be where the user input commands etc, and the second window displayed what the system was currently working on. This second window could be entirely readonly.
Any suggestions would be greatly appreciated! I would post code, but I don't really have anything relevant (that I can think of) to post....
This will be hard to do.
Here is answer for similar question: Can you have multiple .net Consoles (as in Console.Writeline)
If you really want to do it, you can find logic here: http://www.codeproject.com/KB/cpp/MultipleConsoles.aspx
Maby better approach will be to start another process (console app) and communicate between them thru IPC ( Interprocess communication ) - like named pipes .
More about IPC you can find: http://www.infoq.com/news/2008/01/wcf-comm-options
It is probably easier to just pop-up a Windows Form with a TextBox containing the data you wish to show. You can simply start a new thread and call Form.ShowDialog() to get the form to show.

How does someone go about writing a "macro" in C#?

I know something about MACROS. I don't mean the ASSEMBLY language kind. I am talking about those programs that you can use perform repetitions actions on another program. I am talking about those programs that you can use to record a series of events on your computer, like, mouse movements and button clicks and then you can play them back. Some of them are elaborate enough to run only on a paricular app that you designate.
I wrote one of sorts once. It was a program that launched an Excel sessions and then used the dynamic data exchage pipe of some kind to feed the excell session script commands. It worked.
But something on the level of the operating system, I imagine, is a whole different story.
How does someone go about writing a "macro" in C#?
I think the approach I will take is to use the spy routine that comes with the development environment to get a list of the proper messages and parameters (wm_lbuttondown for example) and then use dynamic data exchange to send those messages to the app.
So I have three questions.
Is this the best way to do this?
How do I get a handle to an app that is already running?
How do I send user-like messages to an app that is already running?
There are different answers based on many following factors:
is it 3rd party or your own
application?
does it have automation interface
GUI toolkit used in app
If it is a 3rd party app then you need to work on Windows API level via PInvoke - subclassing WinMain proc, capturing and sending input messages, etc. There are 3rd party library for that task. C# obviously is not a right choice for such task.
In case application has automation model (like Excel) it's a pretty straight forward to write program that will be interact with this app.
If it's your own application you want to enhance with macros functionality then you should take this into account on design state. If you use Command pattern from the beginning then it's not hard to program macro recording.
You should provide more details to get a better answer.
Oh, I almost forgot to answer those three questions
Is this the best way to do this?
Depends on concrete scenario
How do I get a handle to an app that is already running?
Depends on application. If it's a native Win app you can easily get process Id and window's handle via WinApi.
How do I send user-like messages to an app that is already running?
Once again it depends on application type. For native win apps you can easily send WM_XXX messages via WinAPI
Unless its something you need to add in your own program you can just download a keyboard/mouse macro program and use it to perform these repeatable actions.
On the other hand to perform macro's in your own program you would want to find a way to record the buttons clicked and write them to a temporary list that can be saved and then run the list by clicking the buttons (programmically).

Categories

Resources