Prevent WPF Global Keyboard Hook from stops working after hitting keys a while C# .NET

The article written by Dylan Currier, Low Level Global Keyboard Hook / Sink in C# .NET is one the simple, easily understandable, and and working post on Global Keyboard hook out there in internet. It worked in my WPF application and I added following line in the WPF app to refresh hook after each key press- IDK  if it is write or wrong, more likely to be a wrong practice to hook/unhook every time but it gets the job done. The primary reason to refresh hook is to prevent app hanging (not responding to the key press) after few clicks on the WPF button.

void _listener_OnKeyPressed(object sender, KeyPressedArgs e)
        {
           
          _listener.UnHookKeyboard();
          _listener.HookKeyboard();
        }

Following is the video from Dylan Currier  on Low Level Keyboard Hook in C# / .NET"


Comments

Popular posts from this blog

Generate ArcGIS Token By URL Request From ArcGIS Portal, Federated Environment , ESRI JS API and Angular snippets

Update WPF Interaction Triggers in from .Net Framework 4.8 to .Net 5

Solution: IntelliJ not recognizing a particular file correctly, instead its stuck as a text file