How to Get handle of a window and disable the Keyboard inputs using c# ?
Asked
Active
Viewed 355 times
1 Answers
1
To prevent keyboard input in a window in another process, you need to make a keyboard hook.
You can then check GetForegroundWindow()
and suppress the input.

SLaks
- 868,454
- 176
- 1,908
- 1,964
-
-
-
-
Now i set the forgroundwindow to my application. How to suppress the input in the window now ? – Anuya May 21 '10 at 04:14
-
System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcessesByName("notepad"); if (p.Length > 0) { SetForegroundWindow(p[0].MainWindowHandle); } – Anuya May 21 '10 at 04:15
-
You can do that, but it's unlikely to work. [You cannot steal focus from other programs](http://blogs.msdn.com/oldnewthing/archive/2004/02/16/73780.aspx). – SLaks May 21 '10 at 04:16
-
[Correct. You cannot](http://blogs.msdn.com/oldnewthing/archive/2009/02/20/9435239.aspx). – SLaks May 21 '10 at 04:18
-