Getting the button text of WPF application from another application - c#

Is it possible to get the text of a button , that has been clicked in a WPF application from another c# application.... Tried SendMessage with the button handle , but it does not seem to work

UI Automation will do what you want. WPF controls don't have HWNDs, so SendMessage won't work.

You dont provide much info but I will try to provide some possible solutions.
I assume by SendMessage you mean this:
SendMessage
You basically want that a c# application be able to get internal state information from a wpf application.
Or, in other words, 2 c# apps need to communicate data. Well, try this:
InterProcess Communication
Otherwise try reflection. Reflect the wpf app into your c# app and try to get the button text value, if that value is known at compile time. But I wouldnt use reflection for just sharing a text value.

Related

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 do click on specific screen text?

Do you know how to do click on a specific screen text?
I need to do click on a text inside a GUI Object from a external application; I need to automate this with C#. What is the reference that I need to this? I'm new in C#
You need to learn two tricks to accomplish this:
How to find the HWND (the handle) to the window that you want to send the click event to. There are some APIs in the Forms namespace to help with this or you can use PInvoke.
How to send the appropriate windows messages (WM_MOUSEDOWN, WM_MOUSEUP) using SendMessage.
Put these two together and you should be able to simulate a click event.

What "growl" type notification windows are available for WPF (windows that appear and fade after X seconds)?

I wanted to know if there are any good "growl" type notification windows available as open source or guided tutorials for WPF applications. I'm looking for a window that can appear when users save for example, notifying them that the save was successful and then disappears after X seconds (with a fade out) without the user needing to take the explicit action to close the notification window. This way for messages/notifications that require no confirmation, like the example, the user would not have to click "OK" to make the messagebox or dialog close.
This link could help you:
http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx
It is a Pure WPF implementation of the NotifyIcon class from WinForms and supports almost everything normal WPF controls do :)
Cheers
Why don't you use GrowlForWindows?
You can use C# or VB.

Desktop Application auto-complete

I am working on a .net project, (first ever for me) and I would like to do something like the AJAX.AutoCompleteExtender that I used with my WEB projects.
What should I use? is there something ready to use, Or I should go and make my own using the textbox, or combo box or something like that.
The app I am working on, is a .net application made for Windows Mobile. (Pocket PC)
thanks
Check out this sample for creating an Auto-Complete TextBox using WinForms:
Creating WinForms AutoComplete TextBox using C#
That should at least get you pointed in the right direction (using Events to listen for keypresses, querying your datasource, and drawing the results to screen). You might need to slightly modify things for WinCE but it shouldn't be too difficult.

Opening an application inside a form - C# or VB.NET

I am writing an application and I would like to be able to display another application inside it. (Think like a windows form with a small box, or a tab that is displaying a totally seperate application.)
Is that something that can be done? If so, can anyone give some direction on how to go about doing it?
I am looking for something in the C# or VB.NET world.
THANKS!
You need a hWnd (handle) of window from another application.
Then you need a hWnd of container control in you application (System.Windows.Forms.Control.Handle property).
Then you need use a Win32API function SetParent, and that all you need.
On the SetParent page is little sample, which should do what you need.

Categories