Click here to Skip to main content
15,892,674 members

windows ll_keyboard_hook and ll_mouse_hook trying to disable input.

jamescaunt asked:

Open original thread
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);


}
Tags: Windows, Hooking

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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