Hello! I wanted to find out from experienced programmers: is it possible to draw the window of another application and redirect input-output from my application to this application?

Those. I would like to have some Image inside my WPF application, in which a window of a third-party program would be drawn, if the contents of this window are changed, then Image redraws the window. At the same time, if there was a click on Image at any point, then for this third-party window, a click event occurs at the point that I clicked on the image.

Is it possible to implement this with WinAPI and in what direction should we look for a solution to this problem?

Thanks in advance, proggamer12

For example, how this program is implemented: http://store.steampowered.com/app/382110/

    1 answer 1

    Well, if in the forehead, then you can find the window of the program of interest and get the window "target"

    [DllImport("user32.Dll")] public static extern int FindWindow (string lpClassName, string lpWindowName); 

    Get area of ​​this window

      [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle); 

    then start the timer scanning area of ​​this window and with changes, redraw it in your Image. As for the clicks, since you have a duplicate of the coordinates of this window, you can transpose the coordinates for the "target" window and call WinApi on the coordinates.

     [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);