kill keyboard mouse

how do I lock the keyboard off in .Net
also the mouse
Micki-WeaverAsked:
Who is Participating?
 
jkrCommented:
Check out http://www.codeproject.com/csharp/globalsystemhook.asp ("Global System Hooks in .NE") and http://www.codeproject.com/csharp/globalhook.asp ("Processing Global Mouse and Keyboard Hooks in C#") - the idea is to "swallow" the mouse and keyboard messages in the hooks.
0
 
Micki-WeaverAuthor Commented:
I'm looking for something more simple under 30 lines that just eat the mouse and keyboad events, the large projects mix what is going on into to much
0
 
___XXX_X_XXX___Commented:
You can use BlockInput API.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Micki-WeaverAuthor Commented:
it turns out you can use 2 and 7 I think, I'll put up the code:) next day
0
 
Vasanth SCommented:
Hi,
   Are you looking for something which could process the keyboard and mouse events in the windows form and ignore them?

Can you please explain me?

thanks,
Vaz
0
 
Micki-WeaverAuthor Commented:
class Class1
    {
       
        static System.IntPtr hhookMoues = System.IntPtr.Zero;
        static System.IntPtr hhookKeyboard = System.IntPtr.Zero;
        [System.Runtime.InteropServices.DllImport("kernel32.dll")]
        static extern System.IntPtr LoadLibrary(string lpFileName);
        [System.Runtime.InteropServices.DllImport("user32.dll")]
        static extern System.IntPtr SetWindowsHookEx(int idHook, keyboardHookProc callback, System.IntPtr hInstance, uint threadId);

public void flip()
{
        /// <summary>
        /// Loads the library.
        /// </summary>
        /// <param name="lpFileName">Name of the library</param>
        /// <returns>A handle to the library</returns>

            hhookKeyboard = SetWindowsHookEx(WH_KEYBOARD_LL, hookProc, hInstance, 1);
            hhookMoues = SetWindowsHookEx(WH_MOUSE_LL, hookProc, hInstance, 1);
}

        public static bool LockDownAppSpecific;

        static int WH_KEYBOARD_LL
        {
            get
            {
                if (LockDownAppSpecific)
                    return 2;
                else
                    return 13;
            }
        }
        static int WH_MOUSE_LL
        {
            get
            {
                if (LockDownAppSpecific)
                    return 7;
                else
                    return 14;
            }
        }
    }
}
0
 
Micki-WeaverAuthor Commented:
this lock a app or the system from mouse and keyboard
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.