probably at the beach
probably at the beach

Reputation: 15227

Forms application not receiving mouse or keyboard events

I have a C# .NET 2.0 application running on client kiosk machine (Windows XP) that occasionally puts up a window for user input. The other kiosk software seems to be interfering with it somehow because while it is running our window will not receive Mouse or Keyboard events despite it being the top window. When the other software is not running all works as expected. Does anyone have any insight as to what might be going on here?

Thanks

Upvotes: 2

Views: 699

Answers (3)

JonPall
JonPall

Reputation: 814

If in doubt - use Spy++ provided with Visual Studio to see what messages your window receives from the system.

If the other application blocks all input, it's not conforming to the Win32 API. That's why the low level hooks timeout was introduced in Vista and newer Win OS. Meaning a process would be kicked out of the low level hook chain, if it held onto a hook too long before calling CallNextHookEx() and not receive any low level hook messages anymore.

On Windows XP, there is no such limitation. A process can take as much time as they want to process a hooking message. The other program is either buggy, or evil. If it's essential that your application has input, then just close the other one programmatically or contact the author of it and explain the situation.

Upvotes: 2

Tarec
Tarec

Reputation: 3255

Take a look here

http://www.codeproject.com/Articles/7294/Processing-Global-Mouse-and-Keyboard-Hooks-in-C

Using global keyboard hook should do just fine and some sources are included as well. Also, some user seem to solve similar problem by using ManagedSpyLib:

https://stackoverflow.com/a/8829286/1284902

Upvotes: 1

Justin Loveless
Justin Loveless

Reputation: 522

After some digging, it is possible that the other windows forms program is utilizing a low level keyboard hook similar to one found here http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx. After following a link in that article, I came across a summary of that code snippet

For a concrete example of this, consider the (buggy) code in Figure 4. Using a low-level keyboard windows hook, the code intercepts all WM_KEYDOWN messages sent to any window and prints out the corresponding key.

Source: http://msdn.microsoft.com/en-us/magazine/cc163606.aspx

Upvotes: 1

Related Questions