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

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

Related

How to find coordinates of a link with a specific caption in an Electron desktop application from a testing application in C#

Context:
I am beginning to write a testing application in C# which, as part of testing, needs to do UI automation of another Windows desktop application written in Electron, to extract certain results and compare with expected output.
The Electron application has a few hyperlinks, and HTML style buttons, which I need to locate and click.
The Electron application is written by another team and I cannot ask them to include testing features in the UI.
Question:
How can I dynamically find the position of the hyperlink with the text "Login" within the Electron application and click it from my C# application?
I have been able to start the Electron application programmatically, bring it to foreground and send keystrokes to it. Now I need to click on the Login hyperlink.
I have read many similar questions but most are for testing native Windows applications.
EDIT 1:
If I loop over all the child windows of the Electron application, I find only 2 windows. It seems Electron does not render hyperlinks or other HTML elements as Windows.
If I use SendMessage to read the window text, it only returns "Chrome Legacy Window".

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

C# Display text on the taskbar | Windows 10

I want to display a text in the taskbar like the NetSpeedMonitor program .
I thought about how Windows did that with der Date and Time display, but I couldn't find any answer.
I want to do this with C# and .Net 4.x
if you watch this pic
you see every thing in windows application have an handle(HWND) and if you get it you can change this app parameters and add or remove any thing on if look at this link there is sample for it in console application you just need just doing same thing on taskbar.
I created a dll for all office apps to use them in c# like this and i done this by using handles of office and my app

Custom search tab in Windows start menu search with C#

I am interested to know how can I do the same thing that the apllication listed below does:
Start Menu Calculator
I want to know how can I create an custom tab in Start Menu Search and then handle it with my WPF application. It should only be enabled until my application is running.( Just like what The calculator does )
I read something about windows API Code Pack and I downloaded it but I don't know how can I use it. I searched through it but I didn't find anything.( If you know how I could do this using with Windows API Code Pack, please write an example that explains how to do it in C#)
The main exe "Start Menu Calculator.exe" installs a windows hook (using SetWindowsHookEx) into explorer.exe. The hook is implemented as usual in SBLib.dll which is then injected into Windows Explorer's memory space.
This hook searches for window handles belonging to the search box. See a discussion around this here:
How do I get a "handle" on the Windows Search textbox? and probably sub classes the search box windows (if you kill the "Start Menu Calculator.exe" process abruptly, it crashes Windows Explorer too... which kinda confirms this)
It then reacts to key presses, and I suppose it butchers up the result window. In the hierarchies of Windows, I think it's a Window named "Desktop Search Open View", you can get to it with SPY++ under "Start Menu", aside the windows mentioned in the msdn forum above.
So, no nice API behind this nice application. Massive hacks instead :-)
I think however, some level of integration is possible, using documented behavior, with the search box. I have not dug further, but there is the notion of federated search in Windows (Windows 7 Federated Search). I don't see if this would be capable of reacting instantaneously to what the user types in though...
As a side note, if you're also looking for a way to run javascript code from C#, there is a question here on SO that says it all: parse and execute JS by C#
When making Start Menu Calculator I initially tried to use federated search and Managed (.NET) code however you can't integrate into the start menu, only the shell search (for web service based search which lets you return custom results based on a search string). The problem is that the federated search is structured such that all the search data is pre-indexed so for the calculator to work I would have had to pre index every possible calculation! The reason it all works this way is to make sure that clicking the start menu is always fast and responsive (you don't want a web service call everytime you press start in the shell).
I ended up hiring someone to write a native windows app that places a IE control into the Start menu search area and passes the searched text in with the source. All the visual stuff is just css made to look like the start menu rendering and the calculations handled in javascript.
So yes, a bit of a hack but it seems to work and I havent had/heard of any crashing issues so far.

Insert an application to another one.C#

Is it possible to insert one application for example to another application window using WinForms .NET application. I need application A to run in application B in a window of application B.
UPD
I would like to run .exe file in window of my program.
if you have not its source code, i think it is impossible
Possible duplicate answer: Embedding a winform within a winform (c#)
As stated in the answer to that question, you would be better moving your logic into a UserControl and hosting that control from either application in one WinForms window.

Categories

Resources