Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

kill keyboard mouse

Posted on 2007-08-09
7
Medium Priority
?
790 Views
Last Modified: 2013-12-03
how do I lock the keyboard off in .Net
also the mouse
0
Comment
Question by:Micki-Weaver
7 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 19664384
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
 

Author Comment

by:Micki-Weaver
ID: 19664454
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
 
LVL 6

Expert Comment

by:___XXX_X_XXX___
ID: 19666007
You can use BlockInput API.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Micki-Weaver
ID: 19666272
it turns out you can use 2 and 7 I think, I'll put up the code:) next day
0
 
LVL 2

Expert Comment

by:Vasanth S
ID: 19672638
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
 

Author Comment

by:Micki-Weaver
ID: 19673203
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
 

Author Comment

by:Micki-Weaver
ID: 19673209
this lock a app or the system from mouse and keyboard
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question