c# - Is there a way to catch a keyboard event in a dll? -


i need execute specific code when user presses keys keyboard.

nothing hard until now, should in dll project type, class library, , not use specific windows forms controls.

could achieved ? , if please provide me some examples or learning materials.

thanks.

you can use getkeyboardstate api function.

[dllimport ("user32.dll")] public static extern int getkeyboardstate( byte[] keystate );   private void form1_keydown( object sender, keyeventargs e ) {    byte[] keys = new byte[255];     getkeyboardstate (keys);     if( keys[(int)keys.up] == 129 && keys[(int)keys.right] == 129 )    {        console.writeline ("up arrow key , right arrow key down.");    } } 

Comments