Imagine there is an application that has a window with a fixed size, where all controls remain at exactly known places (yes, there are such applications). Now imagine that said application's window is quite small and almost unusable on a touch-screen device. My idea now is to build a simple WPF UI, that maps certain controls of the external application to a touch-friendly UI.
(And this is actually not about gaming, but rather about making music. I want to use the small external application live on stage...)
I found a whole bunch of ways of controlling external applications, most of them getting an handle to the external application's window, then getting a handle to a button, then performing a mouse click on that, like in answers provided to the following questions:
- Control external window in visual studio c#
- How to get the handle of 3rd party application's button using c#?
Other answers propose to move the mouse to the desired location and then perform certain mouse events:
- programmatically mouse click in another window
- How to get the handle of 3rd party application's button using c#?
All of these approaches have drawbacks: Sometimes they need to know the target applications's structure. Sometimes they use deprecated API methods. Sometimes the move the cursor of the mouse to the external application.
So here is my question: How can I perform mouse actions on external applications relative to the external application's window without actually moving the mouse pointer?
Ideally there would be no need for external application's window to be on top, meaning that ideally my WPF UI would be a fullscreen one.
NB: Some commenters suggested using UI Automation for that task. I tried to walk the UI tree of the external application using Inspect, but that yielded unsatisfying results: