I like williamhelmswort's mouse-hook snippet. It always makes random amusement when I use it on somebody elses computer and watch them struggle to move the mouse XD
I wrote a slightly evil code, which I decided not to put up as a code snippet because it completely stops you from doing ANYTHING with the mouse or keyboard The only way to get out of it is to either log off (may only work on some computers) . or to shut down the computer. Be prepared before trying it out
The only thing you can't disable like this is the ability for the user to press CTRL-ALT-DEL
/*
* Make sure project type is windows application
*/
#define _WIN32_WINNT 0x0500
#include<windows.h>
#include<cmath>
LRESULT CALLBACK mouseHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
return 1;
}
LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
return 1;
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd) {
// Set mouse hook
HHOOK mouseHook = SetWindowsHookEx(
WH_MOUSE_LL, /* Type of hook */
mouseHookProc, /* Hook process */
hInstance, /* Instance */
NULL);
HHOOK keyboardHook = SetWindowsHookEx(
WH_KEYBOARD_LL,
keyboardHookProc,
hInstance,
0);
// Wait for user to exit
MessageBox(NULL, "Press OK to close.", "", MB_OK);
return 0;
}
But just incase you want to be able to get out of it, you can make it so the user can exit the process be pressing the ESCAPE button, just change the keyboard hook like this.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.