11 个解决方案
#1
// 关闭组合键
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, &bOld, NULL);
// 重新打开组合键
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, &bOld, NULL);
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, &bOld, NULL);
// 重新打开组合键
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, &bOld, NULL);
#2
方法是用键盘钩子,过滤Alt+tab
#3
#define _WIN32_WINNT 0x0400
#include
LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
WPARAM wParam, LPARAM lParam)
{
BOOL fEatKeystroke = FALSE;
if (nCode == HC_ACTION) {
switch (wParam) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
fEatKeystroke =
((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL)&0x8000) != 0))||
( p->vkCode == VK_LWIN) || ( p->vkCode==VK_RWIN )
;
break;
}
}
return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam,
lParam));
}
int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int)
{
// Install the low-level keyboard & mouse hooks
HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc, hinstExe, 0);
// Keep this app running until we're told to stop
MessageBox(NULL,
TEXT("Alt+Esc, Ctrl+Esc, Alt+Tab, LWIN and RWIN are now disabled.\n")
TEXT("Click \"Ok\" to terminate this application and re-enable these keys."),
TEXT("Disable Low-Level Keys"),
MB_OK);
UnhookWindowsHookEx(hhkLowLevelKybd);
return(0);
}
#include
LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
WPARAM wParam, LPARAM lParam)
{
BOOL fEatKeystroke = FALSE;
if (nCode == HC_ACTION) {
switch (wParam) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
fEatKeystroke =
((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL)&0x8000) != 0))||
( p->vkCode == VK_LWIN) || ( p->vkCode==VK_RWIN )
;
break;
}
}
return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam,
lParam));
}
int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int)
{
// Install the low-level keyboard & mouse hooks
HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc, hinstExe, 0);
// Keep this app running until we're told to stop
MessageBox(NULL,
TEXT("Alt+Esc, Ctrl+Esc, Alt+Tab, LWIN and RWIN are now disabled.\n")
TEXT("Click \"Ok\" to terminate this application and re-enable these keys."),
TEXT("Disable Low-Level Keys"),
MB_OK);
UnhookWindowsHookEx(hhkLowLevelKybd);
return(0);
}
#4
呵呵,楼上将代码都给你帖出来了。
#5
BestBear(天外飞熊) 的代码很好用!!
不过有个小错误:第二行应该是#include <windows.h>
不过有个小错误:第二行应该是#include <windows.h>
#6
钩子很好用,楼上贴出来的代码很全了。
#7
BestBear的代码在win98下管用吗?
#8
用键盘钩子 keyboardhook
#9
用低级键盘钩子
参考:http://www.xiaozhou.net/cooldog/blogview.asp?logID=21
参考:http://www.xiaozhou.net/cooldog/blogview.asp?logID=21
#10
up
#11
注册热键也可以
//关闭
RegisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(),100,MOD_ALT, VK_TAB);
//打开
UnregisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(), 100);
//关闭
RegisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(),100,MOD_ALT, VK_TAB);
//打开
UnregisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(), 100);
#1
// 关闭组合键
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, &bOld, NULL);
// 重新打开组合键
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, &bOld, NULL);
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, &bOld, NULL);
// 重新打开组合键
BOOL bOld;
SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, &bOld, NULL);
#2
方法是用键盘钩子,过滤Alt+tab
#3
#define _WIN32_WINNT 0x0400
#include
LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
WPARAM wParam, LPARAM lParam)
{
BOOL fEatKeystroke = FALSE;
if (nCode == HC_ACTION) {
switch (wParam) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
fEatKeystroke =
((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL)&0x8000) != 0))||
( p->vkCode == VK_LWIN) || ( p->vkCode==VK_RWIN )
;
break;
}
}
return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam,
lParam));
}
int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int)
{
// Install the low-level keyboard & mouse hooks
HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc, hinstExe, 0);
// Keep this app running until we're told to stop
MessageBox(NULL,
TEXT("Alt+Esc, Ctrl+Esc, Alt+Tab, LWIN and RWIN are now disabled.\n")
TEXT("Click \"Ok\" to terminate this application and re-enable these keys."),
TEXT("Disable Low-Level Keys"),
MB_OK);
UnhookWindowsHookEx(hhkLowLevelKybd);
return(0);
}
#include
LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
WPARAM wParam, LPARAM lParam)
{
BOOL fEatKeystroke = FALSE;
if (nCode == HC_ACTION) {
switch (wParam) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
fEatKeystroke =
((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL)&0x8000) != 0))||
( p->vkCode == VK_LWIN) || ( p->vkCode==VK_RWIN )
;
break;
}
}
return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam,
lParam));
}
int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int)
{
// Install the low-level keyboard & mouse hooks
HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL,
LowLevelKeyboardProc, hinstExe, 0);
// Keep this app running until we're told to stop
MessageBox(NULL,
TEXT("Alt+Esc, Ctrl+Esc, Alt+Tab, LWIN and RWIN are now disabled.\n")
TEXT("Click \"Ok\" to terminate this application and re-enable these keys."),
TEXT("Disable Low-Level Keys"),
MB_OK);
UnhookWindowsHookEx(hhkLowLevelKybd);
return(0);
}
#4
呵呵,楼上将代码都给你帖出来了。
#5
BestBear(天外飞熊) 的代码很好用!!
不过有个小错误:第二行应该是#include <windows.h>
不过有个小错误:第二行应该是#include <windows.h>
#6
钩子很好用,楼上贴出来的代码很全了。
#7
BestBear的代码在win98下管用吗?
#8
用键盘钩子 keyboardhook
#9
用低级键盘钩子
参考:http://www.xiaozhou.net/cooldog/blogview.asp?logID=21
参考:http://www.xiaozhou.net/cooldog/blogview.asp?logID=21
#10
up
#11
注册热键也可以
//关闭
RegisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(),100,MOD_ALT, VK_TAB);
//打开
UnregisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(), 100);
//关闭
RegisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(),100,MOD_ALT, VK_TAB);
//打开
UnregisterHotKey(theApp.GetMainWnd()->GetSafeHwnd(), 100);