C# Integration into Windows Shell - c#

I am currently in the process of developing an application in C#. I am using WPF forms and using an embedded SQLite Database.
I was wondering if it was possible to integrate my program into the windows shell. What I want to be able to do is if a user right clicks on a username or password text field on a website or a piece of software then the right click menu will show options for my program. If the user wants to copy their username from the software I have written then can right click on the field, go to menu 'Retrieve Password Manager Data' > choose the category (software/website) > company names retrieved from the database and then go to copy username or password.
Thanks for your help in this matter.

Integrating a .NET app into the shell without trouble is technically possible since .NET 4.0. Google IContextMenu to find sample C# code that implements the required COM interface. Beware of the difficulty of getting it right, debugging is very unpleasant.
But that's a long way from what you are asking for, the shell extension handler lets you create a menu entry in the context menu for Explorer windows. Text boxes in other apps don't expose a standard extensibility interface like the shell does. It is not quite impossible, it requires injecting code into the app with a windows hook. But you can't write that kind of code in C#.

Related

Controling a web browser using a desktop application

I want to know if I will be able to control a web browser using a C# program. What I want to do is the following:
I want to create a windows desktop application which will allow me to Open a web-browser (google chrome), input a webpage address, go to a web page, type something in a specific field or click something.
All of the above would have to be done automatically by the C# application without any user intervention after he opens up the application.
I want to know is it possible doing it in C# ? and if it isn't I would like some suggestions guiding me how would I go about creating this app, what programming language should I take a a look at or what should I research.
I only want a guidance for how I should go about creating this application.
Thanks to anyone who is going to answer ;)
There are a few possibilities to achieve this:
Use WatIn http://www.codeproject.com/Articles/17064/WatiN-Web-Application-Testing-In-NET
Or Selenium http://docs.seleniumhq.org/
Use WebClient, HttpRequest, HttpResponse classes

How to list all the elements of an application?

I'm trying to click a button on a windows application from other application. Basically, I want to click app B's button from app A's code.
I can use winapi findWindow to get a handler. The problem is that I have no idea the name of the button on the app B. Is this possible to list all the names or ids of an application?
I'm using c# to make it happen.
Since you're looking at suggestions (it's a pretty generic question really, it might or might not work depending on what other app/window is, is it e.g. browser or a 3rd party app etc., does it support automation)
Take a look at this closely related answer (it might be a duplicate but you're kind of 'looking for' still so maybe note).
Accessing Elements from Other Processes
Also this one on how to 'access' other app's 'inputs'
Pinvoke SetFocus to a particular control
I have not tested this. But it looks like a intressting libary. Maybe there is some function you can use. It is called White. This is just a sample:
Application application = Application.Launch("foo.exe");
Window window = application.GetWindow("bar", InitializeOption.NoCache);
Button button = window.Get<Button>("save");
button.Click();
You can use tool such as Spy++ (included in any Visual Studio except Express editions) to find name and class of that button and then use these information as parameters of FindWindow().

How to load an OCX using an .INF configuration file

It's my first post, so if I’m posting wrong or something, please let me know!
I'm developing an application in C# where I have to stream picture and sound from an IP Camera.
I have found a SDK from the manufacturer of the IP camera which should make it possible to integrate the streaming process into an application.
The IP camera is a LevelOne FCS-0010, and the SDK contains an .OCX file, an .INF file and a PDF file, which describes the different configuration parameters for the .INF file.
And here's my question: how do I use the OCX file in my application?
According to some forums, the OCX can just be drag 'n dropped into the toolbar in VS and then drag 'n dropped onto a WinForms form. This actually goes pretty well!
But then I just get a clean ActiveX object into my application, nearly just blank. Probably the OCX component needs to be configured, but how?
I guess I have to use the -INF file in some way in my application, so the OCX component could be configured. However, I really can’t figure out how.
It has to be registered first, use the vendor's recommended install procedure. Then you need to generate a AxHost wrapper for control, that allows it to be placed on a Winforms form or a WPF ElementHost.
Two ways to do that. Right-click the toolbox, Choose Items, COM tab and pick the control from the list. Which might be hard to do or not work at all if you don't know the name of the control. Second way is to run the Visual Studio Command Prompt and type aximp foo.ocx. That produces an AxFoo.Interop.dll, you can put it on the toolbox through Choose Items, Browse tab.
Not every ActiveX control is compatible with .NET, window-less controls are not supported.

How to get user input during windows installer for WinForms application?

I have a call tracking application that I've built and now I need to create a Windows Installer that bundles the .NET Framework 4.0 with the installer and also allows the user to enter a authentication id, when installing the application.
Then be able to get the value they entered to setup the application for their specific location, by setting an application setting, within the WinForms application.
If the installer can write the authentication id to the registry, I could grab it from there in my application, on startup.
Just not sure which installer to use that would make this as painless as possible.
All of the things in your question can be done by using Visual Studio Setup projects. But bit painful procedure. Do google search for finding resources about writing to registry and grabbing values at the start-up.
There may be other tools that give these functionalities in a more user-friendly way. I know only about Visual Studio Installer.
This article explains about adding custom dialog boxes.
This is completely easily can be done using NSIS (Nullsoft Scriptable Install System). It enables script based creation of installers and it lets writing of installers, customize and add features and do whatever you want using its own set of commands. You may add any control to any page (text boxes, check boxes etc.) and add any number of custom pages and do whatever you want. It has its own compiler and the script you write can be compiled using it and be compressed usefully.
See the below post too:
Customizing an exsisting NSIS MUI2 page
The NSIS and MUI (Modern User Interface) documentation, NSIS examples on NSIS site and winamp forums will help you at everything in your way...
In Advanced Installer you can do that pretty easily, but it's costly though. Check this tutorial

Prompting a user when activating a SharePoint feature through the site

I would like to know if there is a way to prompt the user when activating/deactivating a feature within SharePoint.
The background behind this is that I have a SharePoint solution that deploys several configuration files that are modified by the user when deployed to the site. I would like to either allow the user to decide whether or not to overwrite the files when activating or deactivating a feature.
Thanks guys!
Do you need this to work on ANY feature that is activated in your site, or just on features that are developed by you? If this is the latter case, you can add an event handler (SPFeatureReceiver) to your feature and catch the feature activated event.
EDIT: As per #Muhimbi's comment I finally understood the question - you want to allow user edit some properties and only then to activate the feature. In this case, I would suggest to define the feature as "hidden", so it does not show up in "web features" and "site features" list. Then create a custom page for "administration" of this feature, which would allow the user to override the settings in question etc. Then, register this administration page with SharePoint (again, deployed as a feature, these two features may be stapled together). Quote a good article about it can be found here: http://www.tonstegeman.com/Blog/Lists/Posts/Post.aspx?ID=13
EDIT2: found a similar article here on SO: SharePoint Feature Activation Form
One of the responses gives a good point - "The problem is, you don't always know where your feature activation code is going to run. If you turn on the feature using stsadm, it will execute in stsadm.exe, not the web process."

Categories