views:

32

answers:

0

Hello there,

I'm trying to send keys to a minimized/unfocused D3D application using C#.

So I borrow FindWindowEx and PostMessage function from the Win32 API.

I also used Winspector Spy to determine the class name of the D3D canvas to fill in the 3rd parameter of FindWindowEx function, and the name is "D3D Window".

Here's my code:

System.Diagnostics.Process proc = System.Diagnostics.Process.GetProcessById(proc_id);
IntPtr hWnd = FindWindowEx(proc.MainWindowHandle, IntPtr.Zero, "D3D Window", null);

Unluckily, FindWindowEx fails. It returns zero (checked by putting a breakpoint). I have rechecked for many times that the proc variable contains the correct process information, and I used the correct class name (It is exactly the same as shown in Winspector, "D3D Window").

Did I missed a thing?

Please leave a comment if you have questions/need more information regarding my problem.

Any kind of help would be appreciated :)

Thanks.