c# Read another applications listbox and sub listboxes? - c#

How does one go about reading another applications listview and sub-listviews? This program has a main listview with a few other mini listviews once an item is clicked on the main view.
I want to create an application that can read the all of the listviews, how do I go about doing that? What is the best way to achieve this?

There are a number of ways to do this.
The supported way is to use an automation API like UIAutomation which is very simple to program. If the other application is using the standard Windows list view control then it should be accessible through UIAutomation. If the other application is using non-windowed controls (e.g. WPF, Qt) then you are dependent on the application implementing support for UIAutomation.
The other commonly attempted approach is to send windows messages to the list view control. This first of all involves enumerating the child windows of the application's main window in order to find the list view window. You can then send the control messages to obtain its contents. This sounds easy, but is actually rather tricky. The reason is that the messages require you to supply pointers to structures that are meaningful in the other process address space. This involves calls to OpenProcess, VirtualAlloc, WriteProcessMemory, ReadProcessMemory etc. It's quite tricky to get it right.
In my view, you should choose the automation API.

Related

Combining C# Windows Form Applications, Master Solution

Rather than have a large collection of small desktop applications, I was wondering if there's a way I can combine them into one 'Master Form' with links to each?
I have many similar applications and the ideal situation would be to have almost like a website hierarchy, where the user can navigate to the application they want.
I have considered a solution that sits on top of the rest and calls the others in some way, but I can't find if this is possible or not, is every separate application effectively stand-alone?
Yes you can directly disign on master form for it.
keep menus for each exe(Application) and,
give command in following way for onclick of that menu in master>>
System.Diagnostics.Process.Start("billing.exe",strCmdText);
Or directly Process.Start("C:\\");

How can I read data from controls on window in a different application?

I have to write an application that observes another application and extracts information from the window. What is the best way to access windows from other applications and get data from their controls?
You'll need to P/Invoke the FindWindow and FindWindowEx functions to retrieve a handle to the other application's parent window and child controls.
Then you will need to use something like GetWindowText to access the text for a particular control.
Visit pinvoke.net for the definitions you'll need to call these functions from C#.
Be warned that this is not a completely straightforward pursuit. You should stop to consider whether you really have a good reason for wanting to do this, and if your goal couldn't be achieved in a simpler way.

What C# / Win32 Control Is the Wireless Network Dialog Using?

I'm working on an application, and I have a screen that in my mind, looks a lot like the Wireless Network List in Windows Vista. For those who are unaware, its basically a listview, but in each row, instead of a line of text, there's a large 'panel' that contains all sorts of useful information. Does anyone know if that's an actual UI control available on windows, or should I roll my own with some sort of autosizing table layout panel hosting a collection of custom controls?
I know this is pretty easy to make using WPF using the stackpanel layout along with a series of user controls containing grid controls for internal layout. Or are you using windows forms?
The wireless network dialog isn't using a standard Win32 control, it's using a custom control (effectively).
If you want to emulate that behavior, you're going to have to use WPF or roll your own.
Not an exact answer but you may want to look at the various Vista TaskDialog libraries and dialogs that have been based on that. You may be able to borrow some of the code since they share some UI functionality. I need to do the something similar with WPF.

Read Items from Control in another Application

I have an MDI application for which I do not have source for. I believe it is an MFC application. I need to automate some of it's functionality.
It has a form with a listview type control on it. I would like to be able to read that list from my new C# application to know what the items are so I can select the correct one. I have tried Spy++ from VS2008 but it cannot see the listview control. There are no windows messages that are useful. How can I make the items in this list available to my new application?
Thanks.
Is it appearing in Spy++ at all? If it is just a window handle then the whole control is custom drawn in which case you are pretty much out of luck.
The only time you would might be able to query this data would be if it was based on one of the Windows standard controls or if it allows you to query it using messages (which is unlikely unless it was designed to be automated)

How could you enable a WPF application to create user controls on the fly?

How could you create an application that could search through a directory, find user controls in the form of paired .xaml / .xaml.cs files, and compile/execute these on the fly? Is this possible? Is there an .exec() or .compile() class somewhere that could do this?
Basically what I want to do with this is have a WPF application that is running and by having the user fill out a form describing the kind of page/functionality he wants, the application could generate XAML and code behind files which are then immediately usable without having to recompile the application.
I'm assuming that this is to change the behaviour of the UI on a known application rather than a XAML/CS component generator for use in another application - after all there's already applications that do this - Expression Blend anyone?
Do you really need to recompile the underlying CS? As far as I can see it all you'll be doing is changing the apparent behaviour and look of the application and UI. This could be achieved by command binding within the xaml and styles for the components.
The reality is that in order to perform the functionality that you require you'll be giving the user a finite choice as to behaviour. You'll need to decide what behaviour is application and what is the UI.
Application bahaviour is governed by fixed commands (they could accept parameters to change behaviour).
UI behaviour (appearance, animation etc) is covered by the xaml. If the application runs in a browser window you could auto generate the xml needed as requried, linking it to the underlying app. commands and allow the browser to execute the new behaviour for you.
Is this a good idea? I can see a few problems with this.
How will the code behind 'know' how to interact with the rest of the application
Security? You will be allowing somebody to make system API calls on behalf of the main application
App domains???
Rather build up the forms using ItemsControls and DataTemplates. In the form where the user specifies what functionality he wants in the form, you will be presenting him with a list of 'building blocks' anyway. Make each 'building block' a ViewModel and associate each ViewModel with a DataTemplate 'UserControl'.

Categories

Resources