Help ^_^ Assembly Language - Disabling Mouse and Keyboard






My instructor wanted me to make a program using assembly laguage(MASM is what we use) to disable and enable a mouse and keyboard.

He wants that when he press a button like "a" on the keyboard -> The Mouse will be DISABLED.
He wants that when he press a button like "b" on the keyboard -> The Mouse will be ENABLED.

And same too with the Keyboard but he wants 2 buttons to be left behind like "c" and "d" so then when presses "c" it will be disabled and if he presses "d" it will be enabled.

:sad: Can someone please help me by providing me a simple program in txt huhuhu. I am doomed coz its deadline is only till friday. I have been searching for solutions for a week but I can't find so I search a community and I saw community =( I wish I could get some help... Thanks to all.
Posted on 2008-11-04 18:58:49 by Glenn
Just some ideas:

Use GetAsynchKeyState to check the keyboard.
When the 'disable' key is pressed, note the mouse position using GetCursorPos.
While disabled, fake disabling of the mouse by using SetCursorPos to the position it was at when disabled.
When the 'enable' key is pressed, set a flag to stop calling SetCursorPos.

You can use similar apis to get the handle of the window the mouse is over, and override its WndProc in order to receive mousemoved messages - dunno if that works for desktop window, in this case you can just hammer SetCursorPos.

I have grave reservations about the identity of your instructor, but I don't see this as being particularly damaging.
Posted on 2008-11-07 04:51:13 by Homer
USER32.DLL has a function called BlockInput() which disables the mouse and keyboard for n number of seconds from reaching applications.

You can then, as Homer said, use GetAsyncKeyState() to determine which keys are pressed while the input is blocked and act accordingly.
Posted on 2008-11-07 16:09:01 by XCHG