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.
Related
I am developing a C# application. I am looking for a way to monitor different events in 3rd party applications.
Example 1: Calculator is running, and I want to know when the user has clicked on "=" button.
Example 2: Skype is running and I want to monitor when the user hits the "Call" button.
Example 3: Word is running and I want to monitor when the user opens the "Font" drop down list.
I am not looking for simple Mouse or Keyboard events.
Take a look at EventSpy, Both of those seams to do what you need.
http://www.codeproject.com/Articles/11918/EventSpy
http://eventspy.codeplex.com/
You basically need to tap into the "Windows Messaging" loop. In order to properly filter the GAZILLION messages that come flying through you'll also need to be able to periodically scan through all of the active windows to see which ones (if any) are relevant to you.
Be aware that this whole subsystem of windows is a GIANT security hole. (I have not worked with it much since NT4 / W95/W98 days so they might have tried attempts to "secure" it since then so it might be even harder to get to than it used to be.
You're going to need a good ide / 3rd party tools to help you get started on your way to have some idea of what you're looking for.
In a "previous" life we used this basic technique to get ~4,000 workstations to install their own software, updates, patches, etc through monitoring for existence of certain windows, controls, etc and "injecting" messages into the Windows Messaging loop to control Application Setup Programs, configuration changes that were not stored in the registry, etc, etc...
This question is asked alot, but I couldnt find working method / way to do it - except for a third party application.
I am pretty sure, or atleast I am being very hopeful that solution for this problem does exist.
As the title says, I want to disable window 8 gestures just like every third app is doing (SkipMetroSuite, ClassicShellMenu or w/e).
I need it to be built in in my app because I cant install anything on the compter my app is dedicated to but my app itself...
Is there a way to do it in C#?
EDIT:
I personally asked the developer of Classic Shell Menu how his programs works, here is the answer:
The principle is to inject a message hook in the thread of window with
class “ApplicationManager_DesktopShellWindow”, then listen for mouse
messages sent to windows with class “EdgeUiInputWndClass”, and hide
those windows. When my program exists it reshows all windows that it
has hidden.
He also mentioned I can find the solution here:
Classic Shell src
But there's one problem, the solution is in c++ and I have no Idea how to port it to c# so I would appreciate your help.
The solution is in ClassicStartMenuDLL.cpp which is in ClassicStartMenuDLL Solution.
The first step to what you want to do is to disable Metro mode (the start screen tiles).
You can achieve this via a registry edit, which you can do programmatically.
The entry of interest is the following:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RPEnabled
You need to set this to 0
Next, you want to disable the 'hot corners'. This is also a registry edit which can be done programmatically.
The entry of interest is the following:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell
Create a new key called EdgeUI, and under thay key create the following DWORD entries:
DisableTLcorner
DisableTRcorner (Windows 8.1+)
DisableCharmsHint
Set both values to 1
Since these are both HKCU settings (i.e. current user), then a simple log-off is all that is required for them to take effect.
Alternatively you can kill the explorer process, though it is not recommended.
If it is not working for you, try to test it with a ready-made registry file first, since you might be doing something wrong -> Disable Charms & Switcher
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?
I have a GUI C# Windows form program that I would like to start as a service when the computer starts and perhaps have an icon in the system tray that when clicked maximizes the program. Is this possible without major rework?
Thanks
Windows Services cannot have a GUI, at least not directly. You will have to separate your application to a presentation layer/process and a service layer/process:
The presentation layer will remain a WinForms application
The service layer will run as a Windows Service
The two of them will have to communcate with each other with some means of inter-process communcation, like named pipes or sockets.
You can use a third party app, such as FireDaemon (http://www.firedaemon.com/), to start any program as a service. There are many options available in FireDaemon, such as form visibility, restart on failure, etc. However, it will not automatically create a tray icon for your app. So your app will have to be changed to have its own tray icon functionality and FireDaemon will just start the program and manage the process.
FireDaemon costs about $40 (USD). I imagine there are many other similar applications available.
I would first look into creating an actual service project as mentioned by other answerers, but keep this approach in mind. It has worded well for me in a handful of situations.
It depends on how the code is currently written. I have several WinForm apps that double as services, but the bulk of the work I have separated into another assembly. My solutions for those apps generally have 3 projects: WinApp, Service, and Library (I'm oversimplifying here).
If you feel that your WinForm app could make a good service then you probably have your code in such a state that you could probably separate it out easily enough. Adding a service project is pretty simple, adding the installer for it is a little more challenging but still well documented. The trickiest part is making a deployment package for it that installs the service properly, but again... its well documented as long as you know you need to look for it.
Edit: Just to clarify, in general I wouldn't consider this a major project.
You can write the code to have it run as a service, but I think the more important question is, what does it provide? There are ways of minimizing an application to the tray, and you can start said applications at launch to the system tray.
This is the link that I always refer back to about doing windows services. It is WCF based, but I think with a little modification you could make it work for you:
http://support.microsoft.com/kb/317421
As to minimizing to a tray, there's an excellent answer in this question:
What's the proper way to minimize to tray a C# WinForms app?
You could use Task Manager within windows and setup a task that would execute your application's .exe per windows boot.
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).