Click here to Skip to main content
13,289,626 members (53,899 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi, im trying to disable user input using global system hooks. heres some of my code. my understanding is mouse input should be disabled as it is not passed down after PlaybackMouseHook is called. However when i run this code, i can still move the mouse. It looks as if the hook works for a bit and then is silently unhooked as described below but im not sure. i tried running as admin no luck. msdn says:
The hook procedure should process a message in less time than the data entry specified in the LowLevelHooksTimeout value in the following registry key:
HKEY_CURRENT_USER\Control Panel\Desktop
The value is in milliseconds. If the hook procedure times out, the system passes the message to the next hook. However, on Windows 7 and later, the hook is silently removed without being called. There is no way for the application to know whether the hook is removed.

however this key isnt present on my win 8 system. I have added a key with a 200 millisecond value and i dont think this has any effect. can anyone help?

static LRESULT CALLBACK PlaybackMouseHook(UINT nCode,WPARAM wParam,LPARAM lParam)
	return 1;

_declspec(dllexport) BOOL setPlaybackHook(HWND hWnd)
	if(hWndServer != NULL)
		return FALSE;
	wh_llkey_playback_hook = SetWindowsHookEx(WH_KEYBOARD_LL,(HOOKPROC)PlaybackHook,hInst,0);
	wh_llmouse_playback_hook = SetWindowsHookEx(WH_MOUSE_LL,(HOOKPROC)PlaybackMouseHook,hInst,0);
	if(wh_llkey_playback_hook != NULL && wh_llmouse_playback_hook != NULL)
		hWndServer = hWnd;
		return TRUE;
	return FALSE;


void CHookDlg::OnBnPlaybackActions()
	BOOL ret = setPlaybackHook(m_hWnd);
        ret = clearPlaybackHook(m_hWnd);


Posted 3-Dec-12 1:15am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171207.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100