//起屏蔽作用的新SAS window回调函数
LRESULT CALLBACK SASWindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
if(uMsg == WM_HOTKEY)
{
//屏蔽所有WM_HOTKEY消息
OutputDebugString("All SAS window's hotkeys are disabled");
return 1;
WORD wKey = HIWORD(lParam);
WORD wModifier = LOWORD(lParam);
bool IsCtrlDown = ((wModifier & VK_CONTROL) != 0);
bool IsAltDown = ((wModifier & VK_MENU) != 0);
bool IsShiftDown = ((wModifier & VK_SHIFT) != 0);
//Ctrl + Alt + Del组合键
if(IsCtrlDown && IsAltDown && wKey == VK_DELETE)
{
return 1; //屏蔽
}
//Ctrl + Shift + Esc组合键,这个组合键将显示任务管理器,可根据需要是否屏蔽。
else if(IsCtrlDown && IsShiftDown && wKey == VK_ESCAPE)
{
// Do nothing
}
}
return CallWindowProc((WNDPROC)FOldProc,hwnd,uMsg,wParam,lParam);
}
//_H低级键盘钩子回调函数
LRESULT CALLBACK KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
if (nCode == HC_ACTION)
{
switch (wParam)
{
case WM_KEYDOWN: case WM_SYSKEYDOWN:
//case WM_KEYUP: case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
if (p->vkCode == VK_F12)
{
//实现模拟按键代码
MessageBox(GetForegroundWindow(),"I'm in position..","ZZ",MB_OK);
}
//屏蔽ALT+TAB
else if ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0))
{
OutputDebugString("ALT+TAB is disabled");
return 1;
}
//屏蔽ALT+ESC
else if ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0))
{
OutputDebugString("ALT+ESC is disabled");
return 1;
}
//屏蔽CTRL+ESC
else if ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0))
{
OutputDebugString("CTRL+ESC is disabled");
return 1;
}
//屏蔽CTRL+SHIFT+ESC,(SAS window中也已屏蔽)
else if ((p->vkCode == VK_ESCAPE) &&
((GetKeyState(VK_CONTROL) & 0x8000) != 0) &&
((GetKeyState(VK_SHIFT) & 0x8000) != 0))
{
OutputDebugString("CTRL+SHIFT+ESC is disabled");
return 1;
}
//屏蔽ALT+F4
else if ((p->vkCode == VK_F4) && ((p->flags & LLKHF_ALTDOWN) != 0))
{
OutputDebugString("ALT+F4 is disabled");
return 1;
}
//屏蔽左右windows键
else if (p->vkCode == VK_LWIN || p->vkCode == VK_RWIN)
{
OutputDebugString("windows key is disabled");
return 1;
}
//此处无法屏蔽CTRL+ALT+DEL,已在SAS window中屏蔽
else if ((p->vkCode == VK_DELETE) &&
((GetKeyState(VK_CONTROL) & 0x8000) != 0) &&
((GetKeyState(VK_MENU) & 0x8000) != 0 ))
return 1;
break;
}
}
return CallNextHookEx(hHook,nCode,wParam,lParam);
}
JNIEXPORT void JNICALL Java_shieldHK_ShieldHotKey_Attach
(JNIEnv *env, jclass obj){
Attach();
}