mouse and keyboard lock in c++ through win32

hello sir/madam,
we are developing project on screen capturing and lock mouse and keyboard of client computer in JAVA. we are able to capture multiple client's screens. but in java , we didn't find any code to lock mouse and keyboard. so, i think it is possible to develop that code in C++. so can u give me some code example to lock mouse and keyboard so that i can call that functions of c++ in JAVA through JNI.pleas reply me.please sir/MADAM.................
you want to call C++ in java.. that means you need to write a dll in c++ and that will be called in java.. but is it possible to call dll's in java.. i dont have any idea..

for locking.. you need to use windows hooks..
something like this compiled in a dll.. this will hook a keyboard on system level.. similarly it can be done for mouse.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	hInst = (HINSTANCE)hModule;

    return TRUE;
}

LRESULT __declspec(dllexport)__stdcall  CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	char ch;	
	
	do
	{
		if (((DWORD)lParam & 0x40000000) &&(HC_ACTION==nCode))
		{		
			if ((wParam==VK_SPACE)||(wParam==VK_RETURN)||(wParam>=0x2f ) &&(wParam<=0x100))
			{
		
				
   					//handle keyboard here..
  
		}
	}while(0);

	return CallNextHookEx( hkb, nCode, wParam, lParam );
}


extern "C" BOOL __declspec(dllexport) InstallHook()
{
	hkb=SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardProc,hInst,0);

	return TRUE;
}


extern "C" BOOL __declspec(dllexport)  UnHook()
{
    	
     BOOL unhooked = UnhookWindowsHookEx(hkb);
     return unhooked;
} 
Last edited on
Topic archived. No new replies allowed.