c# api button click - c#

With 'Calculator', I can click button by use FindWindowEx and SendMessage.
But some application can't use spy++ to get information of button.
For example 'Visual Studio'. How I can click buttons in this application?

In Windows Forms or Win32, UI elements like buttons are native OS window objects. However, I believe Visual Studio is written using WPF where buttons are not native OS window objects, so FindWindowEx will not work on them. You should try to using UI Automation to interact with user interfaces (e.g. to click buttons) and tools like Inspect.

Related

How to find button handle in a WPF application, and click it programatically?

I'm trying to programmaticly (from my own application) press a button that is located on another running windows (WPF) application.
Todo so, a handle to the button would be needed. There are plenty of posts about how to get such a handle.
However, it seem that WPF applications don't present handles for their graphical components:
https://www.experts-exchange.com/questions/25665615/Spy-or-Windows-Api-Functions-not-locating-controls-on-child-window.html
Any clues on how to achieve an automated press on a button in such an application?
I don't have control of the source code for the application with the button.
I believe you'll need to look into UI Automation https://learn.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-overview

Handle Rdp ActiveX minimize event

I've developed a simple .net form application where I've embedded the RdpClient ActiveX.
To reproduce the application, you have to:
'Add Reference' and select COM
include 'Microsoft Terminal Services Control Type Library'
select the ToolBox, 'Choose Items...' and go to 'COM Components' tab
look for 'Microsoft RDP Client Control - version 6' (this is the version I've used)
Now you can drop this Control on the form.
Handle the form Shown event with this code
axMsRdpClient6.FullScreen = true;
axMsRdpClient6.Server = "yourserver";
axMsRdpClient6.Connect();
Then when the rdpclient window appear, click the minimize button on the top bar.
My question is: why the event AxMSTSCLib.AxMsRdpClient7.OnRequestContainerMinimize is not fired when minimize button is clicked?
I need to handle when the user minimize the client to take peculiar actions (write log files, activate other windows application and so on).
I've found the answer in MSDN
This method will only be called if the container-handled full-screen mode is enabled - see
IMsTscAdvancedSettings::put_ContainerHandledFullScreen for more information.

How to run Windows Mobile application in full screen mode?

I have a Windows Mobile application developed with Visual Studio 2010 and C# (Smart Device Project). When I run the application there's a start menu bar visible on the top and keyboard bar on the bottom. How can I make my application run in full-screen mode?
If possible I would like to have a solution that will allow me to turn full-screen mode on and off on runtime (after clicking some form button for example).
(Assuming the question is about Windows Mobile and not Windows Phone.)
On Windows Mobile if you want to hide parts of Windows that normally can't be hidden, you have to hide them with P/Invoke. There are plenty of questions like this already answered and some other resources too. And of course you can call the P/Invoke from an event handler.

click on a button in another application from my C# application?

I want to click on a button in another application from my C# application ,
and I don't have the source code for the application that contains the button
let us say as an example ...can I use windows calculator from my application by clicking its buttons Programmatically
I am using c# and .NET
I think I must use windows api to do this
does anybody have any idea????
Yes, it's not too complicated. You can use FindWindowEx to get the window handle, then iterate through the windows elements and use sendmessage or postmessage to send the WM_Click message.
Here's a codeproject project that does exactly what you want.
Code project

How to attach a winforms dialog to an existing toolbar/menubar (compiled C++ app)?

To attach a winforms dialog on Microsoft Wordpad toolbar/menubar?
First you need to get your assembly loaded into the target process.
Then you'll need to use Win32 API functions to create the new menu item, with a unique child ID.
Finally, you'll need to subclass the window procedure and process WM_COMMAND messages, which are generated by Windows when a native menu item is selected. Be sure to process all other messages, including WM_COMMAND messages that don't match your menu item, to the original window procedure by calling base.WndProc.
Of course, this won't work on Windows 7 WordPad, since it doesn't have menus or toolbars, it uses the new "ribbon" control. The Ribbon API may give you a way to add new items, however.
The Toolbar control that is provided with the Microsoft Windows Common Controls (COMCTL32.OCX) can be customized by users...
http://support.microsoft.com/kb/q174087/

Categories

Resources