Bad idea. In general case, this is impossible. The processes are designed to be isolated, to minimize possible intervention from other processes, eliminate clashes in memory (each process is executed in a separate memory space, which is based on hardware isolation of memory).
In some cases, it is possible, but you never know in advance. For example, if the application is based on WPF, or, more generally, DirectX, there is no message pumping at the level of buttons. From the standpoint of Windows messaging system, those buttons simply don't exist (then are "light-weight", not windowed). In special cases, when your "remote" buttons are windowed control, you can capture windows message using global(!) Windows Hooks. For global hooks, using .NET application won't be enough, you will also need to write a native (unmanaged) DLL, to write your hook handles there and install the hooks. Please see my recent answer:
Is there a way for a Program ran on a Client system to See events that happen inside the Host Remote Desktop Window?[
^].
See also my other answers on the topic:
http://msdn.microsoft.com/en-us/magazine/cc188966.aspx[
^],
System Idle Time for user being idle[
^],
How the Keyboard Hook works and how it is being implemented[
^],
How to set a window hook in other application?[
^],
Creating global shortcuts.[
^].
You would need to install a hook procedure for
WH_GETMESSAGE
, again, in native code, not .NET. Please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx[
^].
—SA