Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
SQL
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?

"
C++
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);
// DO PLAYBACK WITH KEYBOARD AND MOUSE HOOKED (DISABLED)	

        ret = clearPlaybackHook(m_hWnd);


}
Posted

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900